Skip to content

Commit

Permalink
Add functionaility for session based get requests
Browse files Browse the repository at this point in the history
To allow for the cookie from the reverse proxy to propogate through
the bioblend API requests - still need to do for all other requests
Good start through
  • Loading branch information
williamjsmith15 committed Sep 19, 2023
1 parent fe48906 commit d34286f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bioblend/galaxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from typing import Optional

import requests
from bioblend.galaxy import (
config,
container_resolution,
Expand Down Expand Up @@ -39,6 +40,7 @@ def __init__(
email: Optional[str] = None,
password: Optional[str] = None,
verify: bool = True,
session: requests.sessions.Session() = None,
) -> None:
"""
A base representation of a connection to a Galaxy instance, identified
Expand Down Expand Up @@ -106,6 +108,7 @@ def __init__(
self.tool_data = tool_data.ToolDataClient(self)
self.folders = folders.FoldersClient(self)
self.tool_dependencies = tool_dependencies.ToolDependenciesClient(self)
self.session = session

def __repr__(self) -> str:
"""
Expand Down
3 changes: 3 additions & 0 deletions bioblend/galaxy/objects/galaxy_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import bioblend
import bioblend.galaxy
import requests
from bioblend.galaxy.datasets import TERMINAL_STATES
from . import (
client,
Expand Down Expand Up @@ -57,6 +58,7 @@ def __init__(
email: Optional[str] = None,
password: Optional[str] = None,
verify: bool = True,
session: requests.sessions.Session() = None,
) -> None:
self.gi = bioblend.galaxy.GalaxyInstance(url, api_key, email, password, verify)
self.log = bioblend.log
Expand All @@ -68,6 +70,7 @@ def __init__(
self.invocations = client.ObjInvocationClient(self)
self.tools = client.ObjToolClient(self)
self.jobs = client.ObjJobClient(self)
self.session = session

def _wait_datasets(
self, datasets: Iterable[wrappers.Dataset], polling_interval: float, break_on_error: bool = True
Expand Down
3 changes: 2 additions & 1 deletion bioblend/galaxyclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
password: Optional[str] = None,
verify: bool = True,
timeout: Optional[float] = None,
session: requests.sessions.Session() = None,
) -> None:
"""
:param verify: Whether to verify the server's TLS certificate
Expand Down Expand Up @@ -133,7 +134,7 @@ def make_get_request(self, url: str, **kwargs: Any) -> requests.Response:
headers = self.json_headers
kwargs.setdefault("timeout", self.timeout)
kwargs.setdefault("verify", self.verify)
r = requests.get(url, headers=headers, **kwargs)
r = self.session.get(url, headers=headers, **kwargs)
return r

def make_post_request(
Expand Down

0 comments on commit d34286f

Please sign in to comment.