Skip to content

Commit

Permalink
Merge branch 'tickets/DM-43502'
Browse files Browse the repository at this point in the history
  • Loading branch information
kfindeisen committed Mar 26, 2024
2 parents e76f0e8 + 00e7216 commit cd87384
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 3 additions & 6 deletions python/activator/activator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
from .raw import (
get_prefix_from_snap,
is_path_consistent,
get_exp_id_from_oid,
get_group_id_from_oid,
)
from .visit import FannedOutVisit
Expand Down Expand Up @@ -307,9 +306,8 @@ def next_visit_handler() -> Tuple[str, int]:
expected_visit.detector,
)
if oid:
exp_id = get_exp_id_from_oid(oid)
_log.debug("Found exposure %r already present", exp_id)
mwi.ingest_image(oid)
_log.debug("Found object %s already present", oid)
exp_id = mwi.ingest_image(oid)
expid_set.add(exp_id)

_log.debug("Waiting for snaps...")
Expand All @@ -336,9 +334,8 @@ def next_visit_handler() -> Tuple[str, int]:
_log.debug("Received %r", oid)
group_id = get_group_id_from_oid(oid)
if group_id == expected_visit.groupId:
exp_id = get_exp_id_from_oid(oid)
# Ingest the snap
mwi.ingest_image(oid)
exp_id = mwi.ingest_image(oid)
expid_set.add(exp_id)
except ValueError:
_log.error(f"Failed to match object id '{oid}'")
Expand Down
6 changes: 6 additions & 0 deletions python/activator/middleware_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,11 @@ def ingest_image(self, oid: str) -> None:
----------
oid : `str`
Identifier for incoming image, relative to the image bucket.
Returns
-------
exposure_id : `int`
The exposure ID of the image that was just ingested.
"""
# TODO: consider allowing pre-existing raws, as may happen when a
# pipeline is rerun (see DM-34141).
Expand All @@ -967,6 +972,7 @@ def ingest_image(self, oid: str) -> None:
# how we plan to handle exceptions in this code.
assert len(result) == 1, "Should have ingested exactly one image."
_log.info("Ingested one %s with dataId=%s", result[0].datasetType.name, result[0].dataId)
return result[0].dataId["exposure"]

def _get_graph_executor(self, butler, factory):
"""Create a QuantumGraphExecutor suitable for Prompt Processing.
Expand Down
3 changes: 2 additions & 1 deletion tests/test_middleware_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def test_ingest_image(self):
self.next_visit)
with unittest.mock.patch.object(self.interface.rawIngestTask, "extractMetadata") as mock:
mock.return_value = file_data
self.interface.ingest_image(filename)
exp_id = self.interface.ingest_image(filename)
self.assertEqual(exp_id, int(self.next_visit.groupId))

datasets = list(self.interface.butler.registry.queryDatasets('raw',
collections=[f'{instname}/raw/all']))
Expand Down

0 comments on commit cd87384

Please sign in to comment.