Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
90 changes: 37 additions & 53 deletions src/murfey/client/destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import logging
from pathlib import Path
from typing import Dict

from murfey.client.analyser import Analyser
from murfey.client.instance_environment import (
MurfeyInstanceEnvironment,
global_env_lock,
Expand All @@ -19,7 +17,6 @@ def determine_default_destination(
source: Path,
destination: str,
environment: MurfeyInstanceEnvironment,
analysers: Dict[Path, Analyser],
token: str,
touch: bool = False,
extra_directory: str = "",
Expand All @@ -33,57 +30,44 @@ def determine_default_destination(
token=token,
instrument_name=environment.instrument_name,
).json()
_default = ""
if environment.processing_only_mode and environment.sources:
logger.info(f"Processing only mode with sources {environment.sources}")
_default = str(environment.sources[0].absolute()) or str(Path.cwd())
elif machine_data.get("data_directories"):
for data_dir in machine_data["data_directories"]:
if source.absolute() == Path(data_dir).absolute():
_default = f"{destination}/{visit}"
break
else:
try:
mid_path = source.absolute().relative_to(Path(data_dir).absolute())
if use_suggested_path:
with global_env_lock:
if source.name == "Images-Disc1":
source_name = source.parent.name
elif source.name.startswith("Sample"):
source_name = f"{source.parent.name}_{source.name}"
else:
source_name = source.name
if environment.destination_registry.get(source_name):
_default = environment.destination_registry[source_name]
else:
suggested_path_response = capture_post(
base_url=str(environment.url.geturl()),
router_name="file_io_instrument.router",
function_name="suggest_path",
token=token,
visit_name=visit,
session_id=environment.murfey_session,
data={
"base_path": f"{destination}/{visit}/{mid_path.parent if include_mid_path else ''}/raw",
"touch": touch,
"extra_directory": extra_directory,
},
)
if suggested_path_response is None:
raise RuntimeError("Murfey server is unreachable")
_default = suggested_path_response.json().get(
"suggested_path"
)
environment.destination_registry[source_name] = _default
else:
_default = f"{destination}/{visit}/{mid_path if include_mid_path else source.name}"
break
except (ValueError, KeyError):
_default = ""
_default = f"{destination}/{visit}"
for data_dir in machine_data.get("data_directories", []):
if source.absolute() == Path(data_dir).absolute():
_default = f"{destination}/{visit}"
Comment thread
stephen-riggs marked this conversation as resolved.
Outdated
break
else:
_default = ""
else:
_default = f"{destination}/{visit}"
mid_path = source.absolute().relative_to(Path(data_dir).absolute())
if use_suggested_path:
with global_env_lock:
if source.name == "Images-Disc1":
source_name = source.parent.name
elif source.name.startswith("Sample"):
source_name = f"{source.parent.name}_{source.name}"
else:
source_name = source.name
if environment.destination_registry.get(source_name):
_default = environment.destination_registry[source_name]
else:
suggested_path_response = capture_post(
base_url=str(environment.url.geturl()),
router_name="file_io_instrument.router",
function_name="suggest_path",
token=token,
visit_name=visit,
session_id=environment.murfey_session,
data={
"base_path": f"{destination}/{visit}/{mid_path.parent if include_mid_path else ''}/raw",
"touch": touch,
"extra_directory": extra_directory,
},
)
if suggested_path_response is None:
raise RuntimeError("Murfey server is unreachable")
_default = suggested_path_response.json().get("suggested_path")
environment.destination_registry[source_name] = _default
else:
_default = f"{destination}/{visit}/{mid_path if include_mid_path else source.name}"
break
return (
_default + f"/{extra_directory}"
if not _default.endswith("/")
Expand Down
1 change: 0 additions & 1 deletion src/murfey/client/instance_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class MurfeyInstanceEnvironment(BaseModel):
tilt_angles: Dict[str, List[List[str]]] = {}
movie_counters: Dict[str, itertools.count] = {}
visit: str = ""
processing_only_mode: bool = False
dose_per_frame: Optional[float] = None
gain_ref: Optional[str] = None
symmetry: Optional[str] = None
Expand Down
2 changes: 0 additions & 2 deletions src/murfey/client/multigrid_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def __post_init__(self):
symmetry=self.data_collection_parameters.get("symmetry"),
eer_fractionation=self.data_collection_parameters.get("eer_fractionation"),
instrument_name=self.instrument_name,
# processing_only_mode=server_routing_prefix_found,
)
self._machine_config = get_machine_config_client(
str(self._environment.url.geturl()),
Expand Down Expand Up @@ -274,7 +273,6 @@ def _start_rsyncer_multigrid(
source,
self._environment.default_destinations[source],
self._environment,
self.analysers or {},
self.token,
touch=True,
extra_directory=extra_directory,
Expand Down