Skip to content

Commit

Permalink
Fixed tests for epic builder
Browse files Browse the repository at this point in the history
  • Loading branch information
tkakar committed Nov 5, 2024
1 parent 7628817 commit 7c94bce
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 316 deletions.
5 changes: 2 additions & 3 deletions src/portal_visualization/builder_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ def process_hints(hints):
is_json = "json_based" in hints
is_spatial = "spatial" in hints
is_support = "is_support" in hints
is_segmentation_base = "segmentation_base" in hints

return (
is_image,
Expand Down Expand Up @@ -139,6 +138,6 @@ def get_view_config_builder(entity, get_assaytype, parent=None, epic_uuid=None):
return NullViewConfBuilder


def has_visualization(entity, get_assaytype, parent=None):
builder = get_view_config_builder(entity, get_assaytype, parent, epic_uuid=None)
def has_visualization(entity, get_assaytype, parent=None, epic_uuid=None):
builder = get_view_config_builder(entity, get_assaytype, parent, epic_uuid)
return builder != NullViewConfBuilder
1 change: 0 additions & 1 deletion src/portal_visualization/builders/base_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def _get_file_paths(self):
return [file["rel_path"] for file in self._entity["files"]]



class _DocTestBuilder(ViewConfBuilder): # pragma: no cover
# The doctests on the methods in this file need a concrete class to instantiate:
# We need a concrete definition for this method, even if it's never used.
Expand Down
17 changes: 9 additions & 8 deletions src/portal_visualization/builders/epic_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from requests import get
import re
import random
from ..paths import OFFSETS_DIR, IMAGE_PYRAMID_DIR, SEGMENTATION_SUBDIR, SEGMENTATION_ZARR_STORES, SEGMENTATION_DIR

from ..paths import OFFSETS_DIR, IMAGE_PYRAMID_DIR, SEGMENTATION_SUBDIR, SEGMENTATION_ZARR_STORES, \
SEGMENTATION_DIR, SEGMENTATION_SUPPORT_IMAGE_SUBDIR

transformations_filename = 'transformations.json'
zarr_path = f'{SEGMENTATION_SUBDIR}/{SEGMENTATION_ZARR_STORES}'
Expand Down Expand Up @@ -84,20 +84,21 @@ def _apply(self, conf):
zarr_url = self.zarr_store_url()
datasets = conf.get_datasets()
file_paths_found = [file["rel_path"] for file in self._entity["files"]]

found_images = [
path for path in get_matches(
file_paths_found, IMAGE_PYRAMID_DIR + r".*\.ome\.tiff?$",
)
]
found_images = sorted(found_images)
if len(found_images) == 0: # pragma: no cover
# Remove the base-image pyramids from the found_images
filtered_strings = [img_path for img_path in found_images if SEGMENTATION_SUPPORT_IMAGE_SUBDIR not in img_path]
if len(filtered_strings) == 0: # pragma: no cover
img_url, offsets_url = None, None
message = f"Image pyramid assay with uuid {self._uuid} has no matching files"
raise FileNotFoundError(message)

elif len(found_images) >= 1:
elif len(filtered_strings) >= 1:
img_url, offsets_url = self.segmentations_ome_offset_url(
found_images[0]
filtered_strings[0]
)

segmentation_scale = self.read_segmentation_scale()
Expand Down Expand Up @@ -193,7 +194,7 @@ def create_segmentation_objects(base_url, mask_names): # pragma: no cover
else:
channelIndex = index
seg_CL = {
"spatialTargetC": channelIndex ,
"spatialTargetC": channelIndex,
"obsType": mask_name,
"spatialChannelOpacity": 1,
"spatialChannelColor": color_channel,
Expand Down
20 changes: 10 additions & 10 deletions src/vis-preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def get_assaytype(uuid):
print(f'Using: {builder.__class__.__name__}', file=stderr)
conf_cells = builder.get_conf_cells(marker=marker)

# if (epic_uuid is not None and conf_cells is not None): # pragma: no cover
# EpicBuilder = get_epic_builder(epic_uuid)
# epic_builder = EpicBuilder(epic_uuid, conf_cells, entity, args.token, args.assets_url)
# print(f'Using: {epic_builder.__class__.__name__}', file=stderr)
# conf_cells = epic_builder.get_conf_cells()
if (epic_uuid is not None and conf_cells is not None): # pragma: no cover
EpicBuilder = get_epic_builder(epic_uuid)
epic_builder = EpicBuilder(epic_uuid, conf_cells, entity, args.token, args.assets_url)
print(f'Using: {epic_builder.__class__.__name__}', file=stderr)
conf_cells = epic_builder.get_conf_cells()

if isinstance(conf_cells.conf, list):
conf_as_json = json.dumps(conf_cells.conf[0])
Expand All @@ -94,11 +94,11 @@ def get_assaytype(uuid):
print(conf_as_json)

# For testing
with open('conf.json', 'w') as file:
if isinstance(conf_cells.conf, list):
json.dump(conf_cells.conf[0], file, indent=4, separators=(',', ': '))
else:
json.dump(conf_cells.conf, file, indent=4, separators=(',', ': '))
# with open('conf.json', 'w') as file:
# if isinstance(conf_cells.conf, list):
# json.dump(conf_cells.conf[0], file, indent=4, separators=(',', ': '))
# else:
# json.dump(conf_cells.conf, file, indent=4, separators=(',', ': '))

data_url = f'data:,{quote_plus(conf_as_json)}'
vitessce_url = f'http://vitessce.io/#?url={data_url}'
Expand Down
10 changes: 0 additions & 10 deletions test/assaytype-fixtures/d58d16d515fe3237b0ca793da68a5d48.json

This file was deleted.

55 changes: 0 additions & 55 deletions test/good-fixtures/SegImagePyramidViewConfBuilder/fake-conf.json

This file was deleted.

23 changes: 0 additions & 23 deletions test/good-fixtures/SegImagePyramidViewConfBuilder/fake-entity.json

This file was deleted.

Loading

0 comments on commit 7c94bce

Please sign in to comment.