Coverage for python/lsst/obs/lsst/cli/cmd/commands.py: 97%

32 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-07 01:32 -0800

1# This file is part of obs_lsst. 

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

21import click 

22 

23from lsst.daf.butler.cli.opt import ( 

24 config_option, 

25 config_file_option, 

26 locations_argument, 

27 options_file_option, 

28 repo_argument, 

29 regex_option, 

30 run_option, 

31 transfer_option, 

32 register_dataset_types_option, 

33) 

34from lsst.pipe.base.cli.opt import instrument_argument 

35from lsst.daf.butler.cli.utils import ButlerCommand 

36from ... import script 

37from ..._ingest_guider import DEFAULT_GUIDER_REGEX 

38 

39defaultRegex = r"Photodiode_Readings.*txt$|photodiode.ecsv$" 

40 

41 

42@click.command(cls=ButlerCommand, short_help="Ingest photodiode data.") 

43@repo_argument(required=True) 

44@instrument_argument(required=True, help="INSTRUMENT is the name of the instrument to use.") 

45@locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.", 

46 required=True) 

47@regex_option(default=defaultRegex, 

48 help="Regex string used to find photodiode data in directories listed in LOCATIONS. " 

49 f"Defaults to {defaultRegex}") 

50@config_option(metavar="TEXT=TEXT", multiple=True) 

51@config_file_option(type=click.Path(exists=True, writable=False, file_okay=True, dir_okay=False)) 

52@run_option(required=False) 

53@transfer_option(default="copy") 

54@click.option( 

55 "--track-file-attrs/--no-track-file-attrs", 

56 default=True, 

57 help="Indicate to the datastore whether file attributes such as file size" 

58 " or checksum should be tracked or not. Whether this parameter is honored" 

59 " depends on the specific datastore implementation.", 

60) 

61@options_file_option() 

62def ingest_photodiode(*args, **kwargs): 

63 """Ingest photodiode data from a directory into the butler registry.""" 

64 script.ingestPhotodiode(*args, **kwargs) 

65 

66 

67@click.command(cls=ButlerCommand, short_help="Ingest LSSTCam guider data.") 

68@repo_argument(required=True) 

69@locations_argument(help="LOCATIONS specifies files to ingest and/or locations to search for files.", 

70 required=True) 

71@regex_option(default=DEFAULT_GUIDER_REGEX, 

72 help="Regex string used to find photodiode data in directories listed in LOCATIONS. " 

73 f"Defaults to {DEFAULT_GUIDER_REGEX}") 

74@run_option( 

75 required=False, 

76 default=None, 

77 help="Run collection place these guider files. Default is to create collection based on instrument.", 

78) 

79@transfer_option(default="direct") 

80@click.option( 

81 "--track-file-attrs/--no-track-file-attrs", 

82 default=True, 

83 help="Indicate to the datastore whether file attributes such as file size" 

84 " or checksum should be tracked or not. Whether this parameter is honored" 

85 " depends on the specific datastore implementation.", 

86) 

87@click.option( 

88 "--fail-fast/--no-fail-fast", 

89 default=False, 

90 is_flag=True, 

91 help=( 

92 "Stop ingest as soon as any problem is encountered with any file. " 

93 "Otherwise problem files will be skipped and logged and a report issued at completion." 

94 ) 

95) 

96@register_dataset_types_option() 

97@options_file_option() 

98def ingest_guider(*args, **kwargs): 

99 """Ingest LSSTCam guider data into a butler repository.""" 

100 script.ingest_guider_simple(*args, **kwargs)