Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install dask[dataframe] explicitly to fix upstream error #1261

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/scripts/upstream_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def install_deps() -> None:
"--upgrade",
)
upstream_deps = (
"git+https://github.com/dask/dask.git#egg=dask[array]",
"git+https://github.com/dask/dask.git#egg=dask[array,dataframe]",
"git+https://github.com/dask/distributed.git#egg=distributed",
"git+https://github.com/dask/dask-ml.git#egg=dask-ml",
"git+https://github.com/pandas-dev/pandas#egg=pandas",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Upstream

on:
pull_request:
push:
schedule:
- cron: "0 1 * * *"
Expand All @@ -14,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions requirements-numpy2.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy < 2.1
xarray
dask[array] >= 2023.01.0, <= 2024.8.0
distributed >= 2023.01.0, <= 2024.8.0
dask[array] >= 2023.01.0, != 2024.8.1, != 2024.9.*
distributed >= 2023.01.0, != 2024.8.1, != 2024.9.*
dask-ml
scipy
typing-extensions
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy < 2
xarray
dask[array] >= 2023.01.0, <= 2024.8.0
distributed >= 2023.01.0, <= 2024.8.0
dask[array,dataframe] >= 2023.01.0, != 2024.8.1, != 2024.9.*
distributed >= 2023.01.0, != 2024.8.1, != 2024.9.*
dask-ml
scipy
typing-extensions
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ python_requires = >=3.9
install_requires =
numpy < 2
xarray
dask[array] >= 2022.01.0, <= 2024.8.0
distributed >= 2022.01.0, <= 2024.8.0
dask[array,dataframe] >= 2022.01.0, != 2024.8.1, != 2024.9.*
distributed >= 2022.01.0, != 2024.8.1, != 2024.9.*
dask-ml
scipy
zarr >= 2.10.0, != 2.11.0, != 2.11.1, != 2.11.2, < 3
Expand Down
8 changes: 4 additions & 4 deletions sgkit/stats/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def variant_stats(
--------
:func:`count_variant_genotypes`
"""
from .aggregation_numba_fns import count_hom
from .aggregation_numba_fns import count_hom_new_axis

variables.validate(ds, {call_genotype: variables.call_genotype_spec})
mixed_ploidy = ds[call_genotype].attrs.get("mixed_ploidy", False)
Expand All @@ -697,7 +697,7 @@ def variant_stats(
G = da.asarray(ds[call_genotype].data)
H = xr.DataArray(
da.map_blocks(
lambda *args: count_hom(*args)[:, np.newaxis, :],
count_hom_new_axis,
G,
np.zeros(3, np.uint64),
drop_axis=2,
Expand Down Expand Up @@ -796,7 +796,7 @@ def sample_stats(
ValueError
If the dataset contains mixed-ploidy genotype calls.
"""
from .aggregation_numba_fns import count_hom
from .aggregation_numba_fns import count_hom_new_axis

variables.validate(ds, {call_genotype: variables.call_genotype_spec})
mixed_ploidy = ds[call_genotype].attrs.get("mixed_ploidy", False)
Expand All @@ -805,7 +805,7 @@ def sample_stats(
GT = da.asarray(ds[call_genotype].transpose("samples", "variants", "ploidy").data)
H = xr.DataArray(
da.map_blocks(
lambda *args: count_hom(*args)[:, np.newaxis, :],
count_hom_new_axis,
GT,
np.zeros(3, np.uint64),
drop_axis=2,
Expand Down
6 changes: 6 additions & 0 deletions sgkit/stats/aggregation_numba_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# in a separate file here, and imported dynamically to avoid
# initial compilation overhead.

import numpy as np

from sgkit.accelerate import numba_guvectorize, numba_jit
from sgkit.typing import ArrayLike

Expand Down Expand Up @@ -102,3 +104,7 @@ def count_hom(
index = _classify_hom(genotypes[i])
if index >= 0:
out[index] += 1


def count_hom_new_axis(genotypes: ArrayLike, _: ArrayLike) -> ArrayLike:
return count_hom(genotypes, _)[:, np.newaxis, :]
4 changes: 1 addition & 3 deletions sgkit/stats/popgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,7 @@ def pbs(
cohorts = cohorts or list(itertools.combinations(range(n_cohorts), 3)) # type: ignore
ct = _cohorts_to_array(cohorts, ds.indexes.get("cohorts_0", None))

p = da.map_blocks(
lambda t: _pbs_cohorts(t, ct), t, chunks=shape, new_axis=3, dtype=np.float64
)
p = da.map_blocks(_pbs_cohorts, t, ct, chunks=shape, new_axis=3, dtype=np.float64)
assert_array_shape(p, n_windows, n_cohorts, n_cohorts, n_cohorts)

new_ds = create_dataset(
Expand Down
Loading