Skip to content

Commit

Permalink
post-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lmtroper committed Feb 23, 2024
1 parent 52682bd commit b5496c0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions polaris/hub/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,15 +346,15 @@ def read_zarr_file(self, owner: str, name: str, path: str, **kwargs):
"""
polaris_fs = PolarisFSFileSystem(
polaris_client=self,
polarisfs_url=str(self.base_url),
polarisfs_url=str(self.base_url),
default_expirations_seconds=10 * 60,
dataset_owner=owner,
dataset_name=name
dataset_name=name,
)

try:
store = zarr.storage.FSStore(path, fs=polaris_fs)
return zarr.open(store, mode="r")
return zarr.open(store, mode="r")
except Exception as e:
raise PolarisHubError(f"Error opening Zarr store: {e}")

Expand Down
31 changes: 18 additions & 13 deletions polaris/hub/polarisfs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Optional
from typing import Union

import fsspec
import httpx
Expand All @@ -8,6 +7,7 @@

from polaris.utils.errors import PolarisHubError


class PolarisfsSettings(BaseSettings):
url: str = "http://localhost:3000/"

Expand All @@ -19,13 +19,15 @@ class PolarisFSFileSystem(fsspec.AbstractFileSystem):
protocol = "polarisfs"
async_impl = False

def __init__(self,
polaris_client,
polarisfs_url: Optional[str],
dataset_owner: str,
dataset_name: str,
default_expirations_seconds: int = 10 * 60,
**kwargs):
def __init__(
self,
polaris_client,
polarisfs_url: Optional[str],
dataset_owner: str,
dataset_name: str,
default_expirations_seconds: int = 10 * 60,
**kwargs,
):
super().__init__(**kwargs)

if polarisfs_url is None:
Expand All @@ -35,7 +37,7 @@ def __init__(self,

self.default_expirations_seconds = default_expirations_seconds

self.polaris_client = polaris_client
self.polaris_client = polaris_client

self.http_client = httpx.Client(base_url=self.settings.url)
self.http_fs = fsspec.filesystem("http")
Expand All @@ -56,11 +58,14 @@ def ls(self, path: str, detail=False, **kwargs):
entries = [p["name"].replace(self.prefix, "") for p in response.json()]
return entries
else:
detailed_entries = [{"name": p["name"].replace(self.prefix, ""), "size": p["size"], "type": p["type"]} for p in response.json()]
detailed_entries = [
{"name": p["name"].replace(self.prefix, ""), "size": p["size"], "type": p["type"]}
for p in response.json()
]
return detailed_entries

def cat_file(self, path:str, **kwargs):
cat_path=f"{self.base_path}/{path}"
def cat_file(self, path: str, **kwargs):
cat_path = f"{self.base_path}/{path}"

# GET request to Polaris Hub for signed URL of file
response = self.polaris_client.get(cat_path, params={})
Expand All @@ -74,4 +79,4 @@ def cat_file(self, path:str, **kwargs):

storage_response = self.http_client.get(response.json()["url"], timeout=(10, 200))

return storage_response.content
return storage_response.content
6 changes: 3 additions & 3 deletions polaris/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class License(BaseModel):
Else it is required to manually specify this.
"""

SPDX_LICENSE_DATA_PATH: ClassVar[str] = (
"https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json"
)
SPDX_LICENSE_DATA_PATH: ClassVar[
str
] = "https://raw.githubusercontent.com/spdx/license-list-data/main/json/licenses.json"

id: str
reference: Optional[HttpUrlString] = None
Expand Down

0 comments on commit b5496c0

Please sign in to comment.