diff --git a/src/murfey/client/contexts/tomo.py b/src/murfey/client/contexts/tomo.py index da9ea9b9c..e61ab8f69 100644 --- a/src/murfey/client/contexts/tomo.py +++ b/src/murfey/client/contexts/tomo.py @@ -92,31 +92,6 @@ def __init__(self, acquisition_software: str, basepath: Path): self._processing_job_stash: dict = {} self._lock: RLock = RLock() - def _flush_data_collections(self): - logger.info( - f"Flushing {len(self._data_collection_stash)} data collection API calls" - ) - for dc_data in self._data_collection_stash: - data = { - **dc_data[2], - **{ - k: v - for k, v in dc_data[1].data_collection_parameters.items() - if k != "tag" - }, - } - capture_post(dc_data[0], json=data) - self._data_collection_stash = [] - - def _flush_processing_jobs(self): - logger.info( - f"Flushing {len(self._processing_job_stash.keys())} processing job API calls" - ) - for v in self._processing_job_stash.values(): - for pd in v: - requests.post(pd[0], json=pd[1]) - self._processing_job_stash = {} - def _file_transferred_to( self, environment: MurfeyInstanceEnvironment, source: Path, file_path: Path ): @@ -227,8 +202,18 @@ def _add_tilt( self._tilt_series_sizes[tilt_series] = 0 try: if environment: - url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection" - data = { + dcg_url = f"{str(environment.url.geturl())}/visits/{str(environment.visit)}/{environment.murfey_session}/register_data_collection_group" + dcg_data = { + "experiment_type": "tomo", + "experiment_type_id": 36, + "tag": str(self._basepath), + "atlas": "", + "sample": None, + } + capture_post(dcg_url, json=dcg_data) + + dc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/start_data_collection" + dc_data = { "experiment_type": "tomography", "file_extension": file_path.suffix, "acquisition_software": self._acquisition_software, @@ -245,7 +230,7 @@ def _add_tilt( environment.data_collection_parameters and environment.data_collection_parameters.get("voltage") ): - data.update( + dc_data.update( { "voltage": environment.data_collection_parameters[ "voltage" @@ -264,51 +249,16 @@ def _add_tilt( ], } ) + capture_post(dc_url, json=dc_data) + proc_url = f"{str(environment.url.geturl())}/visits/{environment.visit}/{environment.murfey_session}/register_processing_job" - if ( - environment.data_collection_group_ids.get(str(self._basepath)) - is None - ): - self._data_collection_stash.append((url, environment, data)) - self._processing_job_stash[tilt_series] = [ - ( - proc_url, - { - "tag": tilt_series, - "source": str(self._basepath), - "recipe": "em-tomo-preprocess", - "experiment_type": "tomography", - }, - ) - ] - self._processing_job_stash[tilt_series].append( - ( - proc_url, - { - "tag": tilt_series, - "source": str(self._basepath), - "recipe": "em-tomo-align", - "experiment_type": "tomography", - }, - ) - ) - else: - capture_post(url, json=data) - capture_post( - proc_url, - json={ - "tag": tilt_series, - "source": str(self._basepath), - "recipe": "em-tomo-preprocess", - "experiment_type": "tomography", - }, - ) + for recipe in ("em-tomo-preprocess", "em-tomo-align"): capture_post( proc_url, json={ "tag": tilt_series, "source": str(self._basepath), - "recipe": "em-tomo-align", + "recipe": recipe, "experiment_type": "tomography", }, ) diff --git a/src/murfey/client/instance_environment.py b/src/murfey/client/instance_environment.py index a677a20ac..1f8a642e9 100644 --- a/src/murfey/client/instance_environment.py +++ b/src/murfey/client/instance_environment.py @@ -41,7 +41,6 @@ class MurfeyInstanceEnvironment(BaseModel): destination_registry: Dict[str, str] = {} watchers: Dict[Path, DirWatcher] = {} demo: bool = False - data_collection_group_ids: Dict[str, int] = {} data_collection_parameters: dict = {} movies: Dict[Path, MovieTracker] = {} movie_tilt_pair: Dict[Path, str] = {} @@ -64,7 +63,6 @@ def clear(self): for w in self.watchers.values(): w.stop() self.watchers = {} - self.data_collection_group_ids = {} self.data_collection_parameters = {} self.movies = {} self.movie_tilt_pair = {} diff --git a/src/murfey/client/multigrid_control.py b/src/murfey/client/multigrid_control.py index 5df495814..4c963b988 100644 --- a/src/murfey/client/multigrid_control.py +++ b/src/murfey/client/multigrid_control.py @@ -369,46 +369,6 @@ def _start_dc(self, json, from_form: bool = False): ) source = Path(json["source"]) - - url = f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self.session_id}/register_data_collection_group" - dcg_data = { - "experiment_type": "tomo", - "experiment_type_id": 36, - "tag": str(source), - } - requests.post(url, json=dcg_data) - - data = { - "voltage": json["voltage"], - "pixel_size_on_image": json["pixel_size_on_image"], - "experiment_type": json["experiment_type"], - "image_size_x": json["image_size_x"], - "image_size_y": json["image_size_y"], - "file_extension": json["file_extension"], - "acquisition_software": json["acquisition_software"], - "image_directory": str(self._environment.default_destinations[source]), - "tag": json["tilt_series_tag"], - "source": str(source), - "magnification": json["magnification"], - "total_exposed_dose": json.get("total_exposed_dose"), - "c2aperture": json.get("c2aperture"), - "exposure_time": json.get("exposure_time"), - "slit_width": json.get("slit_width"), - "phase_plate": json.get("phase_plate", False), - } - capture_post( - f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self._environment.murfey_session}/start_data_collection", - json=data, - ) - for recipe in ("em-tomo-preprocess", "em-tomo-align"): - capture_post( - f"{str(self._environment.url.geturl())}/visits/{str(self._environment.visit)}/{self._environment.murfey_session}/register_processing_job", - json={ - "tag": json["tilt_series_tag"], - "source": str(source), - "recipe": recipe, - }, - ) log.info("Registering tomography processing parameters") if self._environment.data_collection_parameters.get("num_eer_frames"): eer_response = requests.post( @@ -432,8 +392,6 @@ def _start_dc(self, json, from_form: bool = False): f"{self._environment.url.geturl()}/sessions/{self._environment.murfey_session}/tomography_preprocessing_parameters", json=json, ) - context._flush_data_collections() - context._flush_processing_jobs() capture_post( f"{self._environment.url.geturl()}/visits/{self._environment.visit}/{self._environment.murfey_session}/flush_tomography_processing", json={"rsync_source": str(source)}, diff --git a/src/murfey/client/tui/app.py b/src/murfey/client/tui/app.py index 8b43cc5c7..143aedd9f 100644 --- a/src/murfey/client/tui/app.py +++ b/src/murfey/client/tui/app.py @@ -474,54 +474,6 @@ def _start_dc(self, json, from_form: bool = False): context = self.analysers[source]._context if isinstance(context, TomographyContext): source = Path(json["source"]) - url = f"{str(self._url.geturl())}/visits/{str(self._visit)}/{self._environment.murfey_session}/register_data_collection_group" - dcg_data = { - "experiment_type": "tomo", - "experiment_type_id": 36, - "tag": str(source), - "atlas": ( - str(self._environment.samples[source].atlas) - if self._environment.samples.get(source) - else "" - ), - "sample": ( - self._environment.samples[source].sample - if self._environment.samples.get(source) - else None - ), - } - capture_post(url, json=dcg_data) - data = { - "voltage": json["voltage"], - "pixel_size_on_image": json["pixel_size_on_image"], - "experiment_type": json["experiment_type"], - "image_size_x": json["image_size_x"], - "image_size_y": json["image_size_y"], - "file_extension": json["file_extension"], - "acquisition_software": json["acquisition_software"], - "image_directory": str(self._environment.default_destinations[source]), - "tag": json["tilt_series_tag"], - "source": str(source), - "magnification": json["magnification"], - "total_exposed_dose": json.get("total_exposed_dose"), - "c2aperture": json.get("c2aperture"), - "exposure_time": json.get("exposure_time"), - "slit_width": json.get("slit_width"), - "phase_plate": json.get("phase_plate", False), - } - capture_post( - f"{str(self._url.geturl())}/visits/{str(self._visit)}/{self._environment.murfey_session}/start_data_collection", - json=data, - ) - for recipe in ("em-tomo-preprocess", "em-tomo-align"): - capture_post( - f"{str(self._url.geturl())}/visits/{str(self._visit)}/{self._environment.murfey_session}/register_processing_job", - json={ - "tag": json["tilt_series_tag"], - "source": str(source), - "recipe": recipe, - }, - ) log.info("Registering tomography processing parameters") if self.app._environment.data_collection_parameters.get("num_eer_frames"): eer_response = requests.post( @@ -545,8 +497,6 @@ def _start_dc(self, json, from_form: bool = False): f"{self.app._environment.url.geturl()}/sessions/{self.app._environment.murfey_session}/tomography_preprocessing_parameters", json=json, ) - context._flush_data_collections() - context._flush_processing_jobs() capture_post( f"{self.app._environment.url.geturl()}/visits/{self._visit}/{self.app._environment.murfey_session}/flush_tomography_processing", json={"rsync_source": str(source)},