225d31587eeb9aca226158e346c8e9730777913c,perfkitbenchmarker/publisher.py,,RepublishJSONSamples,#Any#,763

Before Change


  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(","):
          // 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:
        logging.info("Exception processing sample %s", line)

After Change


  

  with open(path, "r") as file:
    samples = [json.loads(s) for s in file if s]
  for sample in samples:
    // 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()
  for publisher in publishers:
    publisher.PublishSamples(samples)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 6

Instances


Project Name: GoogleCloudPlatform/PerfKitBenchmarker
Commit Name: 225d31587eeb9aca226158e346c8e9730777913c
Time: 2017-02-24
Author: nlavine@google.com
File Name: perfkitbenchmarker/publisher.py
Class Name:
Method Name: RepublishJSONSamples


Project Name: commonsense/conceptnet5
Commit Name: db4b9f4d50af9e83733fc301c32e85cbe6d9c812
Time: 2014-02-25
Author: rob@luminoso.com
File Name: conceptnet5/builders/json_to_solr.py
Class Name:
Method Name: convert_to_solr


Project Name: biolab/orange3
Commit Name: a0d5162fb500d43f4be26fd402271fc888397464
Time: 2015-06-24
Author: anze.staric@gmail.com
File Name: Orange/tests/test_classification.py
Class Name: LearnerAccessibility
Method Name: test_all_models_work_after_unpickling


Project Name: bokeh/bokeh
Commit Name: 5ca53bb34ef70d9b05f9195d3090f320d7d2a73c
Time: 2017-07-19
Author: mattpap@gmail.com
File Name: bokeh/util/compiler.py
Class Name:
Method Name: bundle_models