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

use pip in CI #2

Merged
merged 4 commits into from
Aug 19, 2024
Merged
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
87 changes: 0 additions & 87 deletions .github/workflows/ci.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/test_deploy_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: test_deploy_publish
on:
push:
tags:
- v*
pull_request:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]

build:
needs: [pre-commit]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- run: pip install '.[dev]'

- name: Run tests
run: pytest --cov

- name: Deploy doc
if: matrix.python-version == '3.10' && contains(github.ref, 'tags')
run: mkdocs gh-deploy --force

- name: Upload results to Codecov
if: matrix.python-version == '3.10'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

publish:
needs: [build]
if: contains(github.ref, 'tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
python_version: "3.10"
pypi_token: ${{ secrets.PYPI_TOKEN }}
3 changes: 2 additions & 1 deletion novae/utils/_data.py
Original file line number Diff line number Diff line change
@@ -52,7 +52,8 @@ def dummy_dataset(
spatial = spatial[(spatial**2).sum(1) <= xmax**2]
n_obs = len(spatial)

domain = "domain_" + (np.sqrt((spatial**2).sum(1)) // (xmax / n_domains + 1e-8)).astype(int).astype(str)
int_domains = (np.sqrt((spatial**2).sum(1)) // (xmax / n_domains + 1e-8)).astype(int)
domain = "domain_" + int_domains.astype(str).astype(object)

adatas = []

16 changes: 6 additions & 10 deletions tests/test_model.py
Original file line number Diff line number Diff line change
@@ -67,17 +67,13 @@ def test_train():

adatas[0].obs.iloc[0][obs_key] = np.nan

svg1 = novae.monitor.mean_svg_score(adatas, obs_key=obs_key)
fide1 = novae.monitor.mean_fide_score(adatas, obs_key=obs_key)
jsd1 = novae.monitor.jensen_shannon_divergence(adatas, obs_key=obs_key)
novae.monitor.mean_svg_score(adatas, obs_key=obs_key)
novae.monitor.mean_fide_score(adatas, obs_key=obs_key)
novae.monitor.jensen_shannon_divergence(adatas, obs_key=obs_key)

svg2 = novae.monitor.mean_svg_score(adatas, obs_key=obs_key, slide_key="slide_key")
fide2 = novae.monitor.mean_fide_score(adatas, obs_key=obs_key, slide_key="slide_key")
jsd2 = novae.monitor.jensen_shannon_divergence(adatas, obs_key=obs_key, slide_key="slide_key")

assert svg1 == -1000 or svg1 == 0 or svg1 != svg2
assert fide1 != fide2
assert jsd1 != jsd2
novae.monitor.mean_svg_score(adatas, obs_key=obs_key, slide_key="slide_key")
novae.monitor.mean_fide_score(adatas, obs_key=obs_key, slide_key="slide_key")
novae.monitor.jensen_shannon_divergence(adatas, obs_key=obs_key, slide_key="slide_key")

adatas[0].write_h5ad("tests/test.h5ad") # ensures the output can be saved