Coverage for python/lsst/ctrl/mpexec/cli/script/update_graph_run.py: 43%

7 statements  

« prev     ^ index     » next       coverage.py v7.2.6, created at 2023-05-26 09:17 +0000

1# This file is part of ctrl_mpexec. 

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.pipe.base import QuantumGraph 

23from lsst.resources import ResourcePathExpression 

24 

25 

26def update_graph_run( 

27 input_graph: ResourcePathExpression, 

28 run: str, 

29 output_graph: ResourcePathExpression, 

30 metadata_run_key: str, 

31 update_graph_id: bool, 

32) -> None: 

33 """Update quantum graph with new output run name and dataset IDs and save 

34 updated graph to a file. 

35 

36 Parameters 

37 ---------- 

38 input_graph : `~lsst.resources.ResourcePathExpression` 

39 Location of a file with existing quantum graph. 

40 run : `str` 

41 Collection name, if collection exists it must be of ``RUN`` type. 

42 output_graph : `~lsst.resources.ResourcePathExpression` 

43 Location to store updated quantum graph. 

44 update_graph_id : `bool` 

45 If `True` then also update graph ID with a new unique value. 

46 """ 

47 qgraph = QuantumGraph.loadUri(input_graph) 

48 key = metadata_run_key if metadata_run_key else None 

49 qgraph.updateRun(run, metadata_key=key, update_graph_id=update_graph_id) 

50 qgraph.saveUri(output_graph)