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

Add a method that outputs server module versions #363

Merged
merged 1 commit into from
Nov 8, 2024
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
9 changes: 1 addition & 8 deletions docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,9 @@ Added
-----
- Add an argument for custom file naming of downloaded files
and propagate this change in ``Data`` resource


==========
Unreleased
==========

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