-
Notifications
You must be signed in to change notification settings - Fork 114
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 Session Handling #481
base: main
Are you sure you want to change the base?
Add Session Handling #481
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the PR! Can you also have a look at the linting errors (the test failures are about to be fixed in the main branch).
TypeError: typing.Optional requires a single type. Got <requests.sessions.Session object at 0x101161040>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! A few more suggestions for your example scripts.
|
||
with requests.Session() as session: | ||
session.cookies = cookie_jar | ||
session.verify = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default:
session.verify = True |
GALAXY_KEY = "user_api_key" | ||
WORKFLOW_NAME = "workflow_name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move these 2 constants to the top with the other constants?
from bioblend.galaxy import GalaxyInstance | ||
|
||
|
||
def get_inputs(server, api_key, workflow_name, session=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_inputs(server, api_key, workflow_name, session=None): | |
def get_inputs(gi, workflow_name): |
Usage: | ||
get_inputs( | ||
server = "galaxy.server.org", | ||
api_key = "user_api_key", | ||
workflow_name = "workflow_name", | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage: | |
get_inputs( | |
server = "galaxy.server.org", | |
api_key = "user_api_key", | |
workflow_name = "workflow_name", | |
) |
server (string): Galaxy server address | ||
api_key (string): User generated string from galaxy instance | ||
to create: User > Preferences > Manage API Key > Create a new key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server (string): Galaxy server address | |
api_key (string): User generated string from galaxy instance | |
to create: User > Preferences > Manage API Key > Create a new key | |
gi: GalaxyInstance object |
print(response) | ||
|
||
print("Getting inputs for a workflow") | ||
response = get_inputs(f"https://{API_HOSTNAME}", GALAXY_KEY, WORKFLOW_NAME, session=session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response = get_inputs(f"https://{API_HOSTNAME}", GALAXY_KEY, WORKFLOW_NAME, session=session) | |
response = get_inputs(gi, WORKFLOW_NAME) |
Usage: | ||
get_workflows( | ||
server = "galaxy.server.org", | ||
api_key = "user_api_key", | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage: | |
get_workflows( | |
server = "galaxy.server.org", | |
api_key = "user_api_key", | |
) |
return inputs | ||
|
||
|
||
def get_workflows(server, api_key, session=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_workflows(server, api_key, session=None): | |
def get_workflows(gi): |
Returns: | ||
workflows (array of strings): Workflows available to be run on the galaxy instance provided | ||
""" | ||
gi = GalaxyInstance(url=server, key=api_key, session=session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gi = GalaxyInstance(url=server, key=api_key, session=session) |
server (string): Galaxy server address | ||
api_key (string): User generated string from galaxy instance | ||
to create: User > Preferences > Manage API Key > Create a new key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server (string): Galaxy server address | |
api_key (string): User generated string from galaxy instance | |
to create: User > Preferences > Manage API Key > Create a new key | |
gi: GalaxyInstance object |
@williamjsmith15 I was thinking, what if we pass |
Adds session handling for the BioBlend API library so that cookies can be used for an authentication layer external to Galaxy.
Fixes #480
Example of use in the docs/examples/session_handling/cookie_handler.py script. Note: this would need a Galaxy instance configured behind an authentication system.