Skip to content

Commit

Permalink
Add properly formatted remote_uri to ZarrRemoteUri metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Oct 24, 2024
1 parent 051b867 commit 35af2aa
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions lib/galaxy/datatypes/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,24 @@ class ZarrRemoteUri(Text):
Galaxy will try to download it as a file.
"""

info = "Zarr remote URI"

MetadataElement(
name="remote_uri",
default=None,
desc="Remote URI to a Zarr store",
readonly=True,
optional=False,
visible=False,
)

def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> None:
with open(dataset.get_file_name()) as f:
uri = f.read().strip()
if "://" not in uri:
uri = f"https://{uri}"
dataset.metadata.remote_uri = uri

def sniff(self, filename: str) -> bool:
# Must have a single line and end with '.zarr'
with open(filename) as f:
Expand All @@ -1439,13 +1457,7 @@ def sniff(self, filename: str) -> bool:

def set_peek(self, dataset: DatasetProtocol, **kwd) -> None:
if not dataset.dataset.purged:
try:
with open(dataset.get_file_name()) as f:
dataset.peek = f.read().strip()
dataset.info = "Zarr remote URI"
dataset.blurb = nice_size(dataset.get_size())
except Exception:
dataset.peek = "Could not read file"
dataset.info = self.info
else:
dataset.peek = "file does not exist"
dataset.blurb = "file purged from disk"
Expand All @@ -1455,3 +1467,5 @@ class OMEZarrRemoteUri(ZarrRemoteUri):
"""OME-Zarr remote URI"""

file_ext = "ome_zarr_uri"

info = "OME-Zarr remote URI"

0 comments on commit 35af2aa

Please sign in to comment.