Skip to content

Commit ac04be0

Browse files
authored
Merge pull request #57 from nova-model/56-check-for-redirects-from-the-galaxy-url-before-connecting
Follow redirects
2 parents 06e739c + c77d89a commit ac04be0

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
## Nova Galaxy 0.12.0 (in progress)
22

3+
### Nova Galaxy 0.11.4
4+
- Allows connecting to a Galaxy URL that returns a redirect (thanks to John Duggan). [Pull request 57](https://github.com/nova-model/nova-galaxy/pull/57)
5+
6+
### Nova Galaxy 0.11.3
7+
- Minor fixes for workflow parameters (thanks to Andrew Ayres). [Pull request 53](https://github.com/nova-model/nova-galaxy/pull/53)
8+
9+
### Nova Galaxy 0.11.2
10+
- Workflow parameters are now more explicitly defined (thanks to Andrew Ayres). [Commit](https://github.com/nova-model/nova-galaxy/commit/fc7ca763c400698e51f81c99764bb8c696b6ecca)
11+
312
### Nova Galaxy 0.11.1
413
- Improved the performance of Job.get_url when check_url parameter is set to False (thanks to John Duggan). [Pull request 43](https://github.com/nova-model/nova-galaxy/pull/43)
514

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "nova-galaxy"
3-
version = "0.11.3"
3+
version = "0.11.4"
44
description = "Utilties for accessing the ORNL Galaxy instance"
55
authors = [
66
{ name = "Greg Watson", email = "watsongr@ornl.gov" },

src/nova/galaxy/connection.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""The NOVA class is responsible for managing interactions with a Galaxy server instance."""
22

33
from typing import Any, List
4+
from urllib.parse import urlparse
45

56
from bioblend import galaxy
67
from deprecated import deprecated
8+
from requests import head
79

810
from .data_store import Datastore
911
from .tool import stop_all_tools_in_store
@@ -137,8 +139,8 @@ class Connection:
137139
138140
Attributes
139141
----------
140-
galaxy_url (Optional[str]): URL of the Galaxy instance.
141-
galaxy_api_key (Optional[str]): API key for the Galaxy instance.
142+
galaxy_url (str): URL of the Galaxy instance.
143+
galaxy_api_key (str): API key for the Galaxy instance.
142144
"""
143145

144146
def __init__(
@@ -153,7 +155,13 @@ def __init__(
153155
galaxy_url str: URL of the Galaxy instance.
154156
galaxy_key str: API key for the Galaxy instance.
155157
"""
156-
self.galaxy_url = galaxy_url
158+
# Check for redirects on the URL and follow them to the final Galaxy URL.
159+
response = head(galaxy_url, allow_redirects=True)
160+
resolved_url = response.url
161+
parsed_url = urlparse(resolved_url)
162+
new_galaxy_url = f"{parsed_url.scheme}://{parsed_url.hostname}"
163+
164+
self.galaxy_url = new_galaxy_url
157165
self.galaxy_api_key = galaxy_key
158166
self.galaxy_instance: galaxy.GalaxyInstance
159167

0 commit comments

Comments
 (0)