Skip to content
Open
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
26 changes: 15 additions & 11 deletions .github/workflows/code_checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: code checks
permissions:
contents: read
pull-requests: write

on:
push:
Expand All @@ -9,7 +12,7 @@ on:
- .github/workflows/code_checks.yml
- .github/workflows/integration_tests.yml
- '**.py'
- poetry.lock
- uv.lock
- pyproject.toml
- '**.ipynb'
pull_request:
Expand All @@ -19,7 +22,7 @@ on:
- .pre-commit-config.yaml
- .github/workflows/code_checks.yml
- '**.py'
- poetry.lock
- uv.lock
- pyproject.toml
- '**.ipynb'

Expand All @@ -28,20 +31,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install and configure Poetry
uses: snok/install-poetry@v1
- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
with:
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/[email protected]
# Install a specific version of uv.
version: "0.7.20"
enable-cache: true
- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version: '3.10'
cache: 'poetry'
python-version-file: ".python-version"
- name: Install the project
run: uv sync --dev --all-extras
- name: Install dependencies and check code
run: |
poetry env use '3.10'
source .venv/bin/activate
poetry install --with test --all-extras
pre-commit run --all-files
- name: pip-audit (gh-action-pip-audit)
uses: pypa/[email protected]
Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: docs
permissions:
contents: read
pull-requests: write

on:
pull_request:
Expand All @@ -14,22 +17,27 @@ jobs:
submodules: 'true'
fetch-depth: 0

- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry

- uses: actions/[email protected]
- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
with:
python-version: '3.10'
cache: 'poetry'
# Install a specific version of uv.
version: "0.7.20"
enable-cache: true

- name: Install dependencies
- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version-file: ".python-version"
- name: Install the project
run: uv sync --dev --group docs
- name: Install dependencies and check code
run: |
poetry env use '3.10'
poetry install --with docs,test --all-extras
source .venv/bin/activate
pre-commit run --all-files

- name: Build docs
run: |
source $(poetry env info --path)/bin/activate
source .venv/bin/activate
cd docs
rm -rf source/reference/api/_autosummary
if [[ "${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') }}" == "true" ]]; then
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- '**.html'
- '**.jinja'
- '**.js'
- poetry.lock
- uv.lock
- pyproject.toml
- '**.rst'
- '**.md'
Expand All @@ -30,7 +30,7 @@ on:
- '**.html'
- '**.jinja'
- '**.js'
- poetry.lock
- uv.lock
- pyproject.toml
- '**.rst'
- '**.md'
Expand All @@ -41,20 +41,23 @@ jobs:
runs-on: [self-hosted, gpu, db, cyclops]
steps:
- uses: actions/[email protected]
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
with:
python-version: '3.10'
cache: 'poetry'
- name: Install dependencies and check code
# Install a specific version of uv.
version: "0.7.20"
enable-cache: true
- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version-file: ".python-version"
- name: Install project and check code
run: |
export PATH=/opt/openmpi-4.1.5/bin:$PATH
export LD_LIBRARY_PATH=/opt/openmpi-4.1.5/lib:$LD_LIBRARY_PATH
ompi_info
poetry env use '3.10'
source $(poetry env info --path)/bin/activate
env MPICC=/opt/openmpi-4.1.5/bin/mpicc poetry install --with dev,test --all-extras
env MPICC=/opt/openmpi-4.1.5/bin/mpicc uv sync --all-extras --dev --group test
source .venv/bin/activate
mpirun -n 2 python -m pytest --only-mpi
pytest -m integration_test --cov-report term --cov-report xml:./coverage.xml --cov=cyclops -n auto --dist loadscope
- name: Upload coverage to Codecov
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ jobs:
- uses: actions/[email protected]
- name: Install pip
run: python3 -m pip install --upgrade pip
- uses: actions/[email protected]
- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version: '3.10'
python-version-file: ".python-version"
- name: Install package and test import
run: |
pip install -e .
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: publish package
permissions:
contents: read
pull-requests: write

on:
release:
Expand All @@ -13,13 +16,25 @@ jobs:
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libssl-dev
- uses: actions/[email protected]
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]

- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
with:
# Install a specific version of uv.
version: "0.7.20"
enable-cache: true

- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version: '3.10'
python-version-file: ".python-version"

- name: Install the project
run: uv sync --all-extras

- name: Build package
run: poetry build
run: uv build

- name: Publish package
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc
with:
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- '**.html'
- '**.jinja'
- '**.js'
- poetry.lock
- uv.lock
- pyproject.toml
pull_request:
branches:
Expand All @@ -23,25 +23,28 @@ on:
- '**.html'
- '**.jinja'
- '**.js'
- poetry.lock
- uv.lock
- pyproject.toml

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install dependencies, run unit tests and coverage report
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/[email protected]
- name: Install uv
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355
with:
python-version: '3.10'
cache: 'poetry'
# Install a specific version of uv.
version: "0.7.20"
enable-cache: true
- name: "Set up Python"
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38
with:
python-version-file: ".python-version"
- name: Install the project
run: uv sync --dev
- run: |
python3 -m pip install --upgrade pip && python3 -m pip install poetry
poetry env use '3.10'
source $(poetry env info --path)/bin/activate
poetry install --with test --all-extras
source .venv/bin/activate
pytest -m "not integration_test" --cov-report term --cov-report xml:./coverage.xml --cov=cyclops -n auto --dist loadscope
- name: Upload coverage to Codecov
uses: Wandalen/[email protected]
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
*__pycache__*
*.log
docs/build
.python-version
*.DS_Store
htmlcov
.coverage
Expand Down
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ repos:
files: "^cyclops/"
language: system

- repo: local
hooks:
- id: pytest
name: pytest
entry: python3 -m pytest -m "not integration_test" -n auto --dist loadscope
language: system
pass_filenames: false
always_run: true
# - repo: local
# hooks:
# - id: pytest
# name: pytest
# entry: python3 -m pytest -m "not integration_test" -n auto --dist loadscope
# language: system
# pass_filenames: false
# always_run: true

ci:
autofix_commit_msg: |
Expand All @@ -73,5 +73,5 @@ ci:
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [pytest,doctest,nbstripout,mypy]
skip: [doctest,nbstripout,mypy]
submodules: false
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,29 +53,29 @@ below.

## 🧑🏿‍💻 Developing

### Using poetry
### Using uv

The development environment can be set up using
[poetry](https://python-poetry.org/docs/#installation). Hence, make sure it is
[uv](https://github.com/astral-sh/uv?tab=readme-ov-file#installation). Hence, make sure it is
installed and then run:

```bash
python3 -m poetry install
source $(poetry env info --path)/bin/activate
uv sync
source .venv/bin/activate
```

In order to install dependencies for testing (codestyle, unit tests, integration tests),
run:

```bash
python3 -m poetry install --with test
uv sync --group test
```

API documentation is built using [Sphinx](https://www.sphinx-doc.org/en/master/) and
can be locally built by:

```bash
python3 -m poetry install --with docs
uv sync --group docs
cd docs
make html SPHINXOPTS="-D nbsphinx_allow_errors=True"
```
Expand All @@ -89,7 +89,7 @@ guidelines.

## 📚 [Documentation](https://vectorinstitute.github.io/cyclops/)

If you need to build the documentations locally, make sure to install ``Pandoc`` in addition to ``docs`` poetry group.
If you need to build the documentations locally, make sure to install ``Pandoc`` in addition to ``docs`` dependency group.


## 📓 Notebooks
Expand Down
2 changes: 1 addition & 1 deletion cyclops/data/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,4 +761,4 @@ def timestamp_ffill_agg(
if fill_nan is not None:
arr = np.nan_to_num(arr, nan=fill_nan)

return arr
return arr # type: ignore[no-any-return]
2 changes: 1 addition & 1 deletion cyclops/data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)

import pandas as pd
import PIL
import PIL.Image
import psutil
from datasets import Dataset, DatasetDict
from datasets.features import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def world_size(self) -> int:
def _simple_all_gather(self, data: Tensor) -> List[Tensor]:
"""Gather tensors of the same shape from all processes."""
gathered_data = [torch.zeros_like(data) for _ in range(self.world_size)]
torch_dist.all_gather(gathered_data, data) # type: ignore[no-untyped-call]
torch_dist.all_gather(gathered_data, data)
return gathered_data

def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
Expand All @@ -77,7 +77,7 @@ def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
# gather sizes of all tensors
local_size = torch.tensor(data.shape, device=data.device)
local_sizes = [torch.zeros_like(local_size) for _ in range(self.world_size)]
torch_dist.all_gather(local_sizes, local_size) # type: ignore[no-untyped-call]
torch_dist.all_gather(local_sizes, local_size)
max_size = torch.stack(local_sizes).max(dim=0).values
all_sizes_equal = all(all(ls == max_size) for ls in local_sizes)

Expand All @@ -93,7 +93,7 @@ def all_gather(self, data: Tensor) -> List[Tensor]: # type: ignore[override]
pad_dims.append(val.item())
data_padded = torch.nn.functional.pad(data, pad_dims)
gathered_data = [torch.zeros_like(data_padded) for _ in range(self.world_size)]
torch_dist.all_gather(gathered_data, data_padded) # type: ignore[no-untyped-call]
torch_dist.all_gather(gathered_data, data_padded)
for idx, item_size in enumerate(local_sizes):
slice_param = [slice(dim_size) for dim_size in item_size]
gathered_data[idx] = gathered_data[idx][slice_param]
Expand Down
2 changes: 1 addition & 1 deletion cyclops/evaluate/metrics/experimental/functional/auroc.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _reduce_auroc(

"""
if apc.is_array_api_obj(fpr) and apc.is_array_api_obj(tpr):
res = _auc_compute(fpr, tpr, 1.0, axis=1) # type: ignore
res = _auc_compute(fpr, tpr, 1.0, axis=1)
else:
res = xp.stack(
[_auc_compute(x, y, 1.0) for x, y in zip(fpr, tpr)], # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _reduce_average_precision(
"""
if apc.is_array_api_obj(precision) and apc.is_array_api_obj(recall):
avg_prec = -xp.sum(
(recall[:, 1:] - recall[:, :-1]) * precision[:, :-1], # type: ignore
(recall[:, 1:] - recall[:, :-1]) * precision[:, :-1],
axis=1,
dtype=xp.float32,
)
Expand Down
Loading
Loading