Coverage for python/lsst/verify/bin/print_metricvalues.py: 27%

24 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-08-19 19:10 +0000

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/>. 

21 

22"""Summarize measured metric values in one butler repo, or difference values 

23between two repos. 

24""" 

25__all__ = ["main", "build_argparser"] 

26 

27import argparse 

28 

29import lsst.daf.butler 

30from .. import extract_metricvalues 

31 

32 

33def build_argparser(): 

34 """Return an ArgumentParser for this script. 

35 """ 

36 parser = argparse.ArgumentParser( 

37 description=__doc__, 

38 formatter_class=argparse.RawDescriptionHelpFormatter, 

39 epilog='More information is available at https://pipelines.lsst.io.') 

40 parser.add_argument("repo", type=str, 

41 help="Path to butler repo to load metrics from.") 

42 parser.add_argument("collection", type=str, 

43 help="Collection in REPO to load from.") 

44 parser.add_argument("repo2", type=str, nargs="?", default=None, 

45 help="Path to butler repo to load metrics from, to difference with REPO.") 

46 parser.add_argument("collection2", type=str, nargs="?", default=None, 

47 help="Collection in REPO2 to load from, otherwise use COLLECTION.") 

48 parser.add_argument("--kind", choices=["value", "timing", "memory"], default="value", 

49 help="What kind of metrics to load (default='value')." 

50 "Not supported when printing metric differences.") 

51 parser.add_argument("-v", "--verbose", action="store_true", 

52 help="Print extra information when loading metric values or handling errors.") 

53 parser.add_argument("--data-id-keys", nargs="+", default=None, 

54 help="Only print these dataId keys in the output;" 

55 "for example, `--data-id-keys detector visit`.") 

56 return parser 

57 

58 

59def main(): 

60 args = build_argparser().parse_args() 

61 

62 butler = lsst.daf.butler.Butler(args.repo, collections=args.collection) 

63 

64 if args.repo2 is None: 

65 extract_metricvalues.print_metrics(butler, 

66 args.kind, 

67 data_id_keys=args.data_id_keys, 

68 verbose=args.verbose) 

69 else: 

70 collection2 = args.collection2 if args.collection2 is not None else args.collection 

71 butler2 = lsst.daf.butler.Butler(args.repo2, collections=collection2) 

72 print(f"Showing difference of {args.repo2}#{collection2} - {args.repo}#{args.collection}") 

73 extract_metricvalues.print_diff_metrics(butler, 

74 butler2, 

75 data_id_keys=args.data_id_keys, 

76 verbose=args.verbose)