Files
TheRock/compiler/amd-llvm/llvm/utils/dtlto/validate.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

79 lines
1.9 KiB
Python

"""
DTLTO JSON Validator.
This script is used for DTLTO testing to check that the distributor has
been invoked correctly.
Usage:
python validate.py <json_file>
Arguments:
- <json_file> : JSON file describing the DTLTO jobs.
The script does the following:
1. Prints the supplied distributor arguments.
2. Loads the JSON file.
3. Pretty prints the JSON.
4. Validates the structure and required fields.
"""
import sys
import json
from pathlib import Path
def take(jvalue, jpath):
parts = jpath.split(".")
for part in parts[:-1]:
jvalue = jvalue[part]
return jvalue.pop(parts[-1], KeyError)
def validate(jdoc):
# Check the format of the JSON
assert type(take(jdoc, "common.linker_output")) is str
args = take(jdoc, "common.args")
assert type(args) is list
assert len(args) > 0
assert all(type(i) is str for i in args)
inputs = take(jdoc, "common.inputs")
assert type(inputs) is list
assert all(type(i) is str for i in inputs)
assert len(take(jdoc, "common")) == 0
jobs = take(jdoc, "jobs")
assert type(jobs) is list
for j in jobs:
assert type(j) is dict
for attr, min_size in (("args", 0), ("inputs", 2), ("outputs", 1)):
array = take(j, attr)
assert len(array) >= min_size
assert type(array) is list
assert all(type(a) is str for a in array)
assert len(j) == 0
assert len(jdoc) == 0
if __name__ == "__main__":
json_arg = Path(sys.argv[-1])
distributor_args = sys.argv[1:-1]
# Print the supplied distributor arguments.
print(f"{distributor_args=}")
# Load the DTLTO information from the input JSON file.
with json_arg.open() as f:
jdoc = json.load(f)
# Write the input JSON to stdout.
print(json.dumps(jdoc, indent=4))
# Check the format of the JSON.
validate(jdoc)