Files
TheRock/rocm-systems/projects/rccl/tools/ci/lib/parse_gin_config.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

100 lines
2.6 KiB
Python
Executable File

#!/usr/bin/env python3
"""Flatten the GIN test matrix JSON into tab-separated rows for bash.
`run-gin-ci.sh` reads the emitted rows with `IFS=$'\t' read`, so the column
layout below is a stable contract:
mca\t<flags>
debug_env\t<-x flags> (appended to every test only when RCCL_CI_DEBUG=1)
test\t<name>\t<kind>\t<bin>\t<-x env flags>\t<args>
"""
import argparse
import json
import sys
from pathlib import Path
from typing import NamedTuple
class GinTest(NamedTuple):
"""A single GIN test entry parsed from the matrix JSON."""
name: str
kind: str
bin: str
env: list[str]
args: str
class GinConfig(NamedTuple):
"""The parsed GIN test matrix."""
mca: str
debug_env: list[str]
tests: list[GinTest]
def parse_config(path: Path) -> GinConfig:
"""Read and validate the GIN test-matrix JSON file."""
try:
with open(path) as f:
data = json.load(f)
except json.JSONDecodeError as e:
raise ValueError(f"Invalid JSON in {path}: {e}") from e
except OSError as e:
raise RuntimeError(f"Cannot read {path}: {e}") from e
tests: list[GinTest] = []
for entry in data.get("tests", []) or []:
tests.append(
GinTest(
name=entry.get("name", ""),
kind=entry.get("kind", ""),
bin=entry.get("bin", ""),
env=list(entry.get("env", []) or []),
args=entry.get("args", "") or "",
)
)
return GinConfig(
mca=data.get("mca", "") or "",
debug_env=list(data.get("debug_env", []) or []),
tests=tests,
)
def format_rows(config: GinConfig) -> list[str]:
"""Render the parsed config as tab-separated rows for the bash runner."""
rows = ["mca\t" + config.mca]
rows.append("debug_env\t" + " ".join("-x " + e for e in config.debug_env))
for test in config.tests:
env_flags = " ".join("-x " + e for e in test.env)
rows.append(
"\t".join(["test", test.name, test.kind, test.bin, env_flags, test.args])
)
return rows
def main(argv: list[str]) -> int:
parser = argparse.ArgumentParser(
description="Flatten the GIN test matrix JSON into TSV rows for bash."
)
parser.add_argument(
"config",
type=Path,
help="Path to the GIN test-matrix JSON file (e.g. lib/gin-tests.json)",
)
args = parser.parse_args(argv)
if not args.config.exists():
parser.error(f"config file not found: {args.config}")
config = parse_config(args.config)
for row in format_rows(config):
print(row)
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))