28 lines
727 B
Python
28 lines
727 B
Python
|
|
import sys
|
|
import json
|
|
from collections import defaultdict
|
|
|
|
|
|
def main():
|
|
output_refs = sys.argv[1:]
|
|
assert len(output_refs) > 0, "Need at least 1 ref to lookup"
|
|
|
|
result = defaultdict(list)
|
|
|
|
# Partition output prefix makes it obvious which job should fulfill
|
|
for ref in output_refs:
|
|
print(ref, file=sys.stderr)
|
|
body, tail = ref.rsplit("/", 1)
|
|
if "generated_number" in body:
|
|
result["//:generate_number_job"].append(ref)
|
|
elif "sum" in body:
|
|
result["//:sum_job"].append(ref)
|
|
else:
|
|
raise ValueError(f"No job found for ref `{ref}`")
|
|
|
|
print(json.dumps({k: v for k, v in result.items() if v}))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|