with open(path, "r") as file:
for line in file:
try:
raw_dict = json.loads(line)
labels = raw_dict.pop("labels")
metadata = dict()
// labels is a comma-seprated list of key, value pairs
for pair in labels.split(","):
After Change
// Chop "|" at the beginning and end of labels and split labels by "|,|"
fields = sample.pop("labels")[1:-1].split("|,|")
// Turn the fields into [[key, value], ...]
key_values = [field.split(":", 1) for field in fields]
sample["metadata"] = {k: v for k, v in key_values}
// We can"t use a SampleCollector because SampleCollector.AddSamples depends on
// having a benchmark and a benchmark_spec.
publishers = SampleCollector._PublishersFromFlags()