Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Nov 5, 2024
1 parent 9bae3bd commit 75a64b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 6 additions & 0 deletions icechunk-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ strict = true
warn_unreachable = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
"toolz.*",
]

[tool.ruff]
line-length = 90
exclude = ["*.ipynb"]
Expand Down
18 changes: 8 additions & 10 deletions icechunk-python/python/icechunk/xarray.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
#!/usr/bin/env python3
import importlib
from collections.abc import Hashable, Mapping, MutableMapping
from dataclasses import dataclass, field
from typing import Any, Literal


import numpy as np
import zarr

from icechunk import IcechunkStore
from .dask import stateful_store_reduce

from icechunk.distributed import extract_store, merge_stores
from xarray import Dataset
from xarray.backends.zarr import ZarrStore
from xarray.backends.common import ArrayWriter
from dataclasses import dataclass, field
from icechunk.distributed import extract_store, merge_stores
from xarray.backends.zarr import ZarrStore

from icechunk.dask import stateful_store_reduce

ZarrWriteModes = Literal["w", "w-", "a", "a-", "r+", "r"]

# TODO: import-time check on Xarray version
#
try:
import dask

has_dask = True
has_dask = importlib.util.find_spec("dask") is not None
except ImportError:
has_dask = False

Expand Down Expand Up @@ -179,8 +177,8 @@ def write_metadata(
``append_dim`` at the same time. To create empty arrays to fill
in with ``region``, use the `XarrayDatasetWriter` directly.
"""
from xarray.backends.zarr import _choose_default_mode
from xarray.backends.api import _validate_dataset_names, dump_to_store
from xarray.backends.zarr import _choose_default_mode

# validate Dataset keys, DataArray names
_validate_dataset_names(self.dataset)
Expand Down
3 changes: 1 addition & 2 deletions icechunk-python/tests/test_distributed_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ async def test_distributed_writers():
)
_first_snap = store.commit("array created")

with dask.config.set(scheduler=client):
store_dask(store, sources=[dask_array], targets=[zarray])
store_dask(store, sources=[dask_array], targets=[zarray])
commit_res = store.commit("distributed commit")
assert commit_res

Expand Down

0 comments on commit 75a64b6

Please sign in to comment.