Skip to content

Commit

Permalink
remove python 3.7 support (#120)
Browse files Browse the repository at this point in the history
* remove python 3.7 support

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
rabernat and pre-commit-ci[bot] authored Jul 8, 2022
1 parent 99f8bad commit 9d12932
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 33 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -41,14 +41,3 @@ jobs:
- name: Test with pytest
run: |
py.test tests -v
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Run pre-commit
uses: pre-commit/action@v2.0.0
2 changes: 1 addition & 1 deletion rechunker/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def _zarr_empty(shape, store_or_group, chunks, dtype, name=None, **kwargs):
"cache_metadata",
"cache_attrs",
"overwrite",
"write_empty_chunks"
"write_empty_chunks",
]


Expand Down
3 changes: 2 additions & 1 deletion rechunker/executors/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def expand(self, pcoll):


def _start_stage(
target_id: str, specs_by_target: Mapping[str, DirectCopySpec],
target_id: str,
specs_by_target: Mapping[str, DirectCopySpec],
) -> Iterator[Tuple[str, DirectCopySpec]]:
spec = specs_by_target.get(target_id)
if spec is not None:
Expand Down
18 changes: 15 additions & 3 deletions rechunker/executors/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@ class DirectCopySpec(NamedTuple):
def split_into_direct_copies(spec: CopySpec) -> Tuple[DirectCopySpec, ...]:
"""Convert a rechunked copy into a list of direct copies."""
if spec.intermediate.array is None:
return (DirectCopySpec(spec.read.array, spec.write.array, spec.read.chunks,),)
return (
DirectCopySpec(
spec.read.array,
spec.write.array,
spec.read.chunks,
),
)
else:
return (
DirectCopySpec(spec.read.array, spec.intermediate.array, spec.read.chunks,),
DirectCopySpec(
spec.intermediate.array, spec.write.array, spec.write.chunks,
spec.read.array,
spec.intermediate.array,
spec.read.chunks,
),
DirectCopySpec(
spec.intermediate.array,
spec.write.array,
spec.write.chunks,
),
)
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@
"Topic :: Database",
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
packages=find_packages(exclude=["docs", "tests", "tests.*", "docs.*"]),
install_requires=install_requires,
extras_require=extras_require,
python_requires=">=3.7",
python_requires=">=3.8",
long_description=long_description,
long_description_content_type="text/markdown",
setup_requires="setuptools_scm",
Expand Down
29 changes: 24 additions & 5 deletions tests/test_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,22 @@ def test_consolidate_chunks_limit_error(shape, chunks, itemsize, max_mem, chunk_


@pytest.mark.parametrize(
"shape", [(1000, 50, 1800, 3600),],
"shape",
[
(1000, 50, 1800, 3600),
],
)
@pytest.mark.parametrize(
"chunks", [(1, 5, 1800, 3600),],
"chunks",
[
(1, 5, 1800, 3600),
],
)
@pytest.mark.parametrize(
"itemsize", [4,],
"itemsize",
[
4,
],
)
@pytest.mark.parametrize(
"max_mem, expected",
Expand Down Expand Up @@ -265,11 +274,21 @@ def test_intermediate_to_target_memory():
max_mem = 12000000000 # 12 GB

read_chunks, int_chunks, write_chunks = rechunking_plan(
shape, source_chunks, target_chunks, itemsize, max_mem, consolidate_reads=True,
shape,
source_chunks,
target_chunks,
itemsize,
max_mem,
consolidate_reads=True,
)

read_chunks2, int_chunks2, write_chunks2 = rechunking_plan(
shape, int_chunks, target_chunks, itemsize, max_mem, consolidate_reads=True,
shape,
int_chunks,
target_chunks,
itemsize,
max_mem,
consolidate_reads=True,
)

assert read_chunks2 == int_chunks2 == write_chunks2
66 changes: 57 additions & 9 deletions tests/test_rechunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ def chunk_ds():
numpy.random.randint(0, 101, (len(lon), len(lat), len(time))),
)
),
coords=dict(lon=lon, lat=lat, time=time,),
coords=dict(
lon=lon,
lat=lat,
time=time,
),
)
return ds

Expand Down Expand Up @@ -144,9 +148,27 @@ def test_parse_target_chunks_from_dim_chunks(
@pytest.mark.parametrize(
"dask_chunks, dim, target_chunks, expected",
[
pytest.param(None, "lon", dict(lon=10), 10, id="small lon chunks numpy array",),
pytest.param(None, "lon", dict(lon=10), 10, id="small lon chunks dask array",),
pytest.param(None, "time", dict(time=400), 365, id="time chunks exceed len",),
pytest.param(
None,
"lon",
dict(lon=10),
10,
id="small lon chunks numpy array",
),
pytest.param(
None,
"lon",
dict(lon=10),
10,
id="small lon chunks dask array",
),
pytest.param(
None,
"time",
dict(time=400),
365,
id="time chunks exceed len",
),
pytest.param(
{"time": 1},
"time",
Expand Down Expand Up @@ -245,7 +267,11 @@ def test_rechunk_dataset(
)
@pytest.mark.parametrize("max_mem", ["10MB"])
def test_rechunk_dataset_dimchunks(
tmp_path, shape, source_chunks, target_chunks, max_mem,
tmp_path,
shape,
source_chunks,
target_chunks,
max_mem,
):
temp_store = "temp.zarr"
target_store = "target.zarr"
Expand Down Expand Up @@ -297,7 +323,13 @@ def test_rechunk_dataset_dimchunks(
@pytest.mark.parametrize("dtype", ["f4"])
@pytest.mark.parametrize("max_mem", [25600000, "25.6MB"])
@pytest.mark.parametrize(
"executor", ["dask", "python", requires_beam("beam"), requires_prefect("prefect"),],
"executor",
[
"dask",
"python",
requires_beam("beam"),
requires_prefect("prefect"),
],
)
@pytest.mark.parametrize(
"dims,target_chunks",
Expand Down Expand Up @@ -361,7 +393,13 @@ def test_rechunk_array(
@pytest.mark.parametrize("dtype", ["f4"])
@pytest.mark.parametrize("max_mem", [25600000])
@pytest.mark.parametrize(
"target_chunks", [(200, 8000), (800, 8000), (8000, 200), (400, 8000),],
"target_chunks",
[
(200, 8000),
(800, 8000),
(8000, 200),
(400, 8000),
],
)
def test_rechunk_dask_array(
tmp_path, shape, source_chunks, dtype, target_chunks, max_mem
Expand Down Expand Up @@ -390,7 +428,13 @@ def test_rechunk_dask_array(


@pytest.mark.parametrize(
"executor", ["dask", "python", requires_beam("beam"), requires_prefect("prefect"),],
"executor",
[
"dask",
"python",
requires_beam("beam"),
requires_prefect("prefect"),
],
)
@pytest.mark.parametrize("source_store", ["source.zarr", "mapper.source.zarr"])
@pytest.mark.parametrize("target_store", ["target.zarr", "mapper.target.zarr"])
Expand Down Expand Up @@ -509,7 +553,11 @@ def rechunk_args(tmp_path, request):
target_chunks = (8000, 200)

args.update(
{"source": array, "target_chunks": target_chunks, "max_mem": max_mem,}
{
"source": array,
"target_chunks": target_chunks,
"max_mem": max_mem,
}
)
return args

Expand Down

0 comments on commit 9d12932

Please sign in to comment.