Coverage for python / lsst / obs / base / script / ingestRaws.py: 15%
19 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-15 06:36 -0300
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-15 06:36 -0300
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 update_records=False,
40 skip_existing=False,
41):
42 """Ingest raw frames into the butler registry.
44 Parameters
45 ----------
46 repo : `str`
47 URI to the repository.
48 locations : `list` [`str`]
49 Files to ingest and directories to search for files that match
50 ``regex`` to ingest.
51 regex : `str`
52 Regex string used to find files in directories listed in locations.
53 output_run : `str`
54 The path to the location, the run, where datasets should be put.
55 fail_fast : `bool`
56 If True, stop ingest as soon as any problem is encountered with any
57 file. Otherwise problem files will be skipped and logged and a report
58 issued at completion.
59 config : `dict` [`str`, `str`] or `None`
60 Key-value pairs to apply as overrides to the ingest config.
61 config_file : `str` or `None`
62 Path to a config file that contains overrides to the ingest config.
63 transfer : `str` or None
64 The external data transfer type, by default "auto".
65 processes : `int`
66 Number of processes to use for ingest.
67 ingest_task : `str`
68 The fully qualified class name of the ingest task to use by default
69 lsst.obs.base.RawIngestTask.
70 track_file_attrs : `bool`, optional
71 Control whether file attributes such as the size or checksum should
72 be tracked by the datastore. Whether this parameter is honored
73 depends on the specific datastore implementation.
74 update_records : `bool`, optional
75 Control whether recalculated exposure definitions will be accepted or
76 not.
77 skip_existing : `bool`, optional
78 Control whether raws that are already in the Butler repo will be
79 skipped without error.
81 Raises
82 ------
83 Exception
84 Raised if operations on configuration object fail.
85 """
86 TaskClass = doImportType(ingest_task)
87 ingestConfig = TaskClass.ConfigClass()
88 ingestConfig.transfer = transfer
89 configOverrides = ConfigOverrides()
90 if config_file is not None:
91 configOverrides.addFileOverride(config_file)
92 if config is not None:
93 for name, value in config.items():
94 configOverrides.addValueOverride(name, value)
95 if fail_fast:
96 configOverrides.addValueOverride("failFast", True)
97 configOverrides.applyTo(ingestConfig)
98 with Butler.from_config(repo, writeable=True) as butler:
99 ingester = TaskClass(config=ingestConfig, butler=butler)
100 ingester.run(
101 locations,
102 run=output_run,
103 processes=processes,
104 file_filter=regex,
105 track_file_attrs=track_file_attrs,
106 update_exposure_records=update_records,
107 skip_existing_exposures=skip_existing,
108 )