Coverage for python/lsst/obs/base/script/ingestRaws.py: 15%

19 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-17 02:49 -0700

1# This file is part of obs_base. 

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 

22from lsst.daf.butler import Butler 

23from lsst.pipe.base.configOverrides import ConfigOverrides 

24from lsst.utils import doImportType 

25 

26 

27def ingestRaws( 

28 repo, 

29 locations, 

30 regex, 

31 output_run, 

32 fail_fast=False, 

33 config=None, 

34 config_file=None, 

35 transfer="auto", 

36 processes=1, 

37 ingest_task="lsst.obs.base.RawIngestTask", 

38 track_file_attrs=True, 

39 update_records=False, 

40): 

41 """Ingest raw frames into the butler registry. 

42 

43 Parameters 

44 ---------- 

45 repo : `str` 

46 URI to the repository. 

47 locations : `list` [`str`] 

48 Files to ingest and directories to search for files that match 

49 ``regex`` to ingest. 

50 regex : `str` 

51 Regex string used to find files in directories listed in locations. 

52 output_run : `str` 

53 The path to the location, the run, where datasets should be put. 

54 fail_fast : `bool` 

55 If True, stop ingest as soon as any problem is encountered with any 

56 file. Otherwise problem files will be skipped and logged and a report 

57 issued at completion. 

58 config : `dict` [`str`, `str`] or `None` 

59 Key-value pairs to apply as overrides to the ingest config. 

60 config_file : `str` or `None` 

61 Path to a config file that contains overrides to the ingest config. 

62 transfer : `str` or None 

63 The external data transfer type, by default "auto". 

64 processes : `int` 

65 Number of processes to use for ingest. 

66 ingest_task : `str` 

67 The fully qualified class name of the ingest task to use by default 

68 lsst.obs.base.RawIngestTask. 

69 track_file_attrs : `bool`, optional 

70 Control whether file attributes such as the size or checksum should 

71 be tracked by the datastore. Whether this parameter is honored 

72 depends on the specific datastore implementation. 

73 update_records : `bool`, optional 

74 Control whether recalculated exposure definitions will be accepted or 

75 not. 

76 

77 Raises 

78 ------ 

79 Exception 

80 Raised if operations on configuration object fail. 

81 """ 

82 butler = Butler(repo, writeable=True) 

83 TaskClass = doImportType(ingest_task) 

84 ingestConfig = TaskClass.ConfigClass() 

85 ingestConfig.transfer = transfer 

86 configOverrides = ConfigOverrides() 

87 if config_file is not None: 

88 configOverrides.addFileOverride(config_file) 

89 if config is not None: 

90 for name, value in config.items(): 

91 configOverrides.addValueOverride(name, value) 

92 if fail_fast: 

93 configOverrides.addValueOverride("failFast", True) 

94 configOverrides.applyTo(ingestConfig) 

95 ingester = TaskClass(config=ingestConfig, butler=butler) 

96 ingester.run( 

97 locations, 

98 run=output_run, 

99 processes=processes, 

100 file_filter=regex, 

101 track_file_attrs=track_file_attrs, 

102 update_exposure_records=update_records, 

103 )