From c8c2e9eedc398052e0504bd086c63f64158fa5a2 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 18:23:09 +0200 Subject: [PATCH 1/3] Remove scanpy from the notebook --- .../[INITIALS]-[DATE]_sample_notebook.ipynb | 57 ++++--------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb b/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb index 07a4239..1fbcfe1 100644 --- a/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb +++ b/analysis/[INITIALS]-[DATE]_sample_notebook.ipynb @@ -50,23 +50,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2021-05-31T09:25:02.307098Z", "start_time": "2021-05-31T09:25:02.291254Z" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The autoreload extension is already loaded. To reload it, use:\n", - " %reload_ext autoreload\n" - ] - } - ], + "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" @@ -81,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-05-31T09:25:05.984402Z", @@ -91,33 +82,7 @@ }, "outputs": [], "source": [ - "# import single-cell packages\n", - "import scanpy as sc\n", - "from fancypackage.ul import DATA_DIR, FIG_DIR" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Print package versions. " - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Running Scanpy 1.10.3, on 2024-10-16 17:32.\n" - ] - } - ], - "source": [ - "sc.logging.print_version_and_date()" + "from fancypackage.ul import DATA_DIR" ] }, { @@ -128,13 +93,10 @@ ] }, { - "cell_type": "code", - "execution_count": 5, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "sc.settings.figdir = str(FIG_DIR)\n", - "sc.settings.set_figure_params(dpi=100, dpi_save=300, frameon=False)" + "Define constants etc. here. " ] }, { @@ -167,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -189,6 +151,11 @@ "## Main analysis" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "markdown", "metadata": {}, From e810d1290d1d3e8423ab15139b56c229e8004c22 Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 19:19:51 +0200 Subject: [PATCH 2/3] Add tests --- .github/workflows/lint.yml | 36 ++++++++++++++++++------------------ tests/test_basic.py | 12 ++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 tests/test_basic.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 71da080..66487d4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,23 +1,23 @@ name: Lint on: - push: - branches: main - pull_request: - branches: main + push: + branches: main + pull_request: + branches: main jobs: - linting: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pre-commit - - name: Check pre-commit compatibility - run: pre-commit run --all-files --show-diff-on-failure + linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pre-commit + - name: Check pre-commit compatibility + run: pre-commit run --all-files --show-diff-on-failure diff --git a/tests/test_basic.py b/tests/test_basic.py new file mode 100644 index 0000000..b11ec0b --- /dev/null +++ b/tests/test_basic.py @@ -0,0 +1,12 @@ +import pytest + +import fancypackage + + +def test_package_has_version(): + assert fancypackage.__version__ is not None + + +@pytest.mark.skip(reason="This decorator should be removed when test passes.") +def test_example(): + assert 1 == 0 # This test is designed to fail. From cd6619edde119d890018baa5b03b5170e17e6f2c Mon Sep 17 00:00:00 2001 From: Marius Lange Date: Wed, 16 Oct 2024 19:33:53 +0200 Subject: [PATCH 3/3] Update GitHub action workflows --- .github/workflows/build.yaml | 29 ++++++++++++++++ .github/workflows/lint.yml | 23 ------------- .github/workflows/test.yaml | 67 ++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..bfa2cf0 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,29 @@ +name: Check Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: "pip" + cache-dependency-path: "**/pyproject.toml" + - name: Install build dependencies + run: python -m pip install --upgrade pip wheel twine build + - name: Build package + run: python -m build + - name: Check package + run: twine check --strict dist/*.whl diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 66487d4..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint - -on: - push: - branches: main - pull_request: - branches: main - -jobs: - linting: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup Python 3.10 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pre-commit - - name: Check pre-commit compatibility - run: pre-commit run --all-files --show-diff-on-failure diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..841bd7c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,67 @@ +name: Test + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "0 5 1,15 * *" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash -e {0} # -e to fail on error + + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + python: "3.10" + - os: ubuntu-latest + python: "3.12" + - os: ubuntu-latest + python: "3.12" + pip-flags: "--pre" + name: PRE-RELEASE DEPENDENCIES + + name: ${{ matrix.name }} Python ${{ matrix.python }} + + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + cache: "pip" + cache-dependency-path: "**/pyproject.toml" + + - name: Install test dependencies + run: | + python -m pip install --upgrade pip wheel + - name: Install dependencies + run: | + pip install ${{ matrix.pip-flags }} ".[dev,test]" + - name: Test + env: + MPLBACKEND: agg + PLATFORM: ${{ matrix.os }} + DISPLAY: :42 + run: | + coverage run -m pytest -v --color=yes + - name: Report coverage + run: | + coverage report + - name: Upload coverage + uses: codecov/codecov-action@v3