Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ga4gh/vrs/dataproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,17 @@ class SeqRepoRESTDataProxy(_SeqRepoDataProxyBase):

rest_version = "1"

def __init__(self, base_url: str):
def __init__(self, base_url: str, disable_healthcheck: bool = False):
"""Initialize REST-based dataproxy instance.

:param base_url: root URL to server
"""
super().__init__()
self.base_url = f"{base_url}/{self.rest_version}/"
if not disable_healthcheck:
ping_url = self.base_url + "ping"
ping_resp = requests.get(ping_url) # noqa: S113
ping_resp.raise_for_status()

def _get_sequence(
self, identifier: str, start: int | None = None, end: int | None = None
Expand Down
9 changes: 0 additions & 9 deletions src/ga4gh/vrs/extras/annotator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from timeit import default_timer as timer

import click
import requests

from ga4gh.vrs.dataproxy import create_dataproxy
from ga4gh.vrs.extras.annotator.vcf import VcfAnnotator, VcfAnnotatorArgsError
Expand Down Expand Up @@ -200,14 +199,6 @@ def _annotate_vcf_cli(
* seqrepo+:../relative/path/to/seqrepo/root
""" # noqa: D301
data_proxy = create_dataproxy(dataproxy_uri)
try:
data_proxy.get_metadata("GRCh38:1")
except requests.exceptions.ConnectionError:
msg = f"Connection to SeqRepo dataproxy at {dataproxy_uri} failed. Is the REST service running?"
_logger.exception(msg)
if not silent:
click.echo(msg, err=True)
exit(1)
annotator = VcfAnnotator(data_proxy)
start = timer()
msg = f"Annotating {vcf_in} with the VCF Annotator..."
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def dataproxy():
@pytest.fixture(scope="session")
def rest_dataproxy():
return SeqRepoRESTDataProxy(
base_url=os.environ.get("SEQREPO_REST_URL", "http://localhost:5000/seqrepo")
base_url=os.environ.get("SEQREPO_REST_URL", "http://localhost:5000/seqrepo"),
disable_healthcheck=True,
)


Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_grch37_attrs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_grch38_attrs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_grch38_noattrs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
18 changes: 18 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_input_validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
version: 1
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_pickle_only.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_rle.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_annotate_vcf_vcf_only.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
16 changes: 16 additions & 0 deletions tests/extras/cassettes/test_get_vrs_object_invalid_input.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
interactions:
- request:
body: null
headers: {}
method: GET
uri: http://localhost:5000/seqrepo/1/ping
response:
body:
string: "{\n \"dependencies\": {\n \"bioutils\": {\n \"url\": \"https://github.com/biocommons/bioutils/\",\n
\ \"version\": \"0.5.8.post1\"\n },\n \"seqrepo\": {\n \"root\":
\"/usr/local/share/seqrepo/2024-12-20\",\n \"url\": \"https://github.com/biocommons/biocommons.seqrepo/\",\n
\ \"version\": \"0.6.6\"\n }\n },\n \"url\": \"https://github.com/biocommons/seqrepo-rest-service/\",\n
\ \"version\": \"0.2.3.dev0+ge4124b9.d20231114\"\n}\n"
headers: {}
status:
code: 200
message: OK
- request:
body: null
headers: {}
Expand Down
1 change: 1 addition & 0 deletions tests/extras/test_annotate_vcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ def test_annotate_vcf_vcf_only(
assert not Path(output_vrs_pkl).exists()


@pytest.mark.vcr
def test_annotate_vcf_input_validation(vcf_annotator: VcfAnnotator, input_vcf: Path):
with pytest.raises(
VcfAnnotatorError,
Expand Down
Loading