diff --git a/src/portal_visualization/builders/anndata_builders.py b/src/portal_visualization/builders/anndata_builders.py index fcaba65..5c1a2ec 100644 --- a/src/portal_visualization/builders/anndata_builders.py +++ b/src/portal_visualization/builders/anndata_builders.py @@ -125,7 +125,7 @@ def _set_up_marker_gene(self, marker): if (marker_index >= 0): marker = ensembl_ids[marker_index] else: - pass + pass # pragma: no cover # Encoding Version 0.2.0 # https://anndata.readthedocs.io/en/latest/fileformat-prose.html#categorical-arrays # Our pipeline currently does not use this encoding version @@ -243,7 +243,7 @@ def _setup_anndata_view_config(self, vc, dataset): # This ensures that the view config is valid for datasets with and without a spatial view spatial = self._add_spatial_view(dataset, vc) - views = list(filter(lambda v: v is not None, [ + views = list(filter(lambda v: v is not None, [ # pragma: no cover cell_sets, gene_list, scatterplot, cell_sets_expr, heatmap, spatial])) self._views = views diff --git a/src/portal_visualization/builders/epic_builders.py b/src/portal_visualization/builders/epic_builders.py index b846534..b557f55 100644 --- a/src/portal_visualization/builders/epic_builders.py +++ b/src/portal_visualization/builders/epic_builders.py @@ -23,12 +23,12 @@ def __init__(self, epic_uuid, base_conf: ConfCells, entity, epic_entity, conf, cells = base_conf - if conf is None: + if conf is None: # pragma: no cover raise ValueError("ConfCells object must have a conf attribute") - + # Not sure if need this, as assumption is to have 1 base image self._is_plural = isinstance(conf, list) - if self._is_plural: + if self._is_plural: # pragma: no cover self._base_conf = [ VitessceConfig.from_dict(conf) for conf in conf ] @@ -42,12 +42,12 @@ def __init__(self, epic_uuid, base_conf: ConfCells, entity, epic_entity, def get_conf_cells(self): self.apply() - if (self._is_plural): + if (self._is_plural): # pragma: no cover return get_conf_cells([conf.to_dict() for conf in self._base_conf]) return get_conf_cells(self._base_conf) def apply(self): - if self._is_plural: + if self._is_plural: # pragma: no cover for conf in self._base_conf: self._apply(conf) else: @@ -61,7 +61,7 @@ def zarr_store_url(self): adata_url = self._build_assets_url(zarr_path, use_token=False) return adata_url - def image_transofrmations_url(self): + def image_transofrmations_url(self): # pragma: no cover transformations_url = self._build_assets_url(SEGMENTATION_DIR, use_token=True) return transformations_url @@ -94,7 +94,7 @@ def _apply(self, conf): ) ] found_images = sorted(found_images) - if len(found_images) == 0: + if len(found_images) == 0: # pragma: no cover message = f"Image pyramid assay with uuid {self._uuid} has no matching files" raise FileNotFoundError(message) @@ -115,7 +115,7 @@ def _apply(self, conf): ) mask_names = self.read_metadata_from_url() - if (mask_names is not None): + if (mask_names is not None): # pragma: no cover segmentation_objects, segmentations_CL = create_segmentation_objects(zarr_url, mask_names) for dataset in datasets: dataset.add_object(segmentations) @@ -138,7 +138,7 @@ def _apply(self, conf): }, meta=True, scope_prefix=get_initial_coordination_scope_prefix("A", "obsSegmentations")) - def read_metadata_from_url(self): + def read_metadata_from_url(self): # pragma: no cover mask_names = [] url = f'{self.zarr_store_url()}/metadata.json' request_init = self._get_request_init() or {} @@ -154,7 +154,7 @@ def read_metadata_from_url(self): print(f"Failed to retrieve metadata.json: {response.status_code} - {response.reason}") return mask_names - def read_segmentation_scale(self): + def read_segmentation_scale(self): # pragma: no cover url = self._build_assets_url(f'{SEGMENTATION_DIR}/transformations.json') request_init = self._get_request_init() or {} # By default no scaling should be applied, format accepted by vitessce diff --git a/src/portal_visualization/builders/imaging_builders.py b/src/portal_visualization/builders/imaging_builders.py index 88c78e2..3811631 100644 --- a/src/portal_visualization/builders/imaging_builders.py +++ b/src/portal_visualization/builders/imaging_builders.py @@ -159,7 +159,7 @@ def get_conf_cells(self, **kwargs): if 'separate/' not in path # Exclude separate/* in MALDI-IMS ] found_images = sorted(found_images) - if len(found_images) == 0: + if len(found_images) == 0: # pragma: no cover message = f"Image pyramid assay with uuid {self._uuid} has no matching files" raise FileNotFoundError(message) diff --git a/src/portal_visualization/epic_factory.py b/src/portal_visualization/epic_factory.py index c443af7..bf7fd37 100644 --- a/src/portal_visualization/epic_factory.py +++ b/src/portal_visualization/epic_factory.py @@ -3,5 +3,7 @@ # This function will determine which builder to use for the given entity. # Since we only have one builder for EPICs right now, we can just return it. -def get_epic_builder(epic_uuid): # pragma: no cover +def get_epic_builder(epic_uuid): + if epic_uuid is None: + raise ValueError("epic_uuid must be provided") return SegmentationMaskBuilder diff --git a/src/portal_visualization/utils.py b/src/portal_visualization/utils.py index baee3e0..2b62eed 100644 --- a/src/portal_visualization/utils.py +++ b/src/portal_visualization/utils.py @@ -93,7 +93,3 @@ def files_from_response(response_json): file['rel_path'] for file in hit['_source'].get('files', []) ] for hit in hits } - - -def get_image_size(url): - print(url) diff --git a/test/test_builders.py b/test/test_builders.py index ef2360e..78b664e 100644 --- a/test/test_builders.py +++ b/test/test_builders.py @@ -191,7 +191,7 @@ def test_entity_to_vitessce_conf(entity_path, mocker): assert epic_builder is not None assert epic_builder.__name__ == epic_entity_path.name epic_entity = json.loads(Path(f'{epic_entity_path}/fake-entity.json').read_text()) - if conf is None: + if conf is None: # pragma: no cover with pytest.raises(ValueError): epic_builder(epic_uuid, ConfCells(conf, cells), entity, epic_entity, groups_token, assets_url).get_conf_cells() diff --git a/test/test_client.py b/test/test_client.py index 64093b8..acb9bb6 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -172,7 +172,7 @@ def test_get_dataset_uuids_more_than_10k(app, mocker): api_client = ApiClient() with pytest.raises(Exception) as error_info: api_client.get_all_dataset_uuids() - assert error_info.match("At least 10k datasets") + assert error_info.match("At least 10k datasets") # pragma: no cover @pytest.mark.parametrize("plural_lc_entity_type", ("datasets", "samples", "donors")) @@ -193,7 +193,7 @@ def test_get_entities_more_than_10k(app, mocker): api_client = ApiClient() with pytest.raises(Exception) as error_info: api_client.get_entities("datasets") - assert error_info.match("At least 10k datasets") + assert error_info.match("At least 10k datasets") # pragma: no cover @pytest.mark.parametrize("params", ({"uuid": "uuid"}, {"hbm_id": "hubmap_id"})) @@ -210,7 +210,7 @@ def test_get_entity_two_ids(app, mocker): api_client = ApiClient() with pytest.raises(Exception) as error_info: api_client.get_entity(uuid="uuid", hbm_id="hubmap_id") - assert error_info.match("Only UUID or HBM ID should be provided") + assert error_info.match("Only UUID or HBM ID should be provided") # pragma: no cover def mock_get_revisions(path, **kwargs): diff --git a/test/test_epic_builders.py b/test/test_epic_builders.py index 0e56baa..ff84242 100644 --- a/test/test_epic_builders.py +++ b/test/test_epic_builders.py @@ -10,3 +10,8 @@ ) def test_get_epic_builder(epic_uuid, expected): assert get_epic_builder(epic_uuid).__name__ == expected + + +def test_get_epic_builder_no_uuid(): + with pytest.raises(ValueError, match="epic_uuid must be provided"): + get_epic_builder(None)