Skip to content

Commit

Permalink
feat(API): Setup the library for development
Browse files Browse the repository at this point in the history
  • Loading branch information
Bento007 authored Feb 16, 2024
2 parents b23894a + b8a021c commit 1f7ce03
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 16 deletions.
29 changes: 28 additions & 1 deletion .github/workflows/push-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ jobs:
run: |
pip install -r tools/ontology-builder/requirements.txt
pip install -r tools/ontology-builder/requirements-dev.txt
- name: Ontology Dry Run Unit Tests
- name: Ontology builder unit tests
run: |
cd tools/ontology-builder && make unit-tests
unit-test-python-api:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.11
- name: Python cache
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/api/python/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
cd api/python
make install-dev
- name: Python API unit tests
run: |
cd api/python
make unit-tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/api/python/src/cellxgene_ontology_guide/_version.py
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ repos:
- id: mypy
args: [--strict, --ignore-missing-imports]
additional_dependencies: [types-PyYAML]
files: ^(api/python|tools/ontology-builder/src)/
files: ^(api/python/src|tools/ontology-builder/src)/
File renamed without changes.
11 changes: 11 additions & 0 deletions api/python/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
install:
pip install -e .

install-dev:
pip install -e .[test]

clean:
rm -rf ./build ./src/cellxgene_ontology_guide.egg-info

unit-tests:
python -m pytest tests
14 changes: 14 additions & 0 deletions api/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Python API

# Install

```bash
make install
```

# Run Unit Tests

```bash
make install-dev
make unit-tests
```
File renamed without changes.
14 changes: 0 additions & 14 deletions api/python/cellxgene-ontology/pyproject.toml

This file was deleted.

35 changes: 35 additions & 0 deletions api/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[build-system]
requires = ["setuptools>=69", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "cellxgene_ontology_guide"
dynamic = ["version"]
description = "Access ontology data used by CZ cellxgene"
authors = [
{ name = "Chan Zuckerberg Initiative Foundation", email = "[email protected]" }
]
license = { text = "MIT" }
readme = "README.md"
requires-python = "~= 3.11"
dependencies = [
"owlready2"
]

[project.optional-dependencies]
test = ["pytest"]

[tool.setuptools.packages.find]
where = ["src"]
include = ["cellxgene_ontology_guide"]

[tool.pytest.ini_options]
pythonpath = ["src/cellxgene_ontology_guide"]

[tool.setuptools_scm]
version_file = "src/cellxgene_ontology_guide/_version.py"
version_scheme = "python-simplified-semver"
root = "../.."
relative_to = "__file__"
#TODO: setup the github tag for the pypi releases so setuptools-SCM can identify it using a python regex
#tag_regex="^python-api-(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$')"
3 changes: 3 additions & 0 deletions api/python/src/cellxgene_ontology_guide/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import _version

__version__ = _version.__version__
File renamed without changes.
5 changes: 5 additions & 0 deletions api/python/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import cellxgene_ontology_guide


def test_version():
assert cellxgene_ontology_guide.__version__
Binary file not shown.

0 comments on commit 1f7ce03

Please sign in to comment.