Skip to content

Commit

Permalink
chore: Handle no neuroglancer config file (#339)
Browse files Browse the repository at this point in the history
* Handle no neuroglancer config file

* Handling for api v2

* Fix tests
  • Loading branch information
manasaV3 authored Nov 4, 2024
1 parent 6960d82 commit 4b46376
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion apiv2/db_import/importers/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class TomogramItem(ItemDBImporter):
def normalize_to_unknown_str(self, value: str) -> str:
return value.replace(" ", "_") if value else "Unknown"

def generate_neuroglancer_data(self, path) -> str:
def generate_neuroglancer_data(self, path) -> str | None:
if not path:
# Handle the case where there is no neuroglancer config file specified which is expected when
# visualization_default is set to False.
return None
config = self.config.load_key_json(path, is_file_required=False)
# TODO: Log warning
return json.dumps(config, separators=(",", ":")) if config else "{}"
Expand Down
6 changes: 4 additions & 2 deletions ingestion_tools/scripts/importers/db/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ def get_tomogram_type(self) -> str:
return "CANONICAL"
return "UNKOWN" # TYPO that's also reflected in the db :'(

def generate_neuroglancer_data(self, config_path) -> str:
def generate_neuroglancer_data(self, config_path) -> str | None:
if not config_path:
return "{}"
# Handle the case where there is no neuroglancer config file specified, which is expected when
# visualization_default is set to False.
return None
config = self.config.load_key_json(config_path, is_file_required=True)
# TODO: Log warning
return json.dumps(config, separators=(",", ":")) if config else "{}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def expected_tomograms_by_run(http_prefix: str) -> dict[str, dict[float, list[di
"offset_x": 0,
"offset_y": 0,
"offset_z": 0,
"neuroglancer_config": "{}",
"neuroglancer_config": None,
"type": "CANONICAL",
"deposition_id": 300,
}
Expand Down

0 comments on commit 4b46376

Please sign in to comment.