diff --git a/src/murfey/client/context.py b/src/murfey/client/context.py index f17398909..3be79cd77 100644 --- a/src/murfey/client/context.py +++ b/src/murfey/client/context.py @@ -89,9 +89,18 @@ def ensure_dcg_exists( if not windows_path: logger.warning("No atlas metadata path found") return None - visit_index = windows_path.split("\\").index(environment.visit) - partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :]) - logger.info("Partial Linux path successfully constructed from Windows path") + if environment.visit in windows_path.split("\\"): + # Case of atlas in the correct location + visit_index = windows_path.split("\\").index(environment.visit) + partial_path = "/".join(windows_path.split("\\")[visit_index + 1 :]) + logger.info( + f"Partial Linux path successfully constructed from Windows path: {partial_path}" + ) + else: + # Atlas not in visit, so come up with where it should have been + # Assumes /structure/to/Supervisor/Sample/Atlas/Atlas.dm + partial_path = "atlas/" + "/".join(windows_path.split("\\")[-4:]) + logger.info(f"Partial Linux path estimated: {partial_path}") logger.info( f"Looking for atlas XML file in metadata directory {str((source_visit_dir / partial_path).parent)}" diff --git a/src/murfey/client/multigrid_control.py b/src/murfey/client/multigrid_control.py index bfe4372ae..173e49273 100644 --- a/src/murfey/client/multigrid_control.py +++ b/src/murfey/client/multigrid_control.py @@ -566,12 +566,15 @@ def _start_dc(self, metadata_json): + "/".join(source.parts[-2:]) ) metadata_source = Path(metadata_source_as_str.replace("//", "/")) - ensure_dcg_exists( - collection_type="spa", - metadata_source=metadata_source, - environment=self._environment, - token=self.token, - ) + try: + ensure_dcg_exists( + collection_type="spa", + metadata_source=metadata_source, + environment=self._environment, + token=self.token, + ) + except Exception as e: + log.error(f"Failed to register data collection group: {e}") data = { "voltage": metadata_json["voltage"], "pixel_size_on_image": metadata_json["pixel_size_on_image"],