Skip to content

Commit

Permalink
Add a method that output server module versions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellevstek committed Nov 8, 2024
1 parent 39a69ba commit deceb54
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Added
-----
- Add support for predictions
- Add version to annotation field
- Add a resolwe method for fetching the server module versions


===================
Expand Down
12 changes: 11 additions & 1 deletion src/resdk/resolwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from resdk.uploader import Uploader

from .constants import CHUNK_SIZE
from .exceptions import ValidationError, handle_http_exception
from .exceptions import ResolweServerError, ValidationError, handle_http_exception
from .query import (
AnnotationFieldQuery,
AnnotationValueQuery,
Expand Down Expand Up @@ -65,6 +65,7 @@
AUTOMATIC_LOGIN_POSTFIX = "saml-auth/api-login/"
INTERACTIVE_LOGIN_POSTFIX = "saml-auth/remote-login/"
MINIMAL_SUPPORTED_VERSION_POSTFIX = "api/resdk_minimal_supported_version"
SERVER_MODULE_VERSIONS_POSTFIX = "/about/versions"


class ResolweResource(slumber.Resource):
Expand Down Expand Up @@ -212,6 +213,15 @@ def version_check(self):
"Warning: unable to read the minimal supported version from the server."
)

def version_output(self) -> dict:
"""Output the version of the server modules."""
url = urljoin(self.url, SERVER_MODULE_VERSIONS_POSTFIX)
try:
response = requests.get(url)
except requests.exceptions.RequestException:
raise ResolweServerError("Unable to read the server version.")
return response.json()

def _validate_url(self, url):
if not re.match(r"https?://", url):
raise ValueError("Server url must start with http(s)://")
Expand Down

0 comments on commit deceb54

Please sign in to comment.