Skip to content

Commit c4e3c9b

Browse files
authored
Merge pull request #120 from MannLabs/make-dask-optional
Make dask optional
2 parents 8c938c7 + 8d825cb commit c4e3c9b

18 files changed

Lines changed: 44 additions & 21 deletions

.binder/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ COPY LICENSE LICENSE
2727
COPY README.md README.md
2828
COPY pyproject.toml pyproject.toml
2929

30-
RUN pip install ".[stable]"
30+
RUN pip install ".[stable,dask-stable]"
3131

3232
# change owner to be able to write to that folder
3333
COPY --chown=${USER}:${USER} example_nbs example_nbs

.github/workflows/e2e_tests_quick.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
os: ${{ matrix.os }}
31-
install-script: ./pip_install.sh tests,gui
31+
install-script: ./pip_install.sh tests,gui,dask
3232
test-script: ./run_e2e_tests_quick.sh

.github/workflows/e2e_tests_quick_multiple_platforms.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
python-version: ${{ matrix.python-version }}
3131
os: ${{ matrix.os }}
32-
install-script: ./pip_install.sh stable,tests,gui
32+
install-script: ./pip_install.sh stable,tests,gui,dask-stable
3333
test-script: ./run_e2e_tests_quick.sh
3434

3535
run-unit-tests-loose:
@@ -43,5 +43,5 @@ jobs:
4343
with:
4444
python-version: ${{ matrix.python-version }}
4545
os: ${{ matrix.os }}
46-
install-script: ./pip_install.sh tests,gui
46+
install-script: ./pip_install.sh tests,gui,dask
4747
test-script: ./run_e2e_tests_quick.sh

.github/workflows/install_and_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ jobs:
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232
os: ${{ matrix.os }}
33-
install-script: ./pip_install.sh tests,gui
33+
install-script: ./pip_install.sh tests,gui,dask
3434
test-script: ./run_unit_tests.sh

.github/workflows/install_and_unit_tests_multiple_platforms.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
os: ${{ matrix.os }}
29-
install-script: ./pip_install.sh stable,tests,gui
29+
install-script: ./pip_install.sh stable,tests,gui,dask-stable
3030
test-script: ./run_unit_tests.sh
3131

3232
run-unit-tests-loose:
@@ -40,5 +40,5 @@ jobs:
4040
with:
4141
python-version: ${{ matrix.python-version }}
4242
os: ${{ matrix.os }}
43-
install-script: ./pip_install.sh tests,gui
43+
install-script: ./pip_install.sh tests,gui,dask
4444
test-script: ./run_unit_tests.sh

.github/workflows/run_example_nbs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030
os: ${{ matrix.os }}
31-
install-script: ./pip_install.sh tests,gui
31+
install-script: ./pip_install.sh tests,gui,dask
3232
test-script: ./run_example_notebooks.sh

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ COPY LICENSE LICENSE
2020
COPY README.md README.md
2121
COPY pyproject.toml pyproject.toml
2222

23-
RUN pip install ".[stable,gui-stable]"
23+
RUN pip install ".[stable,gui-stable,dask-stable]"
2424

2525
ENV PORT=41215
2626
EXPOSE 41215

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ For those who are really adventurous, it is also possible to directly install an
102102
pip install "git+https://github.com/MannLabs/alphaquant.git@development#egg=alphaquant[stable,development-stable]"
103103
```
104104

105+
#### Optional extras
106+
107+
For processing very large PTM files that don't fit in memory, install the optional dask extra:
108+
109+
```bash
110+
pip install "alphaquant[dask]"
111+
```
112+
or the version with a pinned dependency (recommended)
113+
```bash
114+
pip install "alphaquant[dask-stable]"
115+
```
116+
105117
### Developer installation
106118

107119
AlphaQuant can also be installed in editable (i.e. developer) mode with a few `bash` commands. This allows to fully customize the software and even modify the source code to your specific needs. When an editable Python package is installed, its source code is stored in a transparent location of your choice. While optional, it is advised to first (create and) navigate to e.g. a general software folder:

alphaquant/ptm/ptmsite_mapping.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@
1818
# Cell
1919

2020
import pandas as pd
21-
import dask.dataframe as dd
21+
import warnings
2222

23+
try:
24+
import dask.dataframe as dd
25+
HAS_DASK = True
26+
except ModuleNotFoundError:
27+
HAS_DASK = False
28+
warnings.warn(
29+
"Dependency 'dask' not installed. If you want to use its functionality, install it with: `pip install \"alphaquant[dask]\"` . ImportError will be raised if the data requires out-of-memory processing."
30+
)
2331

2432

2533
def assign_dataset_chunkwise(input_file, results_dir, samplemap_df , modification_type = "[Phospho (STY)]", id_thresh = 0.6, excl_thresh =0.2 ,swissprot_file = None,
@@ -46,6 +54,12 @@ def assign_dataset_chunkwise(input_file, results_dir, samplemap_df , modificatio
4654
input_type (str): Type of input data ("Spectronaut" or "DIANN")
4755
organism (str): Organism name
4856
"""
57+
if not HAS_DASK:
58+
raise ImportError(
59+
"Dask is required for out-of-memory PTM site mapping. "
60+
"Install it with: pip install \"alphaquant[dask]\""
61+
)
62+
4963
clean_up_previous_processings(results_dir)
5064

5165
if input_type == 'Spectronaut':

alphaquant/quant_reader/longformat_reader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
HAS_DASK = True
1111
except ModuleNotFoundError:
1212
warnings.warn(
13-
"Dependency 'dask' not installed. If you want to use its functionality, install alphaquant with the 'dask' extra. Falling back to non-dask based processing."
13+
"Dependency 'dask' not installed. If you want to use its functionality, install it with: `pip install \"alphaquant[dask]\"` . Falling back to non-dask based processing."
1414
)
1515
HAS_DASK = False
1616

0 commit comments

Comments
 (0)