Coverage for python/lsst/daf/butler/script/butlerImport.py: 45%
9 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-07 10:08 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-07 10:08 +0000
1# This file is part of daf_butler.
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/>.
21from __future__ import annotations
23from collections.abc import Iterable
24from typing import TextIO
26from .._butler import Butler
29def butlerImport(
30 repo: str,
31 directory: str | None,
32 export_file: str | TextIO | None,
33 transfer: str | None,
34 skip_dimensions: Iterable[str] | None,
35 reuse_ids: bool,
36) -> None:
37 """Import data into a butler repository.
39 Parameters
40 ----------
41 repo : `str`
42 URI to the location of the repo or URI to a config file describing the
43 repo and its location.
44 directory : `str`, or None
45 Directory containing dataset files. If `None`, all file paths must be
46 absolute.
47 export_file : `TextIO`, or None
48 Name for the file that contains database information associated with
49 the exported datasets. If this is not an absolute path, does not exist
50 in the current working directory, and `directory` is not `None`, it is
51 assumed to be in `directory`. Defaults to "export.{format}".
52 transfer : `str`, or None
53 The external data transfer type.
54 skip_dimensions : `list`, or `None`
55 Dimensions that should be skipped.
56 reuse_ids : `bool`
57 If `True` forces re-use of imported dataset IDs for integer IDs.
58 """
59 butler = Butler(repo, writeable=True)
61 if skip_dimensions is not None:
62 skip_dimensions = set(skip_dimensions)
64 butler.import_(
65 directory=directory,
66 filename=export_file,
67 transfer=transfer,
68 format="yaml",
69 skip_dimensions=skip_dimensions,
70 reuseIds=reuse_ids,
71 )