Skip to content

Commit 17fe304

Browse files
committed
Merged version bump from 'main'
2 parents a836a98 + 3f11363 commit 17fe304

File tree

21 files changed

+113
-227
lines changed

21 files changed

+113
-227
lines changed

.bumpclient.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.bumpversion]
2-
current_version = "0.16.8"
2+
current_version = "0.16.9"
33
commit = true
44
tag = false
55

.bumpversion.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.bumpversion]
2-
current_version = "0.16.8"
2+
current_version = "0.16.9"
33
commit = true
44
tag = true
55

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ requires = [
77

88
[project]
99
name = "murfey"
10-
version = "0.16.8"
10+
version = "0.16.9"
1111
description = "Client-Server architecture hauling Cryo-EM data"
1212
readme = "README.md"
1313
keywords = [

src/murfey/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from __future__ import annotations
22

3-
__version__ = "0.16.8"
4-
__supported_client_version__ = "0.16.8"
3+
__version__ = "0.16.9"
4+
__supported_client_version__ = "0.16.9"

src/murfey/cli/transfer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
from rich.prompt import Confirm
1111

1212
from murfey.client import read_config
13+
from murfey.util.config import MachineConfig
1314

1415

1516
def run():
1617
config = read_config()
17-
known_server = config["Murfey"].get("server")
18+
known_server = config["Murfey"].get("server", "")
19+
instrument_name = config["Murfey"].get("instrument_name", "")
1820

1921
parser = argparse.ArgumentParser(description="Transfer using a remote rsync daemon")
2022

@@ -35,7 +37,11 @@ def run():
3537
console = Console()
3638
murfey_url = urlparse(args.server, allow_fragments=False)
3739

38-
machine_data = requests.get(f"{murfey_url.geturl()}/machine").json()
40+
machine_data = MachineConfig(
41+
requests.get(
42+
f"{murfey_url.geturl()}/instruments/{instrument_name}/machine"
43+
).json()
44+
)
3945
if Path(args.source or ".").resolve() in machine_data.data_directories:
4046
console.print("[red]Source directory is the base directory, exiting")
4147
return

src/murfey/client/contexts/clem.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def _file_transferred_to(
3434
# rsync basepath and modules are set in the microscope's configuration YAML file
3535
return (
3636
Path(machine_config.get("rsync_basepath", ""))
37-
/ (
38-
machine_config.get("rsync_module", "data") or "data"
39-
) # Add "data" if it wasn't set
4037
/ str(datetime.now().year)
4138
/ source.name
4239
/ file_path.relative_to(source)

src/murfey/client/contexts/spa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _file_transferred_to(
4646
return (
4747
Path(machine_config.get("rsync_basepath", ""))
4848
/ Path(environment.default_destinations[source])
49-
/ file_path.relative_to(source)
49+
/ file_path.relative_to(source) # need to strip out the rsync_module name
5050
)
5151
return (
5252
Path(machine_config.get("rsync_basepath", ""))

src/murfey/client/contexts/tomo.py

Lines changed: 25 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class TomographyContext(Context):
7878
ProcessingParameter("image_size_y", "Image Size Y"),
7979
ProcessingParameter("pixel_size_on_image", "Pixel Size"),
8080
ProcessingParameter("motion_corr_binning", "Motion Correction Binning"),
81+
ProcessingParameter("frame_count", "Number of image frames"),
8182
ProcessingParameter("num_eer_frames", "Number of EER Frames"),
8283
]
8384

@@ -92,31 +93,6 @@ def __init__(self, acquisition_software: str, basepath: Path):
9293
self._processing_job_stash: dict = {}
9394
self._lock: RLock = RLock()
9495

95-
def _flush_data_collections(self):
96-
logger.info(
97-
f"Flushing {len(self._data_collection_stash)} data collection API calls"
98-
)
99-
for dc_data in self._data_collection_stash:
100-
data = {
101-
**dc_data[2],
102-
**{
103-
k: v
104-
for k, v in dc_data[1].data_collection_parameters.items()
105-
if k != "tag"
106-
},
107-
}
108-
capture_post(dc_data[0], json=data)
109-
self._data_collection_stash = []
110-
111-
def _flush_processing_jobs(self):
112-
logger.info(
113-
f"Flushing {len(self._processing_job_stash.keys())} processing job API calls"
114-
)
115-
for v in self._processing_job_stash.values():
116-
for pd in v:
117-
requests.post(pd[0], json=pd[1])
118-
self._processing_job_stash = {}
119-
12096
def _file_transferred_to(
12197
self, environment: MurfeyInstanceEnvironment, source: Path, file_path: Path
12298
):
@@ -227,8 +203,18 @@ def _add_tilt(
227203
self._tilt_series_sizes[tilt_series] = 0
228204
try:
229205
if environment:
230-
url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection"
231-
data = {
206+
dcg_url = f"{str(environment.url.geturl())}/visits/{str(environment.visit)}/{environment.murfey_session}/register_data_collection_group"
207+
dcg_data = {
208+
"experiment_type": "tomo",
209+
"experiment_type_id": 36,
210+
"tag": str(self._basepath),
211+
"atlas": "",
212+
"sample": None,
213+
}
214+
capture_post(dcg_url, json=dcg_data)
215+
216+
dc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection"
217+
dc_data = {
232218
"experiment_type": "tomography",
233219
"file_extension": file_path.suffix,
234220
"acquisition_software": self._acquisition_software,
@@ -245,7 +231,7 @@ def _add_tilt(
245231
environment.data_collection_parameters
246232
and environment.data_collection_parameters.get("voltage")
247233
):
248-
data.update(
234+
dc_data.update(
249235
{
250236
"voltage": environment.data_collection_parameters[
251237
"voltage"
@@ -264,51 +250,16 @@ def _add_tilt(
264250
],
265251
}
266252
)
253+
capture_post(dc_url, json=dc_data)
254+
267255
proc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/register_processing_job"
268-
if (
269-
environment.data_collection_group_ids.get(str(self._basepath))
270-
is None
271-
):
272-
self._data_collection_stash.append((url, environment, data))
273-
self._processing_job_stash[tilt_series] = [
274-
(
275-
proc_url,
276-
{
277-
"tag": tilt_series,
278-
"source": str(self._basepath),
279-
"recipe": "em-tomo-preprocess",
280-
"experiment_type": "tomography",
281-
},
282-
)
283-
]
284-
self._processing_job_stash[tilt_series].append(
285-
(
286-
proc_url,
287-
{
288-
"tag": tilt_series,
289-
"source": str(self._basepath),
290-
"recipe": "em-tomo-align",
291-
"experiment_type": "tomography",
292-
},
293-
)
294-
)
295-
else:
296-
capture_post(url, json=data)
297-
capture_post(
298-
proc_url,
299-
json={
300-
"tag": tilt_series,
301-
"source": str(self._basepath),
302-
"recipe": "em-tomo-preprocess",
303-
"experiment_type": "tomography",
304-
},
305-
)
256+
for recipe in ("em-tomo-preprocess", "em-tomo-align"):
306257
capture_post(
307258
proc_url,
308259
json={
309260
"tag": tilt_series,
310261
"source": str(self._basepath),
311-
"recipe": "em-tomo-align",
262+
"recipe": recipe,
312263
"experiment_type": "tomography",
313264
},
314265
)
@@ -361,6 +312,9 @@ def _add_tilt(
361312
"dose_per_frame": environment.data_collection_parameters.get(
362313
"dose_per_frame", 0
363314
),
315+
"frame_count": environment.data_collection_parameters.get(
316+
"frame_count", 0
317+
),
364318
"mc_binning": environment.data_collection_parameters.get(
365319
"motion_corr_binning", 1
366320
),
@@ -591,6 +545,7 @@ def gather_metadata(
591545
mdoc_metadata: OrderedDict = OrderedDict({})
592546
mdoc_metadata["experiment_type"] = "tomography"
593547
mdoc_metadata["voltage"] = float(mdoc_data["Voltage"])
548+
mdoc_metadata["frame_count"] = int(mdoc_data_block["NumSubFrames"])
594549
mdoc_metadata["image_size_x"] = int(mdoc_data["ImageSize"][0])
595550
mdoc_metadata["image_size_y"] = int(mdoc_data["ImageSize"][1])
596551
mdoc_metadata["magnification"] = int(mdoc_data_block["Magnification"])
@@ -658,6 +613,9 @@ def gather_metadata(
658613
mdoc_metadata["num_eer_frames"] = murfey.util.eer.num_frames(
659614
metadata_file.parent / data_file
660615
)
616+
mdoc_metadata["frame_count"] = int(
617+
mdoc_metadata["eer_fractionation"] / mdoc_metadata["num_eer_frames"]
618+
)
661619
except Exception as e:
662620
logger.error(f"Exception encountered in metadata gathering: {str(e)}")
663621
return OrderedDict({})

src/murfey/client/instance_environment.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class MurfeyInstanceEnvironment(BaseModel):
4141
destination_registry: Dict[str, str] = {}
4242
watchers: Dict[Path, DirWatcher] = {}
4343
demo: bool = False
44-
data_collection_group_ids: Dict[str, int] = {}
4544
data_collection_parameters: dict = {}
4645
movies: Dict[Path, MovieTracker] = {}
4746
movie_tilt_pair: Dict[Path, str] = {}
@@ -64,7 +63,6 @@ def clear(self):
6463
for w in self.watchers.values():
6564
w.stop()
6665
self.watchers = {}
67-
self.data_collection_group_ids = {}
6866
self.data_collection_parameters = {}
6967
self.movies = {}
7068
self.movie_tilt_pair = {}

src/murfey/client/multigrid_control.py

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MultigridController:
3232
session_id: int
3333
murfey_url: str = "http://localhost:8000"
3434
rsync_url: str = ""
35+
rsync_module: str = "data"
3536
demo: bool = False
3637
processing_enabled: bool = True
3738
do_transfer: bool = True
@@ -59,12 +60,13 @@ def __post_init__(self):
5960
f"{self.murfey_url}/instruments/{self.instrument_name}/machine"
6061
).json()
6162
self.rsync_url = machine_data.get("rsync_url", "")
63+
self.rsync_module = machine_data.get("rsync_module", "data")
6264
self._environment = MurfeyInstanceEnvironment(
6365
url=urlparse(self.murfey_url, allow_fragments=False),
6466
client_id=0,
6567
murfey_session=self.session_id,
6668
software_versions=machine_data.get("software_versions", {}),
67-
default_destination=f"{machine_data.get('rsync_module') or 'data'}/{datetime.now().year}",
69+
default_destination=f"{datetime.now().year}",
6870
demo=self.demo,
6971
visit=self.visit,
7072
data_collection_parameters=self.data_collection_parameters,
@@ -123,7 +125,7 @@ def _start_rsyncer_multigrid(
123125
break
124126
else:
125127
self._environment.default_destinations[source] = (
126-
f"{machine_data.get('rsync_module') or 'data'}/{datetime.now().year}"
128+
f"{datetime.now().year}"
127129
)
128130
destination = determine_default_destination(
129131
self._environment.visit,
@@ -205,7 +207,7 @@ def _start_rsyncer(
205207
rsync_cmd = [
206208
"rsync",
207209
f"{posix_path(self._environment.gain_ref)!r}", # '!r' will print strings in ''
208-
f"{self._environment.url.hostname}::{visit_path}/processing",
210+
f"{self._environment.url.hostname}::{self.rsync_module}/{visit_path}/processing",
209211
]
210212
# Wrap in bash shell
211213
cmd = [
@@ -223,6 +225,7 @@ def _start_rsyncer(
223225
self.rsync_processes[source] = RSyncer(
224226
source,
225227
basepath_remote=Path(destination),
228+
rsync_module=self.rsync_module,
226229
server_url=(
227230
urlparse(self.rsync_url)
228231
if self.rsync_url
@@ -374,46 +377,6 @@ def _start_dc(self, json, from_form: bool = False):
374377
)
375378

376379
source = Path(json["source"])
377-
378-
url = f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self.session_id}/register_data_collection_group"
379-
dcg_data = {
380-
"experiment_type": "tomo",
381-
"experiment_type_id": 36,
382-
"tag": str(source),
383-
}
384-
requests.post(url, json=dcg_data)
385-
386-
data = {
387-
"voltage": json["voltage"],
388-
"pixel_size_on_image": json["pixel_size_on_image"],
389-
"experiment_type": json["experiment_type"],
390-
"image_size_x": json["image_size_x"],
391-
"image_size_y": json["image_size_y"],
392-
"file_extension": json["file_extension"],
393-
"acquisition_software": json["acquisition_software"],
394-
"image_directory": str(self._environment.default_destinations[source]),
395-
"tag": json["tilt_series_tag"],
396-
"source": str(source),
397-
"magnification": json["magnification"],
398-
"total_exposed_dose": json.get("total_exposed_dose"),
399-
"c2aperture": json.get("c2aperture"),
400-
"exposure_time": json.get("exposure_time"),
401-
"slit_width": json.get("slit_width"),
402-
"phase_plate": json.get("phase_plate", False),
403-
}
404-
capture_post(
405-
f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self._environment.murfey_session}/start_data_collection",
406-
json=data,
407-
)
408-
for recipe in ("em-tomo-preprocess", "em-tomo-align"):
409-
capture_post(
410-
f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self._environment.murfey_session}/register_processing_job",
411-
json={
412-
"tag": json["tilt_series_tag"],
413-
"source": str(source),
414-
"recipe": recipe,
415-
},
416-
)
417380
log.info("Registering tomography processing parameters")
418381
if self._environment.data_collection_parameters.get("num_eer_frames"):
419382
eer_response = requests.post(
@@ -437,8 +400,6 @@ def _start_dc(self, json, from_form: bool = False):
437400
f"{self._environment.url.geturl()}/sessions/{self._environment.murfey_session}/tomography_preprocessing_parameters",
438401
json=json,
439402
)
440-
context._flush_data_collections()
441-
context._flush_processing_jobs()
442403
capture_post(
443404
f"{self._environment.url.geturl()}/visits/{self._environment.visit}/{self._environment.murfey_session}/flush_tomography_processing",
444405
json={"rsync_source": str(source)},

0 commit comments

Comments
 (0)