lsst-ctrl-mpexec 29.2025.3100__py3-none-any.whl → 29.2025.3200__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,28 +25,31 @@
25
25
  # You should have received a copy of the GNU General Public License
26
26
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
27
27
 
28
- from types import SimpleNamespace
28
+ from __future__ import annotations
29
+
30
+ __all__ = ("build",)
29
31
 
30
32
  from lsst.daf.butler import Butler
33
+ from lsst.pipe.base import Pipeline
31
34
  from lsst.pipe.base.pipeline_graph import visualization
35
+ from lsst.resources import ResourcePathExpression
32
36
 
33
- from ... import CmdLineFwk
34
37
  from ..._pipeline_graph_factory import PipelineGraphFactory
38
+ from ...showInfo import ShowInfo
35
39
  from ..utils import _PipelineAction
36
40
 
37
41
 
38
- def build( # type: ignore
42
+ def build(
39
43
  *,
40
- order_pipeline,
41
- pipeline,
42
- pipeline_actions,
43
- pipeline_dot,
44
- pipeline_mermaid,
45
- save_pipeline,
46
- show,
47
- butler_config=None,
48
- select_tasks="",
49
- **kwargs,
44
+ pipeline: ResourcePathExpression | Pipeline,
45
+ pipeline_actions: list[_PipelineAction] | _PipelineAction,
46
+ pipeline_dot: str,
47
+ pipeline_mermaid: str,
48
+ save_pipeline: str,
49
+ show: ShowInfo,
50
+ butler_config: ResourcePathExpression | None = None,
51
+ select_tasks: str = "",
52
+ **kwargs: object,
50
53
  ) -> PipelineGraphFactory:
51
54
  """Implement the command line interface `pipetask build` subcommand.
52
55
 
@@ -60,12 +63,9 @@ def build( # type: ignore
60
63
 
61
64
  Parameters
62
65
  ----------
63
- order_pipeline : `bool`
64
- If true, order tasks in pipeline based on their data dependencies,
65
- ordering is performed as last step before saving or executing pipeline.
66
- pipeline : `str`
66
+ pipeline : `str` or `lsst.pipe.base.Pipeline`
67
67
  Path location of a pipeline definition file in YAML format.
68
- pipeline_actions : `list` [`PipelineAction`]] or `PipelineAction`
68
+ pipeline_actions : `list` [`PipelineAction`] or `PipelineAction`
69
69
  A list of pipeline actions in the order they should be executed.
70
70
  pipeline_dot : `str`
71
71
  Path location for storing GraphViz DOT representation of a pipeline.
@@ -87,7 +87,7 @@ def build( # type: ignore
87
87
  **kwargs
88
88
  Ignored; click commands may accept options for more than one script
89
89
  function and pass all the option kwargs to each of the script functions
90
- which ingore these unused kwargs.
90
+ which ignore these unused kwargs.
91
91
 
92
92
  Returns
93
93
  -------
@@ -105,25 +105,38 @@ def build( # type: ignore
105
105
  # `lsst.utils.iteration.iterable` because a namedtuple *is* iterable,
106
106
  # but we need a list of _PipelineAction.
107
107
  if isinstance(pipeline_actions, _PipelineAction):
108
- pipeline_actions = (pipeline_actions,)
109
-
110
- args = SimpleNamespace(
111
- pipeline=pipeline,
112
- pipeline_actions=pipeline_actions,
113
- pipeline_dot=pipeline_dot,
114
- pipeline_mermaid=pipeline_mermaid,
115
- save_pipeline=save_pipeline,
116
- )
117
-
118
- f = CmdLineFwk()
108
+ pipeline_actions = [pipeline_actions]
119
109
 
120
- # Will raise an exception if it fails to build the pipeline.
121
- pipeline = f.makePipeline(args)
122
-
123
- if butler_config is not None:
124
- butler = Butler.from_config(butler_config, writeable=False)
110
+ if pipeline:
111
+ if not isinstance(pipeline, Pipeline):
112
+ pipeline = Pipeline.from_uri(pipeline)
125
113
  else:
126
- butler = None
114
+ pipeline = Pipeline("anonymous")
115
+
116
+ # loop over all pipeline actions and apply them in order
117
+ for action in pipeline_actions:
118
+ match action.action:
119
+ case "add_instrument":
120
+ pipeline.addInstrument(action.value)
121
+ case "new_task":
122
+ pipeline.addTask(action.value, action.label)
123
+ case "delete_task":
124
+ pipeline.removeTask(action.label)
125
+ case "config":
126
+ # action value string is "field=value", split it at '='
127
+ field, _, value = action.value.partition("=")
128
+ pipeline.addConfigOverride(action.label, field, value)
129
+ case "configfile":
130
+ pipeline.addConfigFile(action.label, action.value)
131
+ case _:
132
+ raise ValueError(f"Unexpected pipeline action: {action.action}")
133
+
134
+ if save_pipeline:
135
+ pipeline.write_to_uri(save_pipeline)
136
+
137
+ butler: Butler | None = None
138
+ if butler_config:
139
+ butler = Butler.from_config(butler_config, writeable=False)
127
140
 
128
141
  pipeline_graph_factory = PipelineGraphFactory(pipeline, butler, select_tasks)
129
142
 
@@ -45,7 +45,6 @@ def qgraph( # type: ignore
45
45
  skip_existing_in,
46
46
  skip_existing,
47
47
  save_qgraph,
48
- save_single_quanta,
49
48
  qgraph_dot,
50
49
  qgraph_mermaid,
51
50
  butler_config,
@@ -58,10 +57,6 @@ def qgraph( # type: ignore
58
57
  data_query,
59
58
  data_id_table=(),
60
59
  show,
61
- save_execution_butler,
62
- clobber_execution_butler,
63
- target_datastore_root,
64
- transfer,
65
60
  clobber_outputs,
66
61
  dataset_query_constraint,
67
62
  rebase,
@@ -102,10 +97,6 @@ def qgraph( # type: ignore
102
97
  save_qgraph : `str` or `None`
103
98
  URI location for storing a serialized quantum graph definition as a
104
99
  pickle file.
105
- save_single_quanta : `str` or `None`
106
- Format string of URI locations for storing individual quantum graph
107
- definition (pickle files). The curly brace {} in the input string will
108
- be replaced by a quantum number.
109
100
  qgraph_dot : `str` or `None`
110
101
  Path location for storing GraphViz DOT representation of a quantum
111
102
  graph.
@@ -152,17 +143,6 @@ def qgraph( # type: ignore
152
143
  Paths to data ID tables to join in.
153
144
  show : `lsst.ctrl.mpexec.showInfo.ShowInfo`
154
145
  Descriptions of what to dump to stdout.
155
- save_execution_butler : `str` or `None`
156
- URI location for storing an execution Butler build from the
157
- QuantumGraph.
158
- clobber_execution_butler : `bool`
159
- It True overwrite existing execution butler files if present.
160
- target_datastore_root : `str` or `None`
161
- URI location for the execution butler's datastore.
162
- transfer : `str` or `None`
163
- Transfer mode for execution butler creation. This should be a
164
- ``transfer`` string recognized by
165
- :func:`lsst.resources.ResourcePath.transfer_from`.
166
146
  clobber_outputs : `bool`
167
147
  Remove outputs from previous execution of the same quantum before new
168
148
  execution. If ``skip_existing`` is also passed, then only failed
@@ -200,7 +180,6 @@ def qgraph( # type: ignore
200
180
  qgraph_node_id=qgraph_node_id,
201
181
  qgraph_datastore_records=qgraph_datastore_records,
202
182
  save_qgraph=save_qgraph,
203
- save_single_quanta=save_single_quanta,
204
183
  qgraph_dot=qgraph_dot,
205
184
  qgraph_mermaid=qgraph_mermaid,
206
185
  butler_config=butler_config,
@@ -214,10 +193,6 @@ def qgraph( # type: ignore
214
193
  data_id_table=data_id_table,
215
194
  skip_existing_in=skip_existing_in,
216
195
  skip_existing=skip_existing,
217
- execution_butler_location=save_execution_butler,
218
- clobber_execution_butler=clobber_execution_butler,
219
- target_datastore_root=target_datastore_root,
220
- transfer=transfer,
221
196
  clobber_outputs=clobber_outputs,
222
197
  dataset_query_constraint=dataset_query_constraint,
223
198
  rebase=rebase,