Skip to content

Commit ac6dcce

Browse files
Do not update scaup for atlases if two dcgs exist (#743)
To try and avoid the case where scaup directs to the atlas dcg when a processing one also exists. Checks to see if the tag is an atlas and if so does not do the scaup updates if we have another dcg
1 parent 936fc5b commit ac6dcce

File tree

4 files changed

+49
-6
lines changed

4 files changed

+49
-6
lines changed

src/murfey/server/api/workflow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def register_dc_group(
138138
_transport_object.feedback_queue,
139139
{
140140
"register": "atlas_update",
141+
"tag": dcg_instance.tag,
141142
"atlas_id": dcg_instance.atlas_id,
142143
"atlas": dcg_params.atlas,
143144
"sample": dcg_params.sample,

src/murfey/workflows/register_atlas_update.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import logging
22
from importlib.metadata import entry_points
3+
from pathlib import Path
34

5+
from sqlmodel import select
46
from sqlmodel.orm.session import Session as SQLModelSession
57

68
from murfey.server import _transport_object
9+
from murfey.util.db import DataCollectionGroup
710

811
logger = logging.getLogger("murfey.workflows.register_atlas_update")
912

@@ -27,6 +30,24 @@ def run(
2730
collection_mode=message.get("collection_mode"),
2831
color_flags=message.get("color_flags", {}),
2932
)
33+
34+
# Find out how many dcgs we have with this atlas
35+
if (
36+
message.get("atlas")
37+
and message.get("sample")
38+
and "atlas" in Path(message.get("tag", "/")).parts
39+
):
40+
dcgs_atlas = murfey_db.exec(
41+
select(DataCollectionGroup)
42+
.where(DataCollectionGroup.session_id == message["session_id"])
43+
.where(DataCollectionGroup.atlas == message["atlas"])
44+
.where(DataCollectionGroup.sample == message["sample"])
45+
).all()
46+
if len(dcgs_atlas) > 1:
47+
# Skip hooks if this is an atlas and there is a processing dcg present
48+
logger.info(f"Skipping data collection group hooks for {message['tag']}")
49+
return {"success": True}
50+
3051
if dcg_hooks := entry_points(group="murfey.hooks", name="data_collection_group"):
3152
try:
3253
for hook in dcg_hooks:

src/murfey/workflows/register_data_collection_group.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import logging
22
import time
33
from importlib.metadata import entry_points
4+
from pathlib import Path
45

56
import ispyb.sqlalchemy._auto_db_schema as ISPyBDB
67
from sqlmodel import select
78
from sqlmodel.orm.session import Session as SQLModelSession
89

9-
import murfey.util.db as MurfeyDB
1010
from murfey.server import _transport_object
1111
from murfey.server.ispyb import ISPyBSession, get_session_id
12+
from murfey.util.db import DataCollectionGroup
1213

1314
logger = logging.getLogger("murfey.workflows.register_data_collection_group")
1415

@@ -30,14 +31,14 @@ def run(message: dict, murfey_db: SQLModelSession) -> dict[str, bool]:
3031
)
3132

3233
if dcg_murfey := murfey_db.exec(
33-
select(MurfeyDB.DataCollectionGroup)
34-
.where(MurfeyDB.DataCollectionGroup.session_id == message["session_id"])
35-
.where(MurfeyDB.DataCollectionGroup.tag == message.get("tag"))
34+
select(DataCollectionGroup)
35+
.where(DataCollectionGroup.session_id == message["session_id"])
36+
.where(DataCollectionGroup.tag == message.get("tag"))
3637
).all():
3738
dcgid = dcg_murfey[0].id
3839
else:
3940
if ispyb_session_id is None:
40-
murfey_dcg = MurfeyDB.DataCollectionGroup(
41+
murfey_dcg = DataCollectionGroup(
4142
session_id=message["session_id"],
4243
tag=message.get("tag"),
4344
)
@@ -77,7 +78,7 @@ def run(message: dict, murfey_db: SQLModelSession) -> dict[str, bool]:
7778
"return_value", None
7879
)
7980

80-
murfey_dcg = MurfeyDB.DataCollectionGroup(
81+
murfey_dcg = DataCollectionGroup(
8182
id=dcgid,
8283
atlas_id=atlas_id,
8384
atlas=message.get("atlas", ""),
@@ -90,6 +91,23 @@ def run(message: dict, murfey_db: SQLModelSession) -> dict[str, bool]:
9091
murfey_db.commit()
9192
murfey_db.close()
9293

94+
# Find out how many dcgs we have with this atlas
95+
if (
96+
message.get("atlas")
97+
and message.get("sample")
98+
and "atlas" in Path(message.get("tag", "/")).parts
99+
):
100+
dcgs_atlas = murfey_db.exec(
101+
select(DataCollectionGroup)
102+
.where(DataCollectionGroup.session_id == message["session_id"])
103+
.where(DataCollectionGroup.atlas == message["atlas"])
104+
.where(DataCollectionGroup.sample == message["sample"])
105+
).all()
106+
if len(dcgs_atlas) > 1:
107+
# Skip hooks if this is an atlas and there is a processing dcg present
108+
logger.info(f"Skipping data collection group hooks for {message['tag']}")
109+
return {"success": True}
110+
93111
if dcg_hooks := entry_points(group="murfey.hooks", name="data_collection_group"):
94112
try:
95113
for hook in dcg_hooks:

tests/server/api/test_workflow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ def test_register_dc_group_processing_to_atlas(
177177
"atlas_pixel_size": 1e-4,
178178
"dcgid": 1,
179179
"session_id": ExampleVisit.murfey_session_id,
180+
"tag": "processing_tag",
180181
},
181182
)
182183
mock_transport.send.assert_any_call(
@@ -189,6 +190,7 @@ def test_register_dc_group_processing_to_atlas(
189190
"atlas_pixel_size": 1e-4,
190191
"dcgid": 2,
191192
"session_id": ExampleVisit.murfey_session_id,
193+
"tag": "second_processing_tag",
192194
},
193195
)
194196

@@ -395,6 +397,7 @@ def test_register_dc_group_new_atlas_with_searchmaps(
395397
"atlas_pixel_size": 1e-4,
396398
"dcgid": 1,
397399
"session_id": ExampleVisit.murfey_session_id,
400+
"tag": "processing_tag",
398401
},
399402
)
400403

0 commit comments

Comments
 (0)