Coverage for python / lsst / daf / butler / script / ingest_zip.py: 67%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-28 08:36 +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 software is dual licensed under the GNU General Public License and also 

10# under a 3-clause BSD license. Recipients may choose which of these licenses 

11# to use; please see the files gpl-3.0.txt and/or bsd_license.txt, 

12# respectively. If you choose the GPL option then the following text applies 

13# (but note that there is still no warranty even if you opt for BSD instead): 

14# 

15# This program is free software: you can redistribute it and/or modify 

16# it under the terms of the GNU General Public License as published by 

17# the Free Software Foundation, either version 3 of the License, or 

18# (at your option) any later version. 

19# 

20# This program is distributed in the hope that it will be useful, 

21# but WITHOUT ANY WARRANTY; without even the implied warranty of 

22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

23# GNU General Public License for more details. 

24# 

25# You should have received a copy of the GNU General Public License 

26# along with this program. If not, see <http://www.gnu.org/licenses/>. 

27from __future__ import annotations 

28 

29__all__ = ["ingest_zip"] 

30 

31from .._butler import Butler 

32 

33 

34def ingest_zip( 

35 repo: str, 

36 zip: str, 

37 transfer: str = "auto", 

38 transfer_dimensions: bool = False, 

39 dry_run: bool = False, 

40) -> None: 

41 """Ingest a Zip file into the given butler. 

42 

43 Parameters 

44 ---------- 

45 repo : `str` 

46 URI string of the Butler repo to use. 

47 zip : `str` 

48 URI string of the location of the Zip file. 

49 transfer : `str`, optional 

50 Transfer mode to use for ingest. 

51 transfer_dimensions : `bool` 

52 Indicate whether dimensions should be transferred along with 

53 datasets. If `True` the dimension records will be retrieved from the 

54 zip and an attempt will be made to register any missing records. 

55 If `False` assumes that all relevant records are already known to the 

56 receiving Butler. It can be more efficient to disable this if it is 

57 known that all dimensions exist. 

58 dry_run : `bool`, optional 

59 If `True` no transfers are done but the number of transfers that 

60 would be done is reported. 

61 """ 

62 with Butler.from_config(repo, writeable=True) as butler: 

63 butler.ingest_zip(zip, transfer=transfer, transfer_dimensions=transfer_dimensions, dry_run=dry_run)