Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
keller-mark committed Oct 4, 2024
1 parent de5066e commit d7f010d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
3 changes: 3 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
class MockArtifactPath:
def __init__(self, url):
self.url = url

def to_url(self):
return self.url


class MockArtifact:
def __init__(self, name, url):
self.name = name
Expand Down Expand Up @@ -167,6 +169,7 @@ def test_config_add_anndata_artifact():
assert list(vc_artifacts.keys()) == ["http://example.com/adata.h5ad.zarr"]
assert vc_artifacts["http://example.com/adata.h5ad.zarr"].name == "My anndata artifact"


def test_config_add_dataset_add_files():
vc = VitessceConfig(schema_version="1.0.15")
vc.add_dataset(name='My Chained Dataset').add_file(
Expand Down
4 changes: 2 additions & 2 deletions vitessce/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def get_routes(self):
routes += obj.get_routes()

return routes

def get_artifacts(self):
artifacts = {}
for obj in self.objs:
Expand Down Expand Up @@ -1596,7 +1596,7 @@ def get_routes(self):
for d in self.config["datasets"]:
routes += d.get_routes()
return routes

def get_artifacts(self):
"""
Get all artifacts for this view config from the datasets.
Expand Down
22 changes: 10 additions & 12 deletions vitessce/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_routes(self):
:rtype: list[starlette.routing.Route]
"""
return self.routes

def register_artifact(self, artifact):
"""
Register an artifact.
Expand All @@ -88,7 +88,6 @@ def register_artifact(self, artifact):
self.artifacts[artifact_url] = artifact
return artifact_url


def get_artifacts(self):
"""
Obtain the dictionary that maps artifact URLs to artifact objects.
Expand Down Expand Up @@ -448,7 +447,7 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, offsets_path=
if num_inputs != 1:
raise ValueError(
"Expected one of img_path, img_url, or img_artifact to be provided")

num_inputs = sum([1 for x in [offsets_path, offsets_url, offsets_artifact] if x is not None])
if num_inputs > 1:
raise ValueError(
Expand All @@ -465,14 +464,13 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, offsets_path=
self.is_remote = img_url is not None
self.local_img_uid = make_unique_filename(".ome.tif")
self.local_offsets_uid = make_unique_filename(".offsets.json")

if img_artifact is not None:
self._img_url = self.register_artifact(img_artifact)

if offsets_artifact is not None:
self._offsets_url = self.register_artifact(offsets_artifact)


def convert_and_save(self, dataset_uid, obj_i, base_dir=None):
# Only create out-directory if needed
if not self.is_remote:
Expand Down Expand Up @@ -581,7 +579,7 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, offsets_path=
if num_inputs != 1:
raise ValueError(
"Expected one of img_path, img_url, or img_artifact to be provided")

num_inputs = sum([1 for x in [offsets_path, offsets_url, offsets_artifact] if x is not None])
if num_inputs > 1:
raise ValueError(
Expand All @@ -599,7 +597,7 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, offsets_path=
self.is_remote = img_url is not None
self.local_img_uid = make_unique_filename(".ome.tif")
self.local_offsets_uid = make_unique_filename(".offsets.json")

if img_artifact is not None:
self._img_url = self.register_artifact(img_artifact)

Expand Down Expand Up @@ -883,7 +881,7 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, coordinate_tr
if num_inputs != 1:
raise ValueError(
"Expected one of img_path, img_url, or img_artifact to be provided")

self._img_path = img_path
self._img_url = img_url
self._img_artifact = img_artifact
Expand All @@ -893,11 +891,11 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, coordinate_tr
self.is_remote = False
else:
self.is_remote = True

if self._img_artifact is not None:
# To serve as a placeholder in the config JSON URL field
self._img_url = self.register_artifact(img_artifact)

self.local_dir_uid = make_unique_filename(".ome.zarr")

def convert_and_save(self, dataset_uid, obj_i, base_dir=None):
Expand Down Expand Up @@ -976,7 +974,7 @@ def __init__(self, img_path=None, img_url=None, img_artifact=None, coordinate_tr
self.is_remote = False
else:
self.is_remote = True

if self._img_artifact is not None:
# To serve as a placeholder in the config JSON URL field
self._img_url = self.register_artifact(img_artifact)
Expand Down Expand Up @@ -1095,7 +1093,7 @@ def __init__(self, adata_path=None, adata_url=None, adata_store=None, adata_arti
self.is_remote = True
self.is_store = False
self.zarr_folder = None

# Store artifacts on AbstractWrapper.artifacts for downstream access,
# e.g. in lamindb.save_vitessce_config
if adata_artifact is not None:
Expand Down

0 comments on commit d7f010d

Please sign in to comment.