Skip to content

Commit

Permalink
Merge pull request #62 from biolink/tox
Browse files Browse the repository at this point in the history
add tox, add biolink-2.2.3 support
  • Loading branch information
sierra-moxon authored Aug 23, 2021
2 parents 81fbfde + 84aa57d commit 359d86c
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 7 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/run_tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run Tox

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
types: [opened, synchronize, reopened]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
types: trigger-run-tox

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox
# Run tox using the version of Python in `PATH`
run: tox -e py
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements.txt
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dev-install:
install:
python setup.py install

tests:
test:
pytest tests/*

cleandist:
Expand Down
2 changes: 1 addition & 1 deletion bmt/toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Url = str
Path = str

REMOTE_PATH = 'https://raw.githubusercontent.com/biolink/biolink-model/2.2.0/biolink-model.yaml'
REMOTE_PATH = 'https://raw.githubusercontent.com/biolink/biolink-model/2.2.3/biolink-model.yaml'
RELATED_TO = 'related to'
CACHE_SIZE = 1024

Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ sphinx-rtd-theme
sphinxcontrib-napoleon
numpydoc
recommonmark
tox
flake8
black
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
REQUIREMENTS = FH.readlines()

NAME = 'bmt'
VERSION = '0.7.3'
VERSION = '0.7.4'
DESCRIPTION = 'Biolink Model Toolkit: A Python API for working with the Biolink Model'
URL = 'https://github.com/biolink/biolink-model-toolkit'
AUTHOR = 'Deepak Unni', 'Sierra Moxon'
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/test_toolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ def toolkit():

def test_get_model_version(toolkit):
version = toolkit.get_model_version()
assert version == '2.2.0'
assert version == '2.2.3'


def test_get_element_by_mapping(toolkit):
element_name = toolkit.get_element_by_mapping('RO:0002410')
assert element_name == 'causes'


def test_get_all_elements(toolkit):
Expand Down Expand Up @@ -254,16 +259,14 @@ def test_get_slot_domain(toolkit):
assert BIOLINK_BIOLOGICAL_ENTITY in toolkit.get_slot_domain(ENABLED_BY, include_ancestors=True, formatted=True)
assert 'entity' in toolkit.get_slot_domain('name')
assert 'entity' in toolkit.get_slot_domain('category')
assert ASSOCIATION in toolkit.get_slot_domain('relation')
assert ASSOCIATION in toolkit.get_slot_domain('predicate')


def test_get_slot_range(toolkit):
assert 'disease or phenotypic feature' in toolkit.get_slot_range('treats')
assert BIOLOGICAL_ENTITY in toolkit.get_slot_range('treats', include_ancestors=True)
assert BIOLINK_BIOLOGICAL_ENTITY in toolkit.get_slot_range('treats', include_ancestors=True, formatted=True)
assert 'label type' in toolkit.get_slot_range('name')
assert 'uriorcurie' in toolkit.get_slot_range('relation')
assert 'metatype:Uriorcurie' in toolkit.get_slot_range('relation', formatted=True)


def test_get_all_slots_with_class_domain(toolkit):
Expand Down
50 changes: 50 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# TODO explain tox and testenv reserved words
[tox]
envlist = py37
py38
py39
black-diff
flake8
example

[testenv]
extras =
jupyter
allowlist_externals =
/usr/bin/make
/bin/cat
/bin/cp
/bin/mkdir
/usr/bin/git
deps =
-rrequirements.txt
commands = pytest

# TODO document how these inherit from testenv
[testenv:black-diff]
line_length = 120
commands =
black --check --diff bmt tests

[testenv:black]
line_length = 120
commands =
black bmt tests

[testenv:flake8]
commands =
flake8 bmt tests

[flake8]
ignore = E501
max_line_length = 70
max-complexity = 10
per-file-ignores = __init__.py:F401

[testenv:example]
deps =
-rrequirements.txt
setenv =
PYTHONPATH=.
commands =
python examples/edgelabel.py

0 comments on commit 359d86c

Please sign in to comment.