From db13804bba4f3d483f663cc7a1691c8cee481952 Mon Sep 17 00:00:00 2001 From: Kyle Ferriter Date: Wed, 23 Jul 2025 14:20:17 -0400 Subject: [PATCH 1/4] Remove vcf annotator healthcheck --- src/ga4gh/vrs/extras/annotator/cli.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ga4gh/vrs/extras/annotator/cli.py b/src/ga4gh/vrs/extras/annotator/cli.py index a015698e..4ebdb206 100644 --- a/src/ga4gh/vrs/extras/annotator/cli.py +++ b/src/ga4gh/vrs/extras/annotator/cli.py @@ -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 @@ -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..." From 499f173ecfbb6fa80e2b59b1d951db0310341936 Mon Sep 17 00:00:00 2001 From: Kyle Ferriter Date: Wed, 23 Jul 2025 15:12:36 -0400 Subject: [PATCH 2/4] Add __init__ check to SeqRepoRESTDataProxy. --- src/ga4gh/vrs/dataproxy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ga4gh/vrs/dataproxy.py b/src/ga4gh/vrs/dataproxy.py index 8e593069..e79ad4d2 100644 --- a/src/ga4gh/vrs/dataproxy.py +++ b/src/ga4gh/vrs/dataproxy.py @@ -254,6 +254,9 @@ def __init__(self, base_url: str): """ super().__init__() self.base_url = f"{base_url}/{self.rest_version}/" + 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 From 8012bc55d44da543044f675d9aae5153993837f8 Mon Sep 17 00:00:00 2001 From: Kyle Ferriter Date: Wed, 17 Dec 2025 15:04:49 -0500 Subject: [PATCH 3/4] Update cassettes --- .../test_annotate_vcf_grch37_attrs.yaml | 16 ++++++++++++++++ .../test_annotate_vcf_grch38_attrs.yaml | 16 ++++++++++++++++ .../test_annotate_vcf_grch38_attrs_altsonly.yaml | 16 ++++++++++++++++ .../test_annotate_vcf_grch38_noattrs.yaml | 16 ++++++++++++++++ .../cassettes/test_annotate_vcf_pickle_only.yaml | 16 ++++++++++++++++ .../extras/cassettes/test_annotate_vcf_rle.yaml | 16 ++++++++++++++++ .../cassettes/test_annotate_vcf_vcf_only.yaml | 16 ++++++++++++++++ .../test_get_vrs_object_invalid_input.yaml | 16 ++++++++++++++++ 8 files changed, 128 insertions(+) diff --git a/tests/extras/cassettes/test_annotate_vcf_grch37_attrs.yaml b/tests/extras/cassettes/test_annotate_vcf_grch37_attrs.yaml index be51c7b6..4808b890 100644 --- a/tests/extras/cassettes/test_annotate_vcf_grch37_attrs.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_grch37_attrs.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_grch38_attrs.yaml b/tests/extras/cassettes/test_annotate_vcf_grch38_attrs.yaml index 48f1f0db..11fe7069 100644 --- a/tests/extras/cassettes/test_annotate_vcf_grch38_attrs.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_grch38_attrs.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_grch38_attrs_altsonly.yaml b/tests/extras/cassettes/test_annotate_vcf_grch38_attrs_altsonly.yaml index 48f1f0db..11fe7069 100644 --- a/tests/extras/cassettes/test_annotate_vcf_grch38_attrs_altsonly.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_grch38_attrs_altsonly.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_grch38_noattrs.yaml b/tests/extras/cassettes/test_annotate_vcf_grch38_noattrs.yaml index 48f1f0db..11fe7069 100644 --- a/tests/extras/cassettes/test_annotate_vcf_grch38_noattrs.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_grch38_noattrs.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_pickle_only.yaml b/tests/extras/cassettes/test_annotate_vcf_pickle_only.yaml index 48f1f0db..11fe7069 100644 --- a/tests/extras/cassettes/test_annotate_vcf_pickle_only.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_pickle_only.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_rle.yaml b/tests/extras/cassettes/test_annotate_vcf_rle.yaml index 2ba6fd04..5f027f36 100644 --- a/tests/extras/cassettes/test_annotate_vcf_rle.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_rle.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_annotate_vcf_vcf_only.yaml b/tests/extras/cassettes/test_annotate_vcf_vcf_only.yaml index 48f1f0db..11fe7069 100644 --- a/tests/extras/cassettes/test_annotate_vcf_vcf_only.yaml +++ b/tests/extras/cassettes/test_annotate_vcf_vcf_only.yaml @@ -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: {} diff --git a/tests/extras/cassettes/test_get_vrs_object_invalid_input.yaml b/tests/extras/cassettes/test_get_vrs_object_invalid_input.yaml index 11a2ee4b..8055c3b5 100644 --- a/tests/extras/cassettes/test_get_vrs_object_invalid_input.yaml +++ b/tests/extras/cassettes/test_get_vrs_object_invalid_input.yaml @@ -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: {} From 9f63a682c93f13f38cf42295347fe1df29281d07 Mon Sep 17 00:00:00 2001 From: Kyle Ferriter Date: Wed, 17 Dec 2025 15:49:07 -0500 Subject: [PATCH 4/4] Make SeqRepoRESTDataProxy healthcheck in constructor optional. Update one test to add vcr. Re-record cassettes. --- src/ga4gh/vrs/dataproxy.py | 9 +++++---- tests/conftest.py | 3 ++- .../test_annotate_vcf_input_validation.yaml | 18 ++++++++++++++++++ tests/extras/test_annotate_vcf.py | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/extras/cassettes/test_annotate_vcf_input_validation.yaml diff --git a/src/ga4gh/vrs/dataproxy.py b/src/ga4gh/vrs/dataproxy.py index e79ad4d2..12c70790 100644 --- a/src/ga4gh/vrs/dataproxy.py +++ b/src/ga4gh/vrs/dataproxy.py @@ -247,16 +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}/" - ping_url = self.base_url + "ping" - ping_resp = requests.get(ping_url) # noqa: S113 - ping_resp.raise_for_status() + 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 diff --git a/tests/conftest.py b/tests/conftest.py index 97b5b02c..4c843539 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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, ) diff --git a/tests/extras/cassettes/test_annotate_vcf_input_validation.yaml b/tests/extras/cassettes/test_annotate_vcf_input_validation.yaml new file mode 100644 index 00000000..be104761 --- /dev/null +++ b/tests/extras/cassettes/test_annotate_vcf_input_validation.yaml @@ -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 diff --git a/tests/extras/test_annotate_vcf.py b/tests/extras/test_annotate_vcf.py index 7e085f2d..0f5ca0e6 100644 --- a/tests/extras/test_annotate_vcf.py +++ b/tests/extras/test_annotate_vcf.py @@ -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,