// labels is a comma-seprated list of key, value pairs
for pair in labels.split(","):
// Need to strip leading and trailing "|" from each pair
key, _, value = pair[1:-1].partition(":")
metadata[key] = value
raw_dict["metadata"] = metadata
samples.append(raw_dict)
except Exception as e:
After Change
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.