Coverage for python/lsst/verify/bin/lintmetrics.py: 28%

18 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-17 09:08 +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# (https://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 <https://www.gnu.org/licenses/>. 

21""" 

22Validate the contents of an LSST Verification Framework metrics package. 

23 

24A metrics package contains, minimally, two root directories: 

25 

261. metrics/ - contains one YAML file per LSST Science Pipelines package 

27 that define metrics measured by that package. 

28 

292. specs/ - contains sub-directories named after LSST Science Pipelines 

30 packages. Specifications are defined in YAML files within those 

31 sub-directories. 

32""" 

33 

34__all__ = ('main',) 

35 

36import argparse 

37 

38from lsst.verify import MetricSet, SpecificationSet 

39 

40 

41def build_argparser(): 

42 """Construct an argument parser for the ``lint_metrics.py`` script. 

43 

44 Returns 

45 ------- 

46 argparser : `argparse.ArgumentParser` 

47 The argument parser that defines the ``lint_metrics.py`` command-line 

48 interface. 

49 """ 

50 # Default to the ``verify_metrics`` EUPS package expressed as a URI so 

51 # that no direct EUPS path lookup is required here; MetricSet / 

52 # SpecificationSet resolve this via lsst.resources. 

53 default_metrics_package_dir = 'eups://verify_metrics/' 

54 

55 parser = argparse.ArgumentParser( 

56 description=__doc__, 

57 formatter_class=argparse.RawDescriptionHelpFormatter) 

58 parser.add_argument( 

59 "package_dir", 

60 default=default_metrics_package_dir, 

61 type=str, 

62 nargs='?', 

63 help="Resource path of the metrics package to be checked, " 

64 "default: %(default)s") 

65 return parser 

66 

67 

68def main(): 

69 """Main entrypoint for the ``lint_metrics.py`` script. 

70 """ 

71 args = build_argparser().parse_args() 

72 

73 print('Linting {}.'.format(args.package_dir)) 

74 

75 metric_repo = MetricSet.load_metrics_package(args.package_dir) 

76 print('Passed: metrics/') 

77 print('\tParsed {0:d} metric sets.'.format(len(metric_repo))) 

78 

79 spec_set = SpecificationSet.load_metrics_package(args.package_dir) 

80 print('Passed: specs/') 

81 print('\tParsed {0:d} specifications.'.format(len(spec_set))) 

82 

83 print("\nAll tests passed.")