Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43502: Prompt Processing should get expId from ingest, not file path #145

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading