Skip to content

Commit

Permalink
Merge pull request #5 from quadbio/notebook_and_tests
Browse files Browse the repository at this point in the history
Notebook and tests
  • Loading branch information
Marius1311 authored Oct 16, 2024
2 parents a669331 + cd6619e commit 3fe83f3
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 68 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -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
57 changes: 12 additions & 45 deletions analysis/[INITIALS]-[DATE]_sample_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -81,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2021-05-31T09:25:05.984402Z",
Expand All @@ -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"
]
},
{
Expand All @@ -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. "
]
},
{
Expand Down Expand Up @@ -167,7 +129,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -189,6 +151,11 @@
"## Main analysis"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
12 changes: 12 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 3fe83f3

Please sign in to comment.