Skip to content

Commit a0d512f

Browse files
committed
Do not allow rsync destination to be empty
1 parent cdbf693 commit a0d512f

File tree

3 files changed

+37
-56
lines changed

3 files changed

+37
-56
lines changed

src/murfey/client/destinations.py

Lines changed: 37 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import logging
44
from pathlib import Path
5-
from typing import Dict
65

7-
from murfey.client.analyser import Analyser
86
from murfey.client.instance_environment import (
97
MurfeyInstanceEnvironment,
108
global_env_lock,
@@ -19,7 +17,6 @@ def determine_default_destination(
1917
source: Path,
2018
destination: str,
2119
environment: MurfeyInstanceEnvironment,
22-
analysers: Dict[Path, Analyser],
2320
token: str,
2421
touch: bool = False,
2522
extra_directory: str = "",
@@ -33,57 +30,44 @@ def determine_default_destination(
3330
token=token,
3431
instrument_name=environment.instrument_name,
3532
).json()
36-
_default = ""
37-
if environment.processing_only_mode and environment.sources:
38-
logger.info(f"Processing only mode with sources {environment.sources}")
39-
_default = str(environment.sources[0].absolute()) or str(Path.cwd())
40-
elif machine_data.get("data_directories"):
41-
for data_dir in machine_data["data_directories"]:
42-
if source.absolute() == Path(data_dir).absolute():
43-
_default = f"{destination}/{visit}"
44-
break
45-
else:
46-
try:
47-
mid_path = source.absolute().relative_to(Path(data_dir).absolute())
48-
if use_suggested_path:
49-
with global_env_lock:
50-
if source.name == "Images-Disc1":
51-
source_name = source.parent.name
52-
elif source.name.startswith("Sample"):
53-
source_name = f"{source.parent.name}_{source.name}"
54-
else:
55-
source_name = source.name
56-
if environment.destination_registry.get(source_name):
57-
_default = environment.destination_registry[source_name]
58-
else:
59-
suggested_path_response = capture_post(
60-
base_url=str(environment.url.geturl()),
61-
router_name="file_io_instrument.router",
62-
function_name="suggest_path",
63-
token=token,
64-
visit_name=visit,
65-
session_id=environment.murfey_session,
66-
data={
67-
"base_path": f"{destination}/{visit}/{mid_path.parent if include_mid_path else ''}/raw",
68-
"touch": touch,
69-
"extra_directory": extra_directory,
70-
},
71-
)
72-
if suggested_path_response is None:
73-
raise RuntimeError("Murfey server is unreachable")
74-
_default = suggested_path_response.json().get(
75-
"suggested_path"
76-
)
77-
environment.destination_registry[source_name] = _default
78-
else:
79-
_default = f"{destination}/{visit}/{mid_path if include_mid_path else source.name}"
80-
break
81-
except (ValueError, KeyError):
82-
_default = ""
33+
_default = f"{destination}/{visit}"
34+
for data_dir in machine_data.get("data_directories", []):
35+
if source.absolute() == Path(data_dir).absolute():
36+
_default = f"{destination}/{visit}"
37+
break
8338
else:
84-
_default = ""
85-
else:
86-
_default = f"{destination}/{visit}"
39+
mid_path = source.absolute().relative_to(Path(data_dir).absolute())
40+
if use_suggested_path:
41+
with global_env_lock:
42+
if source.name == "Images-Disc1":
43+
source_name = source.parent.name
44+
elif source.name.startswith("Sample"):
45+
source_name = f"{source.parent.name}_{source.name}"
46+
else:
47+
source_name = source.name
48+
if environment.destination_registry.get(source_name):
49+
_default = environment.destination_registry[source_name]
50+
else:
51+
suggested_path_response = capture_post(
52+
base_url=str(environment.url.geturl()),
53+
router_name="file_io_instrument.router",
54+
function_name="suggest_path",
55+
token=token,
56+
visit_name=visit,
57+
session_id=environment.murfey_session,
58+
data={
59+
"base_path": f"{destination}/{visit}/{mid_path.parent if include_mid_path else ''}/raw",
60+
"touch": touch,
61+
"extra_directory": extra_directory,
62+
},
63+
)
64+
if suggested_path_response is None:
65+
raise RuntimeError("Murfey server is unreachable")
66+
_default = suggested_path_response.json().get("suggested_path")
67+
environment.destination_registry[source_name] = _default
68+
else:
69+
_default = f"{destination}/{visit}/{mid_path if include_mid_path else source.name}"
70+
break
8771
return (
8872
_default + f"/{extra_directory}"
8973
if not _default.endswith("/")

src/murfey/client/instance_environment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class MurfeyInstanceEnvironment(BaseModel):
4646
tilt_angles: Dict[str, List[List[str]]] = {}
4747
movie_counters: Dict[str, itertools.count] = {}
4848
visit: str = ""
49-
processing_only_mode: bool = False
5049
dose_per_frame: Optional[float] = None
5150
gain_ref: Optional[str] = None
5251
symmetry: Optional[str] = None

src/murfey/client/multigrid_control.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def __post_init__(self):
7777
symmetry=self.data_collection_parameters.get("symmetry"),
7878
eer_fractionation=self.data_collection_parameters.get("eer_fractionation"),
7979
instrument_name=self.instrument_name,
80-
# processing_only_mode=server_routing_prefix_found,
8180
)
8281
self._machine_config = get_machine_config_client(
8382
str(self._environment.url.geturl()),
@@ -274,7 +273,6 @@ def _start_rsyncer_multigrid(
274273
source,
275274
self._environment.default_destinations[source],
276275
self._environment,
277-
self.analysers or {},
278276
self.token,
279277
touch=True,
280278
extra_directory=extra_directory,

0 commit comments

Comments
 (0)