Skip to content

Commit

Permalink
Cleaning up paths
Browse files Browse the repository at this point in the history
  • Loading branch information
manasaV3 committed Oct 7, 2024
1 parent 807f782 commit ca54b91
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ingestion_tools/scripts/importers/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AlignmentImporter(BaseFileImporter):
finder_factory = MultiSourceFileFinder
has_metadata = True
dir_path = "{dataset_name}/{run_name}/Alignments"
metadata_path = "{dataset_name}/{run_name}/Alignments/{alignment_id}-alignment_metadata.json"
metadata_path = os.path.join(dir_path, "{alignment_id}-alignment_metadata.json")

def __init__(self, *args, file_paths: dict[str, str], **kwargs):
super().__init__(*args, **kwargs)
Expand Down
9 changes: 4 additions & 5 deletions ingestion_tools/scripts/importers/tomogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ def get_alignment_metadata_path(self) -> str:

for alignment in AlignmentImporter.finder(self.config, **self.parents):
return alignment.get_metadata_path()
# TODO: This should be an error, but we need to fix the data first.
# TODO: As all tomograms need to be associated to an alignment this should be an error, but we need to fix the
# data first.
return None

def get_neuroglancer_config_path(self) -> str:
def get_neuroglancer_config_path(self) -> str | None:
if self.metadata.get("is_visualization_default"):
# TODO: Refactor this to a method in the viz_config importer with identifier in the name
return self.config.resolve_output_path("viz_config", self).format(identifier=self.identifier)

return self.config.resolve_output_path("viz_config", self)
return None

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion ingestion_tools/scripts/importers/visualization_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class VisualizationConfigImporter(BaseImporter):
has_metadata = False
dir_path = (
"{dataset_name}/{run_name}/Reconstructions/VoxelSpacing{voxel_spacing_name}/NeuroglancerPrecompute/"
"{{identifier}}-neuroglancer_config.json"
"{tomogram_id}-neuroglancer_config.json"
)

def import_item(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions ingestion_tools/scripts/tests/fixtures/dataset1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ tomograms:
processing: raw
reconstruction_method: WBP
reconstruction_software: IMOD
is_visualization_default: true
tomogram_version: 1
sources:
- source_glob:
Expand Down
12 changes: 11 additions & 1 deletion ingestion_tools/scripts/tests/s3_import/test_tomograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,26 @@ def test_tomogram_import_metadata(
item.import_metadata()
run_name = parents["run"].name
voxel_spacing = 13.48
prefix = f"output/{parents['dataset'].name}/{run_name}/Reconstructions/VoxelSpacing{voxel_spacing:.3f}/Tomograms"
run_path = f"output/{parents['dataset'].name}/{run_name}"
vs_path = f"{run_path}/Reconstructions/VoxelSpacing{voxel_spacing:.3f}"
prefix = f"{vs_path}/Tomograms"
tomogram_files = get_children(s3_client, test_output_bucket, prefix)
id_prefix = 100
assert f"{id_prefix}-tomogram_metadata.json" in tomogram_files
image_path = f"{parents['dataset'].name}/{run_name}/Reconstructions/VoxelSpacing{voxel_spacing:.3f}/Images/{id_prefix}-key-photo-"
expected = {
"omezarr_dir": f"{id_prefix}-{run_name}.zarr",
"mrc_files": [f"{id_prefix}-{run_name}.mrc"],
"voxel_spacing": 13.48,
"scales": [{"x": 6, "y": 8, "z": 10}, {"x": 3, "y": 4, "z": 5}, {"x": 2, "y": 2, "z": 3}],
"size": {"x": 6, "y": 8, "z": 10},
"alignment_metadata_path": f"{test_output_bucket}/{run_path}/Alignments/100-alignment_metadata.json",
"neuroglancer_config_path": f"{test_output_bucket}/{vs_path}/NeuroglancerPrecompute/"
f"{id_prefix}-neuroglancer_config.json",
"key_photo": {
"snapshot": f"{image_path}snapshot.png",
"thumbnail": f"{image_path}thumbnail.png",
},
}
validate_metadata(expected, prefix, id_prefix)

Expand Down

0 comments on commit ca54b91

Please sign in to comment.