lsst-pipe-base 29.2025.2800__py3-none-any.whl → 29.2025.3000__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.
@@ -45,6 +45,7 @@ __all__ = [
45
45
  import dataclasses
46
46
  import itertools
47
47
  import string
48
+ import uuid
48
49
  import warnings
49
50
  from collections import UserDict, defaultdict
50
51
  from collections.abc import Collection, Generator, Iterable, Iterator, Mapping, Sequence, Set
@@ -1271,6 +1272,52 @@ class QuantaAdjuster:
1271
1272
  for edge in self._task_node.iter_all_inputs()
1272
1273
  }
1273
1274
 
1275
+ def get_prerequisite_inputs(
1276
+ self,
1277
+ quantum_data_id: DataCoordinate,
1278
+ ) -> dict[str, dict[uuid.UUID, DataCoordinate]]:
1279
+ """Return the data IDs of all prerequisite inputs to a quantum.
1280
+
1281
+ Parameters
1282
+ ----------
1283
+ quantum_data_id : `~lsst.daf.butler.DataCoordinate`
1284
+ Data ID of the quantum to get the inputs of.
1285
+
1286
+ Returns
1287
+ -------
1288
+ inputs : `dict` [ `str`, \
1289
+ `dict` [ `uuid.UUID`, `~lsst.daf.butler.DataCoordinate` ] ]
1290
+ Dataset IDs and and data IDs of prerequisite inputs, keyed by the
1291
+ connection name (the internal task name, not the dataset type
1292
+ name). This only contains prerequisite inputs, not init-inputs or
1293
+ regular inputs.
1294
+
1295
+ Notes
1296
+ -----
1297
+ If two connections have the same dataset type, the current
1298
+ implementation assumes the set of datasets is the same for the two
1299
+ connections. This limitation may be removed in the future.
1300
+
1301
+ Unlike regular inputs, prerequisite inputs are not looked up from input
1302
+ collections or indexed by data ID. Instead, they are uniquely
1303
+ identified by dataset UUID and reused directly between quanta.
1304
+ """
1305
+ from .quantum_graph_skeleton import PrerequisiteDatasetKey, QuantumKey
1306
+
1307
+ by_dataset_type_name: defaultdict[str, dict[uuid.UUID, DataCoordinate]] = defaultdict(dict)
1308
+ quantum_key = QuantumKey(self._task_node.label, quantum_data_id.required_values)
1309
+
1310
+ for dataset_key in self._skeleton.iter_inputs_of(quantum_key):
1311
+ if not isinstance(dataset_key, PrerequisiteDatasetKey):
1312
+ continue
1313
+ by_dataset_type_name[dataset_key.parent_dataset_type_name][
1314
+ uuid.UUID(bytes=dataset_key.dataset_id_bytes)
1315
+ ] = self._skeleton.get_data_id(dataset_key)
1316
+ return {
1317
+ edge.connection_name: by_dataset_type_name[edge.parent_dataset_type_name]
1318
+ for edge in self._task_node.iter_all_inputs()
1319
+ }
1320
+
1274
1321
  def get_outputs(self, quantum_data_id: DataCoordinate) -> dict[str, list[DataCoordinate]]:
1275
1322
  """Return the data IDs of all regular outputs to a quantum.
1276
1323
 
@@ -1340,6 +1387,45 @@ class QuantaAdjuster:
1340
1387
  )
1341
1388
  self._skeleton.add_input_edge(quantum_key, dataset_key)
1342
1389
 
1390
+ def add_prerequisite_input(
1391
+ self, quantum_data_id: DataCoordinate, connection_name: str, dataset_uuid: uuid.UUID
1392
+ ) -> None:
1393
+ """Add a new prerequisite input to a quantum.
1394
+
1395
+ Parameters
1396
+ ----------
1397
+ quantum_data_id : `~lsst.daf.butler.DataCoordinate`
1398
+ Data ID of the quantum to add an input to.
1399
+ connection_name : `str`
1400
+ Name of the connection (the task-internal name, not the butler
1401
+ dataset type name).
1402
+ dataset_uuid : `uuid.UUID`
1403
+ UUID of the prerequisite input dataset. Must already exist in the
1404
+ graph as an input to a different quantum of this task, and must be
1405
+ a prerequisite input, not a regular input or init-input.
1406
+
1407
+ Notes
1408
+ -----
1409
+ If two connections have the same dataset type, the current
1410
+ implementation assumes the set of datasets is the same for the two
1411
+ connections. This limitation may be removed in the future.
1412
+
1413
+ Unlike regular inputs, prerequisite inputs are not looked up from input
1414
+ collections or indexed by data ID. Instead, they are uniquely
1415
+ identified by dataset UUID and reused directly between quanta.
1416
+ """
1417
+ from .quantum_graph_skeleton import PrerequisiteDatasetKey, QuantumKey
1418
+
1419
+ quantum_key = QuantumKey(self._task_node.label, quantum_data_id.required_values)
1420
+ read_edge = self._task_node.prerequisite_inputs[connection_name]
1421
+ dataset_key = PrerequisiteDatasetKey(read_edge.parent_dataset_type_name, dataset_uuid.bytes)
1422
+ if dataset_key not in self._skeleton:
1423
+ raise LookupError(
1424
+ f"Prerequisite Dataset {read_edge.parent_dataset_type_name}@{dataset_uuid} "
1425
+ "is not already in the graph."
1426
+ )
1427
+ self._skeleton.add_input_edge(quantum_key, dataset_key)
1428
+
1343
1429
  def move_output(
1344
1430
  self, quantum_data_id: DataCoordinate, connection_name: str, dataset_data_id: DataCoordinate
1345
1431
  ) -> None:
@@ -353,6 +353,8 @@ class PrerequisiteFinder:
353
353
  where=" AND ".join(where_terms),
354
354
  bind=bind,
355
355
  with_dimension_records=True,
356
+ limit=None,
357
+ explain=False,
356
358
  )
357
359
  except MissingDatasetTypeError:
358
360
  return []
@@ -383,6 +385,8 @@ class PrerequisiteFinder:
383
385
  collections=input_collections,
384
386
  data_id=data_id,
385
387
  with_dimension_records=True,
388
+ limit=None,
389
+ explain=False,
386
390
  )
387
391
  except MissingDatasetTypeError:
388
392
  return []
@@ -29,8 +29,7 @@ __all__ = ["transfer_from_graph"]
29
29
 
30
30
  import math
31
31
 
32
- from lsst.daf.butler import Butler, CollectionType, QuantumBackedButler, Registry
33
- from lsst.daf.butler.registry import MissingCollectionError
32
+ from lsst.daf.butler import Butler, CollectionType, MissingCollectionError, QuantumBackedButler
34
33
  from lsst.pipe.base import QuantumGraph
35
34
  from lsst.utils.iteration import chunk_iterable
36
35
  from lsst.utils.logging import getLogger
@@ -124,45 +123,55 @@ def transfer_from_graph(
124
123
  )
125
124
  count += len(transferred)
126
125
 
127
- # If anything was transferred then update output chain definition if asked.
128
- if count > 0 and update_output_chain and (metadata := qgraph.metadata) is not None:
126
+ # If asked to do so, update output chain definition.
127
+ if update_output_chain and (metadata := qgraph.metadata) is not None:
129
128
  # These are defined in CmdLineFwk.
130
129
  output_run = metadata.get("output_run")
131
130
  output = metadata.get("output")
132
131
  input = metadata.get("input")
133
132
  if output_run is not None and output is not None:
134
- _update_chain(dest_butler.registry, output, output_run, input)
133
+ _update_chain(dest_butler, output, output_run, input)
135
134
 
136
135
  return count
137
136
 
138
137
 
139
- def _update_chain(registry: Registry, output_chain: str, output_run: str, inputs: list[str] | None) -> None:
138
+ def _update_chain(butler: Butler, output_chain: str, output_run: str, inputs: list[str] | None) -> None:
140
139
  """Update chain definition if it exists to include run as the first item
141
140
  in a chain. If it does not exist then create it to include all inputs and
142
141
  output.
142
+
143
+ Parameters
144
+ ----------
145
+ butler : `lsst.daf.butler.Butler`
146
+ Butler where to update the collection chain.
147
+ output_chain : `str`
148
+ Name of the output CHAINED collection.
149
+ output_run : `str`
150
+ Name of the output RUN collection.
151
+ inputs : `list` [`str`] | None
152
+ All the input collections to be included in the chain if the
153
+ chain is created.
143
154
  """
155
+ # Do not need to update chain if output_run does not already exist.
144
156
  try:
145
- # If output_chain is not a chain the exception will be raised.
146
- chain_definition = list(registry.getCollectionChain(output_chain))
157
+ _ = butler.collections.get_info(output_run)
147
158
  except MissingCollectionError:
148
- # We have to create chained collection to include inputs and output run
149
- # (this reproduces logic in CmdLineFwk).
150
- registry.registerCollection(output_chain, type=CollectionType.CHAINED)
151
- chain_definition = list(registry.queryCollections(inputs, flattenChains=True)) if inputs else []
152
- chain_definition = [output_run] + [run for run in chain_definition if run != output_run]
153
- registry.setCollectionChain(output_chain, chain_definition)
154
- else:
155
- # If run is in the chain but not the first item then remove it, will
156
- # re-insert at front below.
157
- try:
158
- index = chain_definition.index(output_run)
159
- if index == 0:
160
- # It is already at the top.
161
- return
162
- else:
163
- del chain_definition[index]
164
- except ValueError:
165
- pass
166
-
167
- chain_definition.insert(0, output_run)
168
- registry.setCollectionChain(output_chain, chain_definition)
159
+ _LOG.verbose(
160
+ "Output RUN collection (%s) does not exist. Skipping updating the output chain.",
161
+ output_run,
162
+ )
163
+ return
164
+
165
+ # Make chain collection if doesn't exist before calling prepend_chain.
166
+ created_now = butler.collections.register(output_chain, CollectionType.CHAINED)
167
+ if created_now:
168
+ _LOG.verbose("Registered chain collection: %s", output_chain)
169
+ if inputs:
170
+ # Add input collections to chain collection just made. Using
171
+ # extend instead of prepend in case of race condition where another
172
+ # execution adds a run before this adds the inputs to the chain.
173
+ butler.collections.extend_chain(output_chain, inputs)
174
+ _LOG.verbose(
175
+ "Prepending output chain collection (%s) with output RUN collection (%s)", output_chain, output_run
176
+ )
177
+ butler.collections.prepend_chain(output_chain, output_run)
lsst/pipe/base/version.py CHANGED
@@ -1,2 +1,2 @@
1
1
  __all__ = ["__version__"]
2
- __version__ = "29.2025.2800"
2
+ __version__ = "29.2025.3000"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lsst-pipe-base
3
- Version: 29.2025.2800
3
+ Version: 29.2025.3000
4
4
  Summary: Pipeline infrastructure for the Rubin Science Pipelines.
5
5
  Author-email: Rubin Observatory Data Management <dm-admin@lists.lsst.org>
6
6
  License: BSD 3-Clause License
@@ -14,7 +14,7 @@ lsst/pipe/base/caching_limited_butler.py,sha256=u1uJYzCE7OxW8MW8Xv2LDB9-Nuj-Ao8l
14
14
  lsst/pipe/base/config.py,sha256=yNipVEc6awwhU_O9I01g20OnvQrs28dAwkXuI1hrlYE,11982
15
15
  lsst/pipe/base/configOverrides.py,sha256=B0An8EaX76VzWnC5dJxvyZ2AhVzawMtq7qlE9ma5lkc,14661
16
16
  lsst/pipe/base/connectionTypes.py,sha256=5QbyL7MAikohjXimXbmtPWryjLCZZXlS_vPzIWy5mzI,16708
17
- lsst/pipe/base/connections.py,sha256=248r_HT3mNDPrJzTviq3dp3zGKdfUchSPWZRupKAkV0,62795
17
+ lsst/pipe/base/connections.py,sha256=_tr_9RWs-LWetDW1tJX3ZROE5ZqvlLdIRStnz_11J5U,66707
18
18
  lsst/pipe/base/dot_tools.py,sha256=o_bDp9vW-4PelE7kWodH6pWVIRuyGlTRFv-kR_YKfLo,13824
19
19
  lsst/pipe/base/executionButlerBuilder.py,sha256=-vv-1aGm06RM4fJECjvJL0ZXHrwth7Hjt0jIfkKYY18,21254
20
20
  lsst/pipe/base/execution_reports.py,sha256=jYtWCD4PkEAeVUpKIxuiJJVgsCm7qiwCorWVgNHkVgU,17270
@@ -22,7 +22,7 @@ lsst/pipe/base/mermaid_tools.py,sha256=b_15oqCcxSom4ecMTDX8tfEtxe8W-juPVL65HOMyw
22
22
  lsst/pipe/base/pipeline.py,sha256=FVaiLhgw9Pzo-nzXKS0dLNafegP0AMZKLtPlSvOSkRU,37563
23
23
  lsst/pipe/base/pipelineIR.py,sha256=DDOAYHnMP-iw021RDMYsZnvb21tWumLjYqO5d38q_Zk,44300
24
24
  lsst/pipe/base/pipelineTask.py,sha256=K3GdjJLvy8A7I-jzQiERQZaYF7mC1LM3iB5TmUtbOCI,8394
25
- lsst/pipe/base/prerequisite_helpers.py,sha256=WxfIGkF0Wlucp9mE3Wp3E6K2M6d66O0oZrWecRqn5CI,28312
25
+ lsst/pipe/base/prerequisite_helpers.py,sha256=bmiebQ4veSrypZgAXjmCBFfj8fUtPW9eRQaVShhxdBQ,28446
26
26
  lsst/pipe/base/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  lsst/pipe/base/quantum_graph_builder.py,sha256=ugTOV5Qe6iWlaX9Zm1HoNWfnFFhohSmIrSFkCFUVOZM,54808
28
28
  lsst/pipe/base/quantum_graph_skeleton.py,sha256=iBSVCAV1OznYd70Lg4bLn0nMqjW5m9-kH5eecPn8DYw,24964
@@ -32,7 +32,7 @@ lsst/pipe/base/task.py,sha256=XHBd-7m1a4-6LgobBYA1DgY4H7EV-_RWKfxbhZbMmD4,15145
32
32
  lsst/pipe/base/taskFactory.py,sha256=4GhN2DozPM8suBYIvoKN4E6VP0I3mYZHBjCUO5JcCGk,2901
33
33
  lsst/pipe/base/testUtils.py,sha256=lSBKMhoKflbi8JkMNYfEqqHNl-rtFI8UYT3QneDYpLo,18477
34
34
  lsst/pipe/base/utils.py,sha256=JmEt3l0xrh9uayKrSXuQEq12aXOhDr2YXmbYduaxCko,1940
35
- lsst/pipe/base/version.py,sha256=zkbtcIsz6tbu7rmamcut51DoG62vyYwam95urGw5Lis,55
35
+ lsst/pipe/base/version.py,sha256=GKnpddvvmGJ8yPsnT--mhT32jeA31BaGZsJcw6cTK7k,55
36
36
  lsst/pipe/base/cli/__init__.py,sha256=861tXIAW7SqtqNUYkjbeEdfg8lDswXsjJQca0gVCFz4,54
37
37
  lsst/pipe/base/cli/_get_cli_subcommands.py,sha256=g_af64klRybBGKAg7fmBSZBdw2LYBAsFON_yQIMZON0,1289
38
38
  lsst/pipe/base/cli/cmd/__init__.py,sha256=BGicstnryQ48rYcNRh4fa6Vy63ZIlZ_pPAEa17jhkwY,1519
@@ -74,7 +74,7 @@ lsst/pipe/base/pipeline_graph/visualization/_status_annotator.py,sha256=dp7PXl9C
74
74
  lsst/pipe/base/script/__init__.py,sha256=cLEXE7aq5UZ0juL_ScmRw0weFgp4tDgwEX_ts-NEYic,1522
75
75
  lsst/pipe/base/script/register_instrument.py,sha256=TRC2r2tSoYBNWNVQya01ELxAtGH8WVk9Ya-uNgCIL5U,2426
76
76
  lsst/pipe/base/script/retrieve_artifacts_for_quanta.py,sha256=pYI0wNl5PU8ImgzWfGEDrRz3PSKSg2szWLEIVKdm7Og,3939
77
- lsst/pipe/base/script/transfer_from_graph.py,sha256=WMpmzaN8hdW4FoZPNL6LRiPW9gvxf9mw20Z1i-KCkWI,6740
77
+ lsst/pipe/base/script/transfer_from_graph.py,sha256=_7zuKf6NdeIzXafkOAFwdkx2zM1H-2uXJSi676WaSdM,6954
78
78
  lsst/pipe/base/script/utils.py,sha256=zNqpHG3kXA8OaNXnwYIo0Hu_LCie1qoBAARAME3WEjs,3739
79
79
  lsst/pipe/base/script/zip_from_graph.py,sha256=rbH_5Jk7Yc-YFD3X4mbDE4Vzddtu5y90Z77wha94mdM,3228
80
80
  lsst/pipe/base/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -86,13 +86,13 @@ lsst/pipe/base/tests/mocks/__init__.py,sha256=NrIJYDeYgR3HsOJXBEXi8EXDhhV7iw7dgw
86
86
  lsst/pipe/base/tests/mocks/_data_id_match.py,sha256=v33QZhZm-srXZAXZ8NbNKGN-_ql4AzaArBUk1lxhyss,7474
87
87
  lsst/pipe/base/tests/mocks/_pipeline_task.py,sha256=fqaJ-tB7K3jxlfCvCSnVd_GNrz-JhX7FB914h7nHLXc,29366
88
88
  lsst/pipe/base/tests/mocks/_storage_class.py,sha256=gC0czHURMk7PWj8N6dLxnY5V4HWX5i8ukb5SZbgWKy8,25257
89
- lsst_pipe_base-29.2025.2800.dist-info/licenses/COPYRIGHT,sha256=kB3Z9_f6a6uFLGpEmNJT_n186CE65H6wHu4F6BNt_zA,368
90
- lsst_pipe_base-29.2025.2800.dist-info/licenses/LICENSE,sha256=pRExkS03v0MQW-neNfIcaSL6aiAnoLxYgtZoFzQ6zkM,232
91
- lsst_pipe_base-29.2025.2800.dist-info/licenses/bsd_license.txt,sha256=7MIcv8QRX9guUtqPSBDMPz2SnZ5swI-xZMqm_VDSfxY,1606
92
- lsst_pipe_base-29.2025.2800.dist-info/licenses/gpl-v3.0.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
93
- lsst_pipe_base-29.2025.2800.dist-info/METADATA,sha256=rpezbW4ETyiwGgw7ttMrlVru-eZA_KG-Xax1jGXA5lE,2195
94
- lsst_pipe_base-29.2025.2800.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
95
- lsst_pipe_base-29.2025.2800.dist-info/entry_points.txt,sha256=bnmUhJBsChxMdqST9VmFBYYKxLQoToOfqW1wjW7khjk,64
96
- lsst_pipe_base-29.2025.2800.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
97
- lsst_pipe_base-29.2025.2800.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
98
- lsst_pipe_base-29.2025.2800.dist-info/RECORD,,
89
+ lsst_pipe_base-29.2025.3000.dist-info/licenses/COPYRIGHT,sha256=kB3Z9_f6a6uFLGpEmNJT_n186CE65H6wHu4F6BNt_zA,368
90
+ lsst_pipe_base-29.2025.3000.dist-info/licenses/LICENSE,sha256=pRExkS03v0MQW-neNfIcaSL6aiAnoLxYgtZoFzQ6zkM,232
91
+ lsst_pipe_base-29.2025.3000.dist-info/licenses/bsd_license.txt,sha256=7MIcv8QRX9guUtqPSBDMPz2SnZ5swI-xZMqm_VDSfxY,1606
92
+ lsst_pipe_base-29.2025.3000.dist-info/licenses/gpl-v3.0.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
93
+ lsst_pipe_base-29.2025.3000.dist-info/METADATA,sha256=ErHeFechV8GyMQBh9Se8mLflvi9VDImXeOt5AAUhHt4,2195
94
+ lsst_pipe_base-29.2025.3000.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
95
+ lsst_pipe_base-29.2025.3000.dist-info/entry_points.txt,sha256=bnmUhJBsChxMdqST9VmFBYYKxLQoToOfqW1wjW7khjk,64
96
+ lsst_pipe_base-29.2025.3000.dist-info/top_level.txt,sha256=eUWiOuVVm9wwTrnAgiJT6tp6HQHXxIhj2QSZ7NYZH80,5
97
+ lsst_pipe_base-29.2025.3000.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
98
+ lsst_pipe_base-29.2025.3000.dist-info/RECORD,,