Skip to content

Commit 7ea6672

Browse files
committed
Pass machine config directly to 'ensure_dcg_exists' and pass 'rsync_basepath' directly to '_atlas_destination'
1 parent 906a66c commit 7ea6672

7 files changed

Lines changed: 27 additions & 12 deletions

File tree

src/murfey/client/context.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import xmltodict
99

1010
from murfey.client.instance_environment import MurfeyInstanceEnvironment, SampleInfo
11-
from murfey.util.client import capture_post, get_machine_config_client
11+
from murfey.util.client import capture_post
1212

1313
logger = logging.getLogger("murfey.client.context")
1414

@@ -50,22 +50,19 @@ def _get_source(file_path: Path, environment: MurfeyInstanceEnvironment) -> Path
5050

5151

5252
def _atlas_destination(
53-
environment: MurfeyInstanceEnvironment, source: Path, token: str
53+
environment: MurfeyInstanceEnvironment,
54+
source: Path,
55+
rsync_basepath: Path,
5456
) -> Path:
55-
machine_config = get_machine_config_client(
56-
str(environment.url.geturl()),
57-
token,
58-
instrument_name=environment.instrument_name,
59-
)
6057
for i, destination_part in enumerate(
6158
Path(environment.default_destinations[source]).parts
6259
):
6360
if destination_part == environment.visit:
64-
return Path(machine_config.get("rsync_basepath", "")) / "/".join(
61+
return rsync_basepath / "/".join(
6562
Path(environment.default_destinations[source]).parent.parts[: i + 1]
6663
)
6764
return (
68-
Path(machine_config.get("rsync_basepath", ""))
65+
rsync_basepath
6966
/ Path(environment.default_destinations[source]).parent
7067
/ environment.visit
7168
)
@@ -75,6 +72,7 @@ def ensure_dcg_exists(
7572
collection_type: str,
7673
metadata_source: Path,
7774
environment: MurfeyInstanceEnvironment,
75+
machine_config: dict,
7876
token: str,
7977
) -> str | None:
8078
"""Create a data collection group"""
@@ -181,7 +179,11 @@ def ensure_dcg_exists(
181179
"experiment_type_id": experiment_type_id,
182180
"tag": dcg_tag,
183181
"atlas": str(
184-
_atlas_destination(environment, session_file.parent, token)
182+
_atlas_destination(
183+
environment,
184+
session_file.parent,
185+
Path(machine_config.get("rsync_basepath", "")),
186+
)
185187
/ environment.samples[metadata_source].atlas.parent
186188
/ atlas_xml_path.with_suffix(".jpg").name
187189
).replace("//", "/"),

src/murfey/client/contexts/atlas.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def post_transfer_epu(
7676
source = _get_source(transferred_file, environment)
7777
if source:
7878
transferred_atlas_name = _atlas_destination(
79-
environment, source, self._token
79+
environment,
80+
source,
81+
Path(self._machine_config.get("rsync_basepath", "")),
8082
) / transferred_file.relative_to(source.parent)
8183
capture_post(
8284
base_url=str(environment.url.geturl()),
@@ -98,7 +100,9 @@ def post_transfer_epu(
98100
if source:
99101
atlas_mrc = transferred_file.with_suffix(".mrc")
100102
transferred_atlas_jpg = _atlas_destination(
101-
environment, source, self._token
103+
environment,
104+
source,
105+
Path(self._machine_config.get("rsync_basepath", "")),
102106
) / atlas_mrc.relative_to(source.parent).with_suffix(".jpg")
103107

104108
with open(transferred_file, "rb") as atlas_xml:

src/murfey/client/contexts/spa_metadata.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def post_transfer(
128128
collection_type="spa",
129129
metadata_source=images_disc,
130130
environment=environment,
131+
machine_config=self._machine_config,
131132
token=self._token,
132133
)
133134
for gs, pos_data in gs_pix_positions.items():
@@ -167,6 +168,7 @@ def post_transfer(
167168
collection_type="spa",
168169
metadata_source=images_disc,
169170
environment=environment,
171+
machine_config=self._machine_config,
170172
token=self._token,
171173
)
172174

src/murfey/client/contexts/sxt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def register_sxt_data_collection(
5353
collection_type="sxt",
5454
metadata_source=metadata_source,
5555
environment=environment,
56+
machine_config=self._machine_config,
5657
token=self._token,
5758
)
5859

src/murfey/client/contexts/tomo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def register_tomography_data_collections(
115115
collection_type="tomo",
116116
metadata_source=metadata_source,
117117
environment=environment,
118+
machine_config=self._machine_config,
118119
token=self._token,
119120
)
120121

src/murfey/client/contexts/tomo_metadata.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def post_transfer(
5757
collection_type="tomo",
5858
metadata_source=metadata_source,
5959
environment=environment,
60+
machine_config=self._machine_config,
6061
token=self._token,
6162
)
6263

@@ -67,6 +68,7 @@ def post_transfer(
6768
collection_type="tomo",
6869
metadata_source=metadata_source,
6970
environment=environment,
71+
machine_config=self._machine_config,
7072
token=self._token,
7173
)
7274
with open(transferred_file, "r") as sm_xml:
@@ -174,6 +176,7 @@ def post_transfer(
174176
collection_type="tomo",
175177
metadata_source=metadata_source,
176178
environment=environment,
179+
machine_config=self._machine_config,
177180
token=self._token,
178181
)
179182
with open(transferred_file, "r") as sm_xml:
@@ -230,6 +233,7 @@ def post_transfer(
230233
collection_type="tomo",
231234
metadata_source=metadata_source,
232235
environment=environment,
236+
machine_config=self._machine_config,
233237
token=self._token,
234238
)
235239
with open(transferred_file) as xml:

src/murfey/client/multigrid_control.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ def _start_dc(self, metadata_json):
575575
collection_type="spa",
576576
metadata_source=metadata_source,
577577
environment=self._environment,
578+
machine_config=self._machine_config,
578579
token=self.token,
579580
)
580581
except Exception as e:

0 commit comments

Comments
 (0)