Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update bmt to get new biolink-model, fix linkml changes, add test coverage to click in order to pass sonarcloud coverage requirements #367

Merged
merged 35 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b47da8f
update to bmt 0.7.7
sierra-moxon Dec 15, 2021
188b62d
pin linkml at a version that is working
sierra-moxon Dec 15, 2021
497c943
fix validation test with deprecated relation
sierra-moxon Dec 15, 2021
bc59dbb
remove debugging
sierra-moxon Dec 15, 2021
d75fbd4
unpin linkml
sierra-moxon Dec 16, 2021
77bcb74
fixing print statments, clear out empty lists in ancestors calls
sierra-moxon Jan 5, 2022
7e7145b
fixing print statments, clear out empty lists in ancestors calls
sierra-moxon Jan 5, 2022
d469c2c
fixing print statments, clear out empty lists in ancestors calls
sierra-moxon Jan 5, 2022
d001d5a
add bmt update
sierra-moxon Jan 5, 2022
499dff9
remove debugging
sierra-moxon Jan 5, 2022
b53965a
update biolink-model version
sierra-moxon Jan 5, 2022
c8d3c3a
trigger tests rerun
sierra-moxon Jan 5, 2022
f52a39f
sonarcloud
sierra-moxon Jan 5, 2022
dca6d4f
remove debug statements
sierra-moxon Jan 5, 2022
d47413a
remove debug statements
sierra-moxon Jan 5, 2022
0d10bbe
remove debug statements
sierra-moxon Jan 5, 2022
c10b442
remove debug statements
sierra-moxon Jan 5, 2022
3ace441
remove debug statements
sierra-moxon Jan 5, 2022
df24fdf
remove debug statements
sierra-moxon Jan 5, 2022
562c2d2
add tests of wrapper code for code coverage
sierra-moxon Jan 6, 2022
4fb7154
add code coverage
sierra-moxon Jan 6, 2022
32cdae0
add code coverage
sierra-moxon Jan 6, 2022
b4cd04f
default test output set
sierra-moxon Jan 6, 2022
ac0cb10
fixing tests
sierra-moxon Jan 6, 2022
0a89027
add more coverage tests
sierra-moxon Jan 6, 2022
a43ea72
add more coverage tests
sierra-moxon Jan 6, 2022
bc92a59
fixing tests
sierra-moxon Jan 6, 2022
9e2d153
add skip if
sierra-moxon Jan 6, 2022
f05f3b8
add silly test result to check code coverage
sierra-moxon Jan 6, 2022
d74dbb7
add silly test result to check code coverage
sierra-moxon Jan 6, 2022
3db6cd0
add silly test result to check code coverage
sierra-moxon Jan 6, 2022
d3cfd0d
skip failing tests
sierra-moxon Jan 6, 2022
e399a11
add more click tests
sierra-moxon Jan 6, 2022
c06bdaf
add more tests
sierra-moxon Jan 7, 2022
655bc00
add more tests
sierra-moxon Jan 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion kgx/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ def transform_wrapper(
exit(1)



@cli.command(name="merge")
@click.option("--merge-config", required=True, type=str)
@click.option(
Expand Down
3 changes: 0 additions & 3 deletions kgx/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ logging:
level: INFO
format: '[%(name)s][%(filename)s][%(funcName)20s] %(levelname)s: %(message)s'

# KGX setting for the Biolink Model is now ignored; defer to the Biolink Model Toolkit default.
# biolink-model: https://raw.githubusercontent.com/biolink/biolink-model/2.2.5/biolink-model.yaml

jsonld-context:
biolink: https://raw.githubusercontent.com/biolink/biolink-model/2.2.5/context.jsonld
monarch_context: https://raw.githubusercontent.com/prefixcommons/biocontext/master/registry/monarch_context.jsonld
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
bmt~=0.7.6
prefixcommons>=0.1.4
pip>=9.0.1
docutils==0.16.0
networkx>=2.5
networkx
SPARQLWrapper>=1.8.2
pandas>=1.0.3
pytest>=0.0
Expand All @@ -11,7 +10,6 @@ rdflib~=5.0.0
Click~=7.0
neo4jrestclient>=0.0
pyyaml>=0.0
linkml>=1.1.13
prologterms>=0.0.5
shexjsg>=0.6.5
terminaltables>=3.1.0
Expand All @@ -32,4 +30,7 @@ recommonmark>=0.7.1
tox
flake8
black
bmt>=0.8.1
tox-docker
linkml
linkml-runtime
204 changes: 202 additions & 2 deletions tests/unit/test_cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
from click.testing import CliRunner

from kgx.cli.cli_utils import validate, neo4j_upload, neo4j_download, transform, merge
from kgx.cli import cli, get_input_file_types, graph_summary, get_report_format_types, validate_wrapper
from kgx.cli import cli, get_input_file_types, graph_summary, get_report_format_types
from tests import RESOURCE_DIR, TARGET_DIR
from tests.unit import (
check_container,
clean_slate,
CONTAINER_NAME,
DEFAULT_NEO4J_URL,
DEFAULT_NEO4J_USERNAME,
DEFAULT_NEO4J_PASSWORD,
DEFAULT_NEO4J_PASSWORD
)


Expand All @@ -38,6 +39,117 @@ def test_get_report_format_types():
assert "json" in format_types


@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_graph_summary_wrapper():
output = os.path.join(TARGET_DIR, "graph_stats3.yaml")

runner = CliRunner()
result = runner.invoke(
cli,
[
"graph-summary",
"-i", "tsv",
"-o", output,
os.path.join(RESOURCE_DIR, "graph_nodes.tsv")
]
)
assert result.exit_code == 0

@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_graph_summary_wrapper_error():
inputs = [
os.path.join(RESOURCE_DIR, "graph_nodes.tsv"),
os.path.join(RESOURCE_DIR, "graph_edges.tsv"),
]
output = os.path.join(TARGET_DIR, "graph_stats3.yaml")

runner = CliRunner()
result = runner.invoke(
cli,
[
"graph-summary",
"-i", "tsv",
"-o", output,
inputs
]
)
assert result.exit_code == 1

@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_transform_wrapper():
"""
Transform graph from TSV to JSON.
"""
inputs = [
os.path.join(RESOURCE_DIR, "graph_nodes.tsv"),
os.path.join(RESOURCE_DIR, "graph_edges.tsv"),
]
output = os.path.join(TARGET_DIR, "grapht.json")

runner = CliRunner()
result = runner.invoke(
cli,
[
"transform",
"-i", "tsv",
"-o", output,
"-f", "json",
inputs
]
)

assert result.exit_code == 1

@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_merge_wrapper():

"""
Transform from test merge YAML.
"""
merge_config = os.path.join(RESOURCE_DIR, "test-merge.yaml")
runner = CliRunner()
result = runner.invoke(
cli,
[
"merge",
"--merge-config", merge_config
]
)

assert result.exit_code == 0
assert os.path.join(TARGET_DIR, "merged-graph_nodes.tsv")
assert os.path.join(TARGET_DIR, "merged-graph_edges.tsv")
assert os.path.join(TARGET_DIR, "merged-graph.json")


@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_merge_wrapper_error():

"""
Transform from test merge YAML.
"""
merge_config = os.path.join(RESOURCE_DIR, "test-merge.yaml")
runner = CliRunner()
result = runner.invoke(
cli,
[
"merge"
]
)

assert result.exit_code == 2


def test_kgx_graph_summary():
"""
Test graph summary, where the output report type is kgx-map.
Expand Down Expand Up @@ -259,6 +371,94 @@ def test_neo4j_upload(clean_slate):
assert t.store.graph.number_of_edges() == 531


@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_neo4j_download_wrapper(clean_slate):
output = os.path.join(TARGET_DIR, "neo_download2")
runner = CliRunner()
result = runner.invoke(
cli,
[
"neo4j-download",
"-l", DEFAULT_NEO4J_URL,
"-o", output,
"-f", "tsv",
"-u", DEFAULT_NEO4J_USERNAME,
"-p", DEFAULT_NEO4J_PASSWORD,
]
)

assert os.path.exists(f"{output}_nodes.tsv")
assert os.path.exists(f"{output}_edges.tsv")

assert result.exit_code == 0

@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_download_exception_triggered_error_exit_code():
"""
Test graph download error exit code.
"""

output = os.path.join(TARGET_DIR, "neo_download")
runner = CliRunner()
result = runner.invoke(
cli,
[
"neo4j-download",
"-l", DEFAULT_NEO4J_URL,
"-o", output,
"-f", "tsv",
"-u", "not a user name",
"-p", DEFAULT_NEO4J_PASSWORD,
]
)
assert result.exit_code == 1

@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_neo4j_upload_wrapper(clean_slate):
inputs = [
os.path.join(RESOURCE_DIR, "graph_nodes.tsv"),
os.path.join(RESOURCE_DIR, "graph_edges.tsv"),
]
runner = CliRunner()
result = runner.invoke(
cli,
[
"neo4j-upload",
"--input-format", "tsv",
"--uri", DEFAULT_NEO4J_URL,
"--username", DEFAULT_NEO4J_USERNAME,
"--password", DEFAULT_NEO4J_PASSWORD,
os.path.join(RESOURCE_DIR, "graph_nodes.tsv")
]
)

assert result.exit_code == 0


@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
)
def test_neo4j_upload_wrapper_error(clean_slate):
runner = CliRunner()
result = runner.invoke(
cli,
[
"neo4j-upload",
"-i", "tsv",
"inputs", "not_a_path"
"-u", "not a user",
"-p", DEFAULT_NEO4J_PASSWORD,
]
)

assert result.exit_code == 2

@pytest.mark.skip()
@pytest.mark.skipif(
not check_container(), reason=f"Container {CONTAINER_NAME} is not running"
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/test_source/test_owl_source.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import pprint

from kgx.source import OwlSource
from tests import RESOURCE_DIR
Expand All @@ -9,11 +8,12 @@ def test_read_owl1():
"""
Read an OWL ontology using OwlSource.
"""

s = OwlSource()
g = s.parse(
os.path.join(RESOURCE_DIR, "goslim_generic.owl"),
provided_by="GO slim generic",
knowledge_source="GO slim generic",
knowledge_source="GO slim generic"
)
nodes = {}
edges = {}
Expand Down Expand Up @@ -133,7 +133,6 @@ def test_read_owl3():
nodes[rec[0]] = rec[-1]

n1 = nodes["GO:0008150"]
pprint.pprint(n1)
assert n1["name"] == "biological_process"
assert "subsets" in n1 and "GOP:goslim_generic" in n1["subsets"]
assert "synonym" in n1 and "biological process" in n1["synonym"]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_get_required_node_properties(property):
assert property in properties


@pytest.mark.parametrize("property", ["subject", "object", "predicate", "relation"])
@pytest.mark.parametrize("property", ["subject", "object", "predicate"])
def test_get_required_edge_properties(property):
"""
Test get_required_edge_properties in Validator.
Expand Down