From 9649c42efa0cbddaf26afb130b41c4a7a5b9d586 Mon Sep 17 00:00:00 2001 From: Khoroshevskyi Date: Thu, 21 Nov 2024 18:20:18 -0500 Subject: [PATCH] 1. added timeout 10 sec for responses 2. added unwrapping for reg path --- docs/changelog.md | 5 +++++ pephubclient/__init__.py | 2 +- pephubclient/helpers.py | 10 ++++++++++ tests/test_manual.py | 1 - tests/test_pephubclient.py | 1 - 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 5237b03..60b4ff2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format. +## [0.4.5] - 2024-11-21 +### Added +- Function for unwrapping PEPhub registry path +- Timeout for requests + ## [0.4.4] - 2024-08-21 ### Fixed - Project annotation model diff --git a/pephubclient/__init__.py b/pephubclient/__init__.py index f950988..a099d01 100644 --- a/pephubclient/__init__.py +++ b/pephubclient/__init__.py @@ -4,7 +4,7 @@ import coloredlogs __app_name__ = "pephubclient" -__version__ = "0.4.4" +__version__ = "0.4.5" __author__ = "Oleksandr Khoroshevskyi, Rafal Stepien" diff --git a/pephubclient/helpers.py b/pephubclient/helpers.py index f2911ce..dcd9b51 100644 --- a/pephubclient/helpers.py +++ b/pephubclient/helpers.py @@ -45,6 +45,7 @@ def send_request( headers=headers, params=params, json=json, + timeout=10, ) if request_return.status_code == 401: if ( @@ -160,6 +161,15 @@ def is_registry_path(input_string: str) -> bool: return True +def unwrap_registry_path(input_string: str) -> RegistryPath: + """ + Unwrap registry path from string + :param str input_string: path to the PEP (or registry path) + :return RegistryPath: RegistryPath object + """ + return RegistryPath(**parse_registry_path(input_string)) + + def _build_filename(registry_path: RegistryPath) -> str: """ Takes query string and creates output filename to save the project to. diff --git a/tests/test_manual.py b/tests/test_manual.py index 1848210..cac8be0 100644 --- a/tests/test_manual.py +++ b/tests/test_manual.py @@ -4,7 +4,6 @@ @pytest.mark.skip(reason="Manual test") class TestViewsManual: - def test_get(self): ff = PEPHubClient().view.get( "databio", diff --git a/tests/test_pephubclient.py b/tests/test_pephubclient.py index 5c89177..211a143 100644 --- a/tests/test_pephubclient.py +++ b/tests/test_pephubclient.py @@ -231,7 +231,6 @@ def test_is_registry_path(self, input_str, expected_output): class TestSamples: - def test_get(self, mocker): return_value = { "genome": "phc_test1",