Skip to content

Commit

Permalink
ENH: add from_assets constructor for Adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
genematx committed Nov 7, 2024
1 parent 9c6ade4 commit bfce5ff
Show file tree
Hide file tree
Showing 21 changed files with 357 additions and 427 deletions.
2 changes: 1 addition & 1 deletion docs/source/reference/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ or its dask counterpart.
.. autosummary::
:toctree: generated
tiled.adapters.csv.read_csv
tiled.adapters.csv.CSVAdapter
tiled.adapters.excel.ExcelAdapter
tiled.adapters.hdf5.HDF5Adapter
tiled.adapters.netcdf.read_netcdf
Expand Down
77 changes: 0 additions & 77 deletions scripts/mongo_migration/load.py

This file was deleted.

4 changes: 2 additions & 2 deletions tiled/_tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import tifffile
import xarray

from ..adapters.csv import read_csv
from ..adapters.csv import CSVAdapter
from ..adapters.dataframe import ArrayAdapter
from ..adapters.tiff import TiffAdapter
from ..catalog import in_memory
Expand Down Expand Up @@ -236,7 +236,7 @@ async def test_write_dataframe_external_direct(a, tmpdir):
filepath = str(tmpdir / "file.csv")
data_uri = ensure_uri(filepath)
df.to_csv(filepath, index=False)
dfa = read_csv(data_uri)
dfa = CSVAdapter.from_uris(data_uri)
structure = asdict(dfa.structure())
await a.create_node(
key="x",
Expand Down
2 changes: 1 addition & 1 deletion tiled/_tests/test_jpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def client(tmpdir_module):

tree = MapAdapter(
{
"color": JPEGAdapter(ensure_uri(path)),
"color": JPEGAdapter.from_uris(ensure_uri(path)),
"sequence": JPEGSequenceAdapter.from_uris(
[ensure_uri(filepath) for filepath in filepaths]
),
Expand Down
244 changes: 0 additions & 244 deletions tiled/adapters/_zoo.py

This file was deleted.

13 changes: 13 additions & 0 deletions tiled/adapters/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ def __init__(
self.specs = list(specs or [])
self.access_policy = access_policy

@classmethod
def from_assets(
cls,
assets: List[Asset],
structure: TableStructure,
metadata: Optional[JSON] = None,
specs: Optional[List[Spec]] = None,
access_policy: Optional[AccessPolicy] = None,
**kwargs: Optional[Union[str, List[str], Dict[str, str]]],
) -> "ArrowAdapter":
data_uris = [a.data_uri for a in assets]
return cls(data_uris, structure, metadata, specs, access_policy)

def metadata(self) -> JSON:
"""
Expand Down
Loading

0 comments on commit bfce5ff

Please sign in to comment.