Skip to content

Commit

Permalink
Merge pull request #696 from opencobra/fix-workflow
Browse files Browse the repository at this point in the history
Fix workflow
  • Loading branch information
Midnighter committed Aug 20, 2020
2 parents 77237a0 + d73cfe2 commit ea06738
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 36 deletions.
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[paths]
source =
src/memote
*/site-packages/memote

[run]
branch = true
parallel = true

[report]
precision = 2
exclude_lines =
# Have to re-enable the standard pragma.
pragma: no cover
8 changes: 1 addition & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,17 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
node-version: [10]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions
- name: Generate the MEMOTE report
run: make reports
- name: Test with tox
run: tox -- --cov-report=xml
- name: Report coverage
Expand Down Expand Up @@ -73,6 +66,7 @@ jobs:
python -m pip install --upgrade pip setuptools wheel
python -m pip install twine
- name: Generate the MEMOTE report
shell: bash
run: make reports
- name: Build package
run: python setup.py sdist bdist_wheel
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# Document Python Code
autoapi_type = 'python'
autoapi_dirs = ['../memote']
autoapi_dirs = ['../src/memote']
autoapi_ignore = ['.tox', '.pytest_cache', 'scripts', 'benchmarks']

numpydoc_show_class_members = False
Expand Down
2 changes: 1 addition & 1 deletion src/memote/experimental/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ def check_row(self, cells):
cell,
message="Value '{value}' in column {header} on row "
"{row_number} is an unknown identifier.",
message_substitutions={"value": value,},
message_substitutions={"value": value},
)
return [error]
4 changes: 3 additions & 1 deletion src/memote/experimental/essentiality.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ def load(self, dtype_conversion=None):
super(EssentialityExperiment, self).load(dtype_conversion=dtype_conversion)
self.data["essential"] = self.data["essential"].isin(self.TRUTHY)

def validate(self, model, checks=[]):
def validate(self, model, checks=None):
"""Use a defined schema to validate the medium table format."""
if checks is None:
checks = []
custom = [
{
"unknown-identifier": {
Expand Down
12 changes: 6 additions & 6 deletions src/memote/experimental/experimental_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

# Copyright 2018 Novo Nordisk Foundation Center for Biosustainability,
# Technical University of Denmark.
#
Expand All @@ -15,25 +13,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.


"""Provide a class for medium definitions."""

from __future__ import absolute_import

import json
import logging

from goodtables import validate
from importlib_resources import open_text

# Importing the checks is necessary in order to register them.
import memote.experimental.schemata

# The following import is necessary in order to register the custom check.
from memote.experimental.checks import UnknownIdentifier # noqa: F401
from memote.experimental.tabular import read_tabular


__all__ = ("ExperimentalBase",)


LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -84,8 +82,10 @@ def load(self, dtype_conversion=None):
) as file_handle:
self.schema = json.load(file_handle)

def validate(self, model, checks=[]):
def validate(self, model, checks=None):
"""Use a defined schema to validate the given table."""
if checks is None:
checks = []
records = self.data.to_dict("records")
self.evaluate_report(
validate(
Expand Down
4 changes: 3 additions & 1 deletion src/memote/experimental/medium.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def __init__(self, **kwargs):
"""
super(Medium, self).__init__(**kwargs)

def validate(self, model, checks=[]):
def validate(self, model, checks=None):
"""Use a defined schema to validate the medium table format."""
if checks is None:
checks = []
custom = [
{
"unknown-identifier": {
Expand Down
7 changes: 5 additions & 2 deletions src/memote/suite/results/history_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def iter_commits(self):
"""Iterate over all commit hashes in the repository."""
return iterkeys(self._history["commits"])

def load_history(self, model, skip={"gh-pages"}):
def load_history(self, model, skip=("gh-pages",)):
"""
Load the entire results history into memory.
Could be a bad idea in a far future.
"""
skip = set(skip)
if self._history is None:
self.build_branch_structure(model, skip)
self._results = dict()
Expand All @@ -117,8 +118,10 @@ def load_history(self, model, skip={"gh-pages"}):
LOGGER.error("Could not load result '%s'.", commit)
LOGGER.debug("%s", str(err))

def get_result(self, commit, default=MemoteResult()):
def get_result(self, commit, default=None):
"""Return an individual result from the history if it exists."""
if default is None:
default = MemoteResult()
assert self._results is not None, "Please call the method `load_history` first."
return self._results.get(commit, default)

Expand Down
20 changes: 3 additions & 17 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ envlist = isort, black, flake8, safety, docs, py3{6,7,8}

[gh-actions]
python =
3.6: isort, black, flake8, safety, docs, py36
3.6: isort, black, flake8, safety, py36
3.7: safety, py37
3.8: safety, py38

Expand Down Expand Up @@ -38,7 +38,8 @@ deps=
flake8-docstrings
flake8-bugbear
commands=
flake8 {toxinidir}/src/memote {toxinidir}/tests {toxinidir}/setup.py
flake8 {toxinidir}/src/memote {toxinidir}/setup.py
# flake8 {toxinidir}/src/memote {toxinidir}/tests {toxinidir}/setup.py

[testenv:safety]
deps=
Expand Down Expand Up @@ -66,21 +67,6 @@ testpaths =
markers =
raises

[coverage:paths]
source =
src/memote
*/site-packages/memote

[coverage:run]
branch = true
parallel = true

[coverage:report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
precision = 2

[flake8]
max-line-length = 88
exclude =
Expand Down

0 comments on commit ea06738

Please sign in to comment.