Skip to content

Commit

Permalink
build: separate dependency groups by use case (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored May 5, 2023
1 parent b898b6c commit 975d587
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 183 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
name: github-actions
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python3 -m pip install ".[dev]"

- name: Check style
run: python3 -m flake8 gene/ tests/ setup.py

test:
runs-on: ubuntu-latest
strategy:
matrix:
db_url: ["http://localhost:8000", "postgres://postgres:postgres@localhost:5432/gene_normalizer_test"]
python-version: ['3.8', '3.9', '3.10']
services:
postgres:
image: postgres:14
Expand All @@ -25,24 +45,27 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install pipenv
pipenv install --dev
- name: Install DynamoDB dependencies
if: ${{ env.GENE_NORM_DB_URL == 'http://localhost:8000' }}
run: python3 -m pip install ".[etl,test]"

- name: Install PG dependencies
if: ${{ env.GENE_NORM_DB_URL != 'http://localhost:8000' }}
run: python3 -m pip install ".[pg,etl,test]"

- name: Build local DynamoDB
if: ${{ env.GENE_NORM_DB_URL == 'http://localhost:8000' }}
run: |
chmod +x ./tests/unit/dynamodb_build.bash
./tests/unit/dynamodb_build.bash
- run: pipenv run flake8
- run: pipenv run pytest tests/
- name: Run tests
run: python3 -m pytest tests/
docs:
runs-on: ubuntu-latest
steps:
Expand All @@ -52,4 +75,3 @@ jobs:
with:
pre-build-command: "python3 -m pip install .; python3 -m pip install sphinx_autodoc_typehints"
docs-folder: "docs/"

14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Services and guidelines for normalizing gene terms
The Normalizer is available via PyPI:

```commandline
pip install gene-normalizer[dev]
pip install gene-normalizer[etl,pg]
```

The `[dev]` argument tells pip to install packages to fulfill the dependencies of the `gene.etl` package.
The `[etl,pg]` argument tells pip to install packages to fulfill the dependencies of the `gene.etl` package and the PostgreSQL data storage implementation.

### External requirements

Expand Down Expand Up @@ -121,6 +121,16 @@ pipenv update
pipenv install --dev
```

Alternatively, install the `pg`, `etl`, `dev`, and `test` dependency groups in a virtual environment:

```commandline
git clone https://github.com/cancervariants/gene-normalization
cd gene-normalization
python3 -m virtualenv venv
source venv/bin/activate
pip install -e ".[pg,etl,dev,test]"
```

### Init coding style tests

Code style is managed by [flake8](https://github.com/PyCQA/flake8) and checked prior to commit.
Expand Down
18 changes: 16 additions & 2 deletions docs/source/full_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,24 @@ Package installation

First, install the Gene Normalizer from PyPI: ::

pip install gene-normalizer[dev]
pip install "gene-normalizer[etl]"

The ``[dev]`` option installs dependencies necessary for using the ``gene.etl`` package, which performs data loading operations.
The ``[etl]`` option installs dependencies necessary for using the ``gene.etl`` package, which performs data loading operations.

Users intending to utilize PostgreSQL to store source data should also include the `pg` dependency group: ::

pip install "gene-normalizer[etl,pg]"

.. _Dependency groups:

.. note::

The Gene Normalizer defines four optional dependency groups in total:

* `etl` provides dependencies for regenerating data from sources. It's necessary for users who don't intend to rely on existing database dumps.
* `pg` provides dependencies for connecting to a PostgreSQL database. It's not necessary for users who are using a DynamoDB backend.
* `dev` provides development dependencies, such as static code analysis and docs generation tools. It's required for contributing to the Gene Normalizer, but otherwise unnecessary.
* `test` provides dependencies for running tests. As with `dev`, it's mostly relevant for contributors.

SeqRepo
-------
Expand Down
4 changes: 2 additions & 2 deletions docs/source/quick_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Requirements
Installation Steps
------------------

Install the Gene Normalizer via PyPI: ::
Install the Gene Normalizer via PyPI (see the :ref:`note on dependency groups <Dependency groups>` for more info): ::

pip install gene-normalizer
pip install "gene-normalizer[pg]"

Create a new PostgreSQL database. For example, using the `psql createdb <https://www.postgresql.org/docs/current/app-createdb.html>`_ utility, and assuming that ``postgres`` is a valid user: ::

Expand Down
2 changes: 0 additions & 2 deletions docs/source/search_capabilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ Each search mode can be accessed directly within Python using the :ref:`query AP
>>> normalized_response.gene_descriptor.label
'ERBB2'



Match types
-----------

Expand Down
70 changes: 0 additions & 70 deletions dynamodb_revisions/add_item_type.py

This file was deleted.

45 changes: 0 additions & 45 deletions dynamodb_revisions/add_other_id_refs.py

This file was deleted.

45 changes: 0 additions & 45 deletions dynamodb_revisions/add_xref_refs.py

This file was deleted.

3 changes: 1 addition & 2 deletions gene/cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""This module provides a CLI util to make updates to normalizer database."""
from collections.abc import Collection
import logging
import os
from pathlib import Path
from timeit import default_timer as timer
from typing import List, Optional, Set
from typing import Collection, List, Optional, Set

import click

Expand Down
14 changes: 10 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,25 @@ console_scripts =
gene_norm_check_db = gene.cli:check_db

[options.extras_require]
dev =
pg =
psycopg[binary]

etl =
gffutils
biocommons.seqrepo

test =
pytest
pytest-cov
mock

dev =
pre-commit
flake8
flake8-docstrings
pytest-cov
mock
ipykernel
sphinx == 6.1.3
sphinx-autodoc-typehints == 1.22.0

[tool:pytest]
addopts = --ignore setup.py --ignore codebuild/ --ignore dynamodb_local_latest/ --doctest-modules --cov-report term-missing --cov .
addopts = --ignore setup.py --ignore dynamodb_local_latest/ --ignore docs/ --doctest-modules --cov-report term-missing --cov=.

0 comments on commit 975d587

Please sign in to comment.