Skip to content

Commit

Permalink
Conda to uv (#390)
Browse files Browse the repository at this point in the history
* Conda to uv

* Update flake8 command

* Update
  • Loading branch information
keller-mark authored Nov 27, 2024
1 parent 83fa4bb commit a19bea9
Show file tree
Hide file tree
Showing 35 changed files with 4,198 additions and 94 deletions.
28 changes: 14 additions & 14 deletions .coveragerc_omit
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[run]
omit =
vitessce/config.py
vitessce/export.py
vitessce/file_def_utils.py
vitessce/routes.py
vitessce/widget.py
vitessce/wrappers.py
vitessce/repr.py
vitessce/utils.py
vitessce/data_utils/anndata.py
vitessce/data_utils/ome.py
vitessce/data_utils/entities.py
vitessce/data_utils/multivec.py
vitessce/widget_plugins/demo_plugin.py
vitessce/widget_plugins/spatial_query.py
src/vitessce/config.py
src/vitessce/export.py
src/vitessce/file_def_utils.py
src/vitessce/routes.py
src/vitessce/widget.py
src/vitessce/wrappers.py
src/vitessce/repr.py
src/vitessce/utils.py
src/vitessce/data_utils/anndata.py
src/vitessce/data_utils/ome.py
src/vitessce/data_utils/entities.py
src/vitessce/data_utils/multivec.py
src/vitessce/widget_plugins/demo_plugin.py
src/vitessce/widget_plugins/spatial_query.py
1 change: 0 additions & 1 deletion .envrc

This file was deleted.

20 changes: 7 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install vitessce
run: pip install -e .[dev,docs,all]
run: uv sync --extra dev --extra docs --extra all
- name: Run tests
run: pytest
run: uv run pytest
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
run: uv build --sdist --wheel
- name: Build docs
run: |
make html
uv run make html
touch docs-dist/html/.nojekyll
- uses: actions/upload-pages-artifact@v1
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- run: pip install -e .[docs,all]
- run: make html
- run: uv sync --extra docs --extra all
- run: uv run make html
9 changes: 4 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: astral-sh/setup-uv@v3
with:
python-version: '3.9'
architecture: 'x64'
- run: pip install .[dev]
- run: flake8
version: "latest"
- run: uv sync --extra dev
- run: uv run flake8
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['3.9', '3.12']
version: ['3.10', '3.12']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: astral-sh/setup-uv@v3
with:
python-version: ${{ matrix.version }}
version: "latest"
env:
UV_PYTHON: ${{ matrix.version }}
- name: Install vitessce
run: pip install -e .[dev,all]
run: uv sync --extra dev --extra all
- name: Run tests and report coverage with omits
run: |
coverage run --rcfile .coveragerc_omit --module pytest && \
coverage report --show-missing --fail-under 100
uv run coverage run --rcfile .coveragerc_omit --module pytest && \
uv run coverage report --show-missing --fail-under 100
- name: Run tests and report coverage without omits
run: |
coverage run --rcfile .coveragerc_real --module pytest && \
coverage report --show-missing
uv run coverage run --rcfile .coveragerc_real --module pytest && \
uv run coverage report --show-missing
12 changes: 4 additions & 8 deletions .github/workflows/test_demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: astral-sh/setup-uv@v3
with:
python-version: '3.9'
- run: |
pip install "pulp==2.7.0"
pip install snakemake
pip install pyyaml
version: "latest"
- name: Install vitessce
run: pip install -e .[dev,all]
run: uv sync --extra dev --extra all --extra demos
- name: Run tests
working-directory: ./demos
run: snakemake -j 1 --dry-run
run: uv run snakemake -j 1 --dry-run
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ For a development installation (requires NodeJS and NPM),

$ git clone https://github.com/vitessce/vitessce-python.git
$ cd vitessce-python
$ conda env create -f environment.yml
$ conda activate vitessce-python-dev
$ pip install -e ".[dev,docs,all]"
$ uv sync --extra dev --extra docs --extra all

### Conda environments

Expand All @@ -43,29 +41,29 @@ In this repository, there are multiple conda environments for different purposes
## Linting and testing

```sh
flake8
pytest
uv run flake8
uv run pytest
```

### Formatting

One file:

```sh
autopep8 --in-place --aggressive ./path/to/file.py
uv run autopep8 --in-place --aggressive ./path/to/file.py
```

All `.py` files:

```sh
find . -name '*.py' -exec autopep8 --in-place --aggressive '{}' \;
find . -name '*.py' -exec uv run autopep8 --in-place --aggressive '{}' \;
```


## Documentation

```sh
make html
uv run make html
```


Expand Down
1 change: 0 additions & 1 deletion docs/notebooks/.envrc

This file was deleted.

6 changes: 2 additions & 4 deletions docs/notebooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ Some of the example notebooks rely on external single-cell data analysis package

```sh
cd docs/notebooks
conda env create -f environment.yml
conda activate vitessce-python-notebooks
pip install -e "../..[dev]"
uv sync --extra dev --extra docs --extra all
```

## Run

```sh
jupyter lab
uv run jupyter lab
```

## Troubleshooting
Expand Down
7 changes: 0 additions & 7 deletions environment.yml

This file was deleted.

62 changes: 47 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["setuptools>=67.0", "wheel>=0.38.4"]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "vitessce"
Expand All @@ -11,7 +11,7 @@ authors = [
description = "Jupyter widget facilitating interactive visualization of spatial single-cell data with Vitessce"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.9"
requires-python = ">=3.10"
keywords = ["ipython", "jupyter", "widgets"]
classifiers = [
'Development Status :: 4 - Beta',
Expand All @@ -31,24 +31,19 @@ dependencies = [
'negspy>=0.2.24',
'pandas>=1.1.2',
'black>=21.11b1',
'numpy>=1.21.2,<2.0',
'anndata>=0.7.8,<0.11',
'scanpy>=1.9.3',
'numpy>=1.21.2',
'anndata>=0.7.8',
# scanpy < 1.10.3 does not support numpy >= 2.0.0 and does not
# Reference: https://github.com/scverse/scanpy/pull/3115/files
'scanpy>=1.10.2',
'ome-zarr>=0.8.3',
'tifffile>=2020.10.1',
'jsonschema>=3.2',
'tqdm>=4.1.0'
]

[project.optional-dependencies]
dev = [
'build==0.1.0',
'pytest>=6.2.4',
'loompy>=3.0.6',
'coverage>=6.3.2',
'flake8==3.8.4',
'spatialdata>=0.2.2',
]
dev = []
docs = [
'sphinx==4.2.0',
'sphinx-rtd-theme==1.0.0',
Expand Down Expand Up @@ -79,7 +74,7 @@ all = [
'uvicorn>=0.17.0',
'ujson>=4.0.1',
'starlette==0.14.0',
'generate-tiff-offsets>=0.1.7',
'generate-tiff-offsets>=0.1.8',
'kerchunk>=0.2.6',
'fsspec',

Expand All @@ -93,9 +88,46 @@ building = []
testing = []
linting = []
notebook = []
demos = [
"pulp==2.7.0",
"snakemake",
"pyyaml",
]

[dependency-groups]
dev = [
'build==0.1.0',
'pytest>=6.2.4',
'loompy>=3.0.6',
'coverage>=6.3.2',
'flake8==3.8.4',
#'spatialdata>=0.2.2',
'jupyterlab',
'numba>=0.53.0',
'jupyterlab>=3',
'boto3>=1.16.30',
'scikit-misc>=0.1.3',
]

[tool.uv]
default-groups = ["dev"]
override-dependencies = [
'starlette==0.14.0'
]

[tool.hatch.build]
exclude = [".github", "docs", "demos", "binder"]

[project.urls]
repository = "https://github.com/vitessce/vitessce-python"

[tool.setuptools]
packages = ["vitessce", "vitessce.data_utils", "vitessce.widget_plugins"]
package-dir = {"" = "src"}

# Reference: https://stackoverflow.com/a/50156706
[tool.pytest.ini_options]
pythonpath = ["src"]
testpaths = ["tests"]
addopts = ["--doctest-modules", "--verbose", "--ignore=docs", "--ignore=demos"]

2 changes: 0 additions & 2 deletions pytest.ini

This file was deleted.

10 changes: 7 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ universal=1
[flake8]
per-file-ignores =
# Special case: names are reimported from __init__.py, so unused imports are expected.
vitessce/__init__.py: F401
vitessce/data_utils/__init__.py: F401
vitessce/widget_plugins/__init__.py: F401
src/vitessce/__init__.py: F401
src/vitessce/data_utils/__init__.py: F401
src/vitessce/widget_plugins/__init__.py: F401
ignore =
# Ignore line too long
E501,
Expand All @@ -20,6 +20,10 @@ ignore =
E128
exclude =
./js/node_modules/,
./docs/,
./demos/,
./binder/,
./.venv/,
./docs/notebooks/.ipynb_checkpoints/,
./build/,
./.ipynb_checkpoints/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a19bea9

Please sign in to comment.