Skip to content

Commit

Permalink
Merge branch 'tickets/DM-28958'
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKrughoff committed Feb 25, 2021
2 parents 3e22ff4 + f9ef4ae commit d90f2a7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions python/lsst/verify/bin/jobReporter.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import argparse
import json
import time

from lsst.verify import Job, MetricSet
from lsst.daf.butler import Butler
from lsst.daf.butler import Butler, FileTemplate


__all__ = ["main", "JobReporter", "build_argparser"]
Expand Down Expand Up @@ -50,11 +49,20 @@ def main(repository, collection, metrics_package, spec, dataset_name):
if len(jobs) == 0:
raise RuntimeError('Job reporter returned no jobs.')
for k, v in jobs.items():
filename = f"{metrics_package or 'all'}_{spec}_{k}_{time.time()}.json"
filename = f"{metrics_package or 'all'}_{spec}_{k}.verify.json"
with open(filename, 'w') as fh:
json.dump(v.json, fh, indent=2, sort_keys=True)


def make_key(ref):
names = sorted(list(ref.dataId.names))
names.append('run') # "run" must be in the template
key_tmpl = '_'.join(['{' + el + '}' for el in names])
file_tmpl = FileTemplate(key_tmpl)
key = file_tmpl.format(ref)
return key


class JobReporter:
"""A class for extracting metric values from a Gen 3 repository and
repackaging them as Job objects.
Expand Down Expand Up @@ -112,8 +120,7 @@ def run(self):

# queryDatasets guarantees ref.dataId.hasFull()
dataId = ref.dataId.full.byName()
# Sort values by key name
key = "_".join(str(id) for _, id in sorted(dataId.items()))
key = make_key(ref)

# For backward-compatibility with Gen 2 SQuaSH uploads
pfilt = dataId.get('physical_filter')
Expand Down

0 comments on commit d90f2a7

Please sign in to comment.