Coverage for python/lsst/verify/bin/lintmetrics.py: 30%
23 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-22 01:34 -0700
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-22 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# (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.
24A metrics package contains, minimally, two root directories:
261. metrics/ - contains one YAML file per LSST Science Pipelines package
27 that define metrics measured by that package.
292. specs/ - contains sub-directories named after LSST Science Pipelines
30 packages. Specifications are defined in YAML files within those
31 sub-directories.
32"""
34__all__ = ('main',)
36import argparse
38from lsst.utils import getPackageDir
39from lsst.verify import MetricSet, SpecificationSet
42def build_argparser():
43 """Construct an argument parser for the ``lint_metrics.py`` script.
45 Returns
46 -------
47 argparser : `argparse.ArgumentParser`
48 The argument parser that defines the ``lint_metrics.py`` command-line
49 interface.
50 """
51 try:
52 default_metrics_package_dir = getPackageDir('verify_metrics')
53 except LookupError:
54 default_metrics_package_dir = None
56 parser = argparse.ArgumentParser(
57 description=__doc__,
58 formatter_class=argparse.RawDescriptionHelpFormatter)
59 parser.add_argument(
60 "package_dir",
61 default=default_metrics_package_dir,
62 type=str,
63 nargs='?',
64 help="Filepath of the metrics package to be checked.")
65 return parser
68def main():
69 """Main entrypoint for the ``lint_metrics.py`` script.
70 """
71 args = build_argparser().parse_args()
73 print('Linting {}.'.format(args.package_dir))
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)))
79 spec_set = SpecificationSet.load_metrics_package(args.package_dir)
80 print('Passed: specs/')
81 print('\tParsed {0:d} specifications.'.format(len(spec_set)))
83 print("\nAll tests passed.")