Skip to content

Commit e8e361d

Browse files
authored
Container setup for TEM workflow + tomography/SPA bugfixes (#503)
* Set up Helm charts needed to create an instrument server container to test TEM workflow with * Added an rsync_url key to the MurfeyInstanceEnvironment class, now that we are supporting externally run rsync daemons * Set microscope name using instrument_name from database lookup, instead of using the get_microscope() function * Added logs to the prepare_(eer_)gain() function to see why the subprocess fails * Fixed logic for why the first tomography position is not processed * Added logic to handle cases in the feedback_callback function where no workflows are found * Locked NumPy to <2
1 parent f9fbc35 commit e8e361d

File tree

15 files changed

+155
-27
lines changed

15 files changed

+155
-27
lines changed

Helm/Chart.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ description: Umbrella Helm chart for deploying the servers and daemons needed to
44
version: 0.16.12
55
dependencies:
66
- name: murfey-instrument-server-clem
7+
- name: murfey-instrument-server-tem
78
- name: murfey-server
89
- name: murfey-rsync
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
name: murfey-instrument-server-tem
3+
description: Helm chart for deploying a Murfey instrument server, which executes orders to detect, modify, and transfer files on the instrument PC, and notifies the backend server about transferred files
4+
version: 0.16.12
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ .Values.appName }}
5+
namespace: {{ .Values.global.namespace }}
6+
labels:
7+
app: {{ .Values.appName }}
8+
spec:
9+
type: LoadBalancer
10+
externalTrafficPolicy: Cluster
11+
ports:
12+
{{- toYaml .Values.servicePorts | nindent 2 }}
13+
selector:
14+
app: {{ .Values.appName }}
15+
---
16+
apiVersion: apps/v1
17+
kind: Deployment
18+
metadata:
19+
name: {{ .Values.appName }}
20+
namespace: {{ .Values.global.namespace }}
21+
labels:
22+
app: {{ .Values.appName }}
23+
spec:
24+
replicas: {{ .Values.replicas }}
25+
selector:
26+
matchLabels:
27+
app: {{ .Values.appName }}
28+
template:
29+
metadata:
30+
labels:
31+
app: {{ .Values.appName }}
32+
spec:
33+
securityContext:
34+
runAsUser: {{ .Values.global.runAsUser }}
35+
runAsGroup: {{ .Values.global.runAsGroup }}
36+
volumes:
37+
# Mount config files from secrets
38+
- name: murfey-client-config
39+
secret:
40+
secretName: {{ .Values.global.murfeyClientConfigTEMSecretName }}
41+
items:
42+
- key: {{ .Values.global.murfeyClientConfigTEMFileName }}
43+
path: .murfey
44+
# Mount data directories
45+
{{- toYaml .Values.extraVolumes | nindent 8 }}
46+
containers:
47+
- name: {{ .Values.appName }}
48+
image: {{ .Values.image }}
49+
imagePullPolicy: Always
50+
securityContext:
51+
privileged: false
52+
volumeMounts:
53+
# Mount Murfey client config
54+
- name: murfey-client-config
55+
mountPath: /murfey/config/.murfey
56+
subPath: .murfey
57+
readOnly: false
58+
# Mount data directories
59+
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
60+
env:
61+
- name: MURFEY_CLIENT_CONFIG_HOME
62+
value: "/tmp"
63+
ports:
64+
- containerPort: {{ .Values.containerPort }}
65+
command:
66+
{{- toYaml .Values.command | nindent 12 }}
67+
args:
68+
{{- toYaml .Values.args | nindent 12 }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ server = [
6464
"ispyb", # Responsible for setting requirements for SQLAlchemy and mysql-connector-python; v10.0.0: sqlalchemy <2, mysql-connector-python >=8.0.32
6565
"jinja2",
6666
"mrcfile",
67-
"numpy",
67+
"numpy<2",
6868
"packaging",
6969
"passlib",
7070
"pillow",

src/murfey/client/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ def run():
322322
default_destination=args.destination or str(datetime.now().year),
323323
demo=args.demo,
324324
processing_only_mode=server_routing_prefix_found,
325+
rsync_url=(
326+
urlparse(machine_data["rsync_url"]).hostname
327+
if machine_data.get("rsync_url")
328+
else ""
329+
),
325330
)
326331

327332
ws.environment = instance_environment

src/murfey/client/analyser.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from murfey.client.rsync import RSyncerUpdate, TransferResult
2424
from murfey.client.tui.forms import FormDependency
2525
from murfey.util import Observer, get_machine_config_client
26+
from murfey.util.mdoc import get_block
2627
from murfey.util.models import PreprocessingParametersTomo, ProcessingParametersSPA
2728

2829
logger = logging.getLogger("murfey.client.analyser")
@@ -113,6 +114,13 @@ def _find_extension(self, file_path: Path):
113114
):
114115
logger.info(f"File extension re-evaluated: {file_path.suffix}")
115116
self._extension = file_path.suffix
117+
# If we see an .mdoc file first, use that to determine the file extensions
118+
elif file_path.suffix == ".mdoc":
119+
with open(file_path, "r") as md:
120+
md.seek(0)
121+
mdoc_data_block = get_block(md)
122+
if subframe_path := mdoc_data_block.get("SubFramePath"):
123+
self._extension = Path(subframe_path).suffix
116124
# Check for LIF files separately
117125
elif file_path.suffix == ".lif":
118126
self._extension = file_path.suffix
@@ -124,6 +132,7 @@ def _find_context(self, file_path: Path) -> bool:
124132
stages of processing. Actions to take for individual files will be determined
125133
in the Context classes themselves.
126134
"""
135+
logger.debug(f"Finding context using file {str(file_path)!r}")
127136
if "atlas" in file_path.parts:
128137
self._context = SPAMetadataContext("epu", self._basepath)
129138
return True
@@ -258,9 +267,9 @@ def _analyse(self):
258267
self._find_extension(transferred_file)
259268
found = self._find_context(transferred_file)
260269
if not found:
261-
# logger.warning(
262-
# f"Context not understood for {transferred_file}, stopping analysis"
263-
# )
270+
logger.debug(
271+
f"Couldn't find context for {str(transferred_file)!r}"
272+
)
264273
self.queue.task_done()
265274
continue
266275
elif self._extension:
@@ -383,6 +392,10 @@ def _analyse(self):
383392
SPAMetadataContext,
384393
),
385394
):
395+
context = str(self._context).split(" ")[0].split(".")[-1]
396+
logger.debug(
397+
f"Transferring file {str(transferred_file)} with context {context!r}"
398+
)
386399
self.post_transfer(transferred_file)
387400
self.queue.task_done()
388401

src/murfey/client/contexts/tomo.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,19 @@ def _check_tilt_series(
366366
newly_completed_series: List[str] = []
367367
mdoc_tilt_series_size = self._tilt_series_sizes.get(tilt_series, 0)
368368
if not self._tilt_series or not mdoc_tilt_series_size:
369+
logger.debug(f"Tilt series size not yet set for {tilt_series!r}")
369370
return newly_completed_series
370371

371372
counted_tilts = len(self._tilt_series.get(tilt_series, []))
372373
tilt_series_size_check = counted_tilts >= mdoc_tilt_series_size
373374
if tilt_series_size_check and tilt_series not in self._completed_tilt_series:
374375
self._completed_tilt_series.append(tilt_series)
375376
newly_completed_series.append(tilt_series)
377+
else:
378+
logger.debug(
379+
f"{tilt_series!r} not complete yet. Counted {counted_tilts} tilts. "
380+
f"Expected number of tilts was {mdoc_tilt_series_size}"
381+
)
376382
return newly_completed_series
377383

378384
def _add_tomo_tilt(

src/murfey/client/instance_environment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class MurfeyInstanceEnvironment(BaseModel):
5252
superres: bool = True
5353
murfey_session: Optional[int] = None
5454
samples: Dict[Path, SampleInfo] = {}
55+
rsync_url: str = ""
5556

5657
class Config:
5758
validate_assignment: bool = True

src/murfey/client/multigrid_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ def _start_dc(self, json, from_form: bool = False):
410410
f"{self._environment.url.geturl()}/visits/{self._environment.visit}/{self._environment.murfey_session}/flush_tomography_processing",
411411
json={"rsync_source": str(source)},
412412
)
413-
log.info("tomography processing flushed")
413+
log.info("Tomography processing flushed")
414414

415415
elif isinstance(context, SPAModularContext):
416416
url = f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self.session_id}/register_data_collection_group"

src/murfey/client/tui/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ def _start_dc(self, json, from_form: bool = False):
511511
f"{self.app._environment.url.geturl()}/visits/{self._visit}/{self.app._environment.murfey_session}/flush_tomography_processing",
512512
json={"rsync_source": str(source)},
513513
)
514-
log.info("tomography processing flushed")
514+
log.info("Tomography processing flushed")
515515
elif isinstance(context, SPAModularContext):
516516
url = f"{str(self._url.geturl())}/visits/{str(self._visit)}/{self._environment.murfey_session}/register_data_collection_group"
517517
dcg_data = {

0 commit comments

Comments
 (0)