Coverage for python/lsst/verify/bin/print_metricvalues.py: 27%
24 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-13 01:34 -0700
« prev ^ index » next coverage.py v7.2.7, created at 2023-06-13 01:34 -0700
1# This file is part of verify.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22"""Summarize measured metric values in one butler repo, or difference values
23between two repos.
25This tool is built on the `~lsst.verify.extract_metricvalues` module, which
26can be used to investigate metrics within e.g. a notebook environment.
27"""
28__all__ = ["main", "build_argparser"]
30import argparse
32import lsst.daf.butler
33from .. import extract_metricvalues
36def build_argparser():
37 """Return an ArgumentParser for this script.
38 """
39 parser = argparse.ArgumentParser(
40 description=__doc__,
41 formatter_class=argparse.RawDescriptionHelpFormatter,
42 epilog='More information is available at https://pipelines.lsst.io.')
43 parser.add_argument("repo", type=str,
44 help="Path to butler repo to load metrics from.")
45 parser.add_argument("collection", type=str,
46 help="Collection in REPO to load from.")
47 parser.add_argument("repo2", type=str, nargs="?", default=None,
48 help="Path to butler repo to load metrics from, to difference with REPO.")
49 parser.add_argument("collection2", type=str, nargs="?", default=None,
50 help="Collection in REPO2 to load from, otherwise use COLLECTION.")
51 parser.add_argument("--kind", choices=["value", "timing", "memory"], default="value",
52 help="What kind of metrics to load (default='value')."
53 "Not supported when printing metric differences.")
54 parser.add_argument("-v", "--verbose", action="store_true",
55 help="Print extra information when loading metric values or handling errors.")
56 parser.add_argument("--data-id-keys", nargs="+", default=None,
57 help="Only print these dataId keys in the output;"
58 "for example, `--data-id-keys detector visit`.")
59 return parser
62def main():
63 args = build_argparser().parse_args()
65 butler = lsst.daf.butler.Butler(args.repo, collections=args.collection)
67 if args.repo2 is None:
68 extract_metricvalues.print_metrics(butler,
69 args.kind,
70 data_id_keys=args.data_id_keys,
71 verbose=args.verbose)
72 else:
73 collection2 = args.collection2 if args.collection2 is not None else args.collection
74 butler2 = lsst.daf.butler.Butler(args.repo2, collections=collection2)
75 print(f"Showing difference of {args.repo2}#{collection2} - {args.repo}#{args.collection}")
76 extract_metricvalues.print_diff_metrics(butler,
77 butler2,
78 data_id_keys=args.data_id_keys,
79 verbose=args.verbose)