Coverage for python/lsst/obs/base/script/ingestRaws.py: 15%
19 statements
« prev ^ index » next coverage.py v6.4.4, created at 2022-08-19 12:24 -0700
« prev ^ index » next coverage.py v6.4.4, created at 2022-08-19 12:24 -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/>.
22from lsst.daf.butler import Butler
23from lsst.pipe.base.configOverrides import ConfigOverrides
24from lsst.utils import doImportType
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):
40 """Ingests raw frames into the butler registry
42 Parameters
43 ----------
44 repo : `str`
45 URI to the repository.
46 locations : `list` [`str`]
47 Files to ingest and directories to search for files that match
48 ``regex`` to ingest.
49 regex : `str`
50 Regex string used to find files in directories listed in locations.
51 output_run : `str`
52 The path to the location, the run, where datasets should be put.
53 fail_fast : `bool`
54 If True, stop ingest as soon as any problem is encountered with any
55 file. Otherwise problem files will be skipped and logged and a report
56 issued at completion.
57 config : `dict` [`str`, `str`] or `None`
58 Key-value pairs to apply as overrides to the ingest config.
59 config_file : `str` or `None`
60 Path to a config file that contains overrides to the ingest config.
61 transfer : `str` or None
62 The external data transfer type, by default "auto".
63 processess : `int`
64 Number of processes to use for ingest.
65 ingest_task : `str`
66 The fully qualified class name of the ingest task to use by default
67 lsst.obs.base.RawIngestTask.
68 track_file_attrs : `bool`, optional
69 Control whether file attributes such as the size or checksum should
70 be tracked by the datastore. Whether this parameter is honored
71 depends on the specific datastore implentation.
73 Raises
74 ------
75 Exception
76 Raised if operations on configuration object fail.
77 """
78 butler = Butler(repo, writeable=True)
79 TaskClass = doImportType(ingest_task)
80 ingestConfig = TaskClass.ConfigClass()
81 ingestConfig.transfer = transfer
82 configOverrides = ConfigOverrides()
83 if config_file is not None:
84 configOverrides.addFileOverride(config_file)
85 if config is not None:
86 for name, value in config.items():
87 configOverrides.addValueOverride(name, value)
88 if fail_fast:
89 configOverrides.addValueOverride("failFast", True)
90 configOverrides.applyTo(ingestConfig)
91 ingester = TaskClass(config=ingestConfig, butler=butler)
92 ingester.run(
93 locations, run=output_run, processes=processes, file_filter=regex, track_file_attrs=track_file_attrs
94 )