Skip to content

Commit 26772bc

Browse files
committed
update workflow
1 parent 4f58b08 commit 26772bc

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

.github/scripts/matrix_generator.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import os
22
import json
33
import argparse
4-
from typing import List, Dict, Tuple
4+
from typing import List, Dict
55

66
# ---------------------------------------------------------
7-
# THE VIP LIST: Known mammoths that must bypass the queue
7+
# THE VIP LIST: These will get their own dedicated isolated VMs
88
# ---------------------------------------------------------
99
MAMMOTH_OVERRIDES = {
1010
"google-cloud-spanner": 9999,
@@ -15,16 +15,11 @@
1515
}
1616

1717
def calculate_package_weight(pkg_path: str) -> int:
18-
"""
19-
Determines computational weight. Mammoths get massive artificial weights
20-
to guarantee they are processed first.
21-
"""
2218
pkg_name = os.path.basename(os.path.normpath(pkg_path))
2319
if pkg_name in MAMMOTH_OVERRIDES:
2420
return MAMMOTH_OVERRIDES[pkg_name]
2521

2622
base_weight = 1
27-
2823
meta_path = os.path.join(pkg_path, ".repo-metadata.json")
2924
if os.path.isfile(meta_path):
3025
try:
@@ -34,7 +29,6 @@ def calculate_package_weight(pkg_path: str) -> int:
3429
except Exception:
3530
pass
3631

37-
# Fallback for standard packages: roughly estimate by test file count
3832
test_dir = os.path.join(pkg_path, "tests")
3933
if os.path.isdir(test_dir):
4034
for root, _, files in os.walk(test_dir):
@@ -48,8 +42,6 @@ def create_balanced_buckets(packages: List[str], max_buckets: int) -> List[Dict]
4842
return []
4943

5044
pkg_weights = [(pkg, calculate_package_weight(pkg)) for pkg in valid_pkgs]
51-
52-
# Sort heaviest to lightest. Mammoths (9999) will always be at the front.
5345
pkg_weights.sort(key=lambda x: x[1], reverse=True)
5446

5547
num_buckets = min(len(valid_pkgs), max_buckets)
@@ -60,7 +52,25 @@ def create_balanced_buckets(packages: List[str], max_buckets: int) -> List[Dict]
6052
lightest["packages"].append(pkg)
6153
lightest["total_weight"] += weight
6254

63-
return [{"id": b["id"], "packages": " ".join(b["packages"])} for b in buckets if b["packages"]]
55+
# Build the final output payload
56+
final_output = []
57+
for b in buckets:
58+
if not b["packages"]:
59+
continue
60+
61+
# Clean UI labels for isolated VIPs
62+
first_pkg_name = os.path.basename(os.path.normpath(b["packages"][0]))
63+
if first_pkg_name in MAMMOTH_OVERRIDES:
64+
ui_label = first_pkg_name.replace("google-cloud-", "")
65+
else:
66+
ui_label = f"Bucket {b['id']}"
67+
68+
final_output.append({
69+
"id": ui_label,
70+
"packages": " ".join(b["packages"])
71+
})
72+
73+
return final_output
6474

6575
def main():
6676
parser = argparse.ArgumentParser()
@@ -82,4 +92,4 @@ def main():
8292
print(json.dumps(buckets, indent=2))
8393

8494
if __name__ == "__main__":
85-
main()
95+
main()

.github/workflows/experiment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ jobs:
4646
matrix:
4747
chunk: ${{ fromJSON(needs.discover.outputs.buckets) }}
4848
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
49-
50-
name: Unit (Py ${{ matrix.python }})
49+
50+
name: Unit (Py ${{ matrix.python }} - ${{ matrix.chunk.id }})
5151
steps:
5252
- uses: actions/checkout@v4
5353
- uses: astral-sh/setup-uv@v5
@@ -71,7 +71,7 @@ jobs:
7171
7272
FAILED=0
7373
74-
for pkg in ${{ matrix.chunk }}; do
74+
for pkg in ${{ matrix.chunk.packages }}; do
7575
echo "=========================================================="
7676
echo "🚀 TESTING: $pkg (Python ${{ matrix.python }})"
7777
echo "=========================================================="

0 commit comments

Comments
 (0)