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

[24.0] Fix anonymous user job retrieval logic #18358

Conversation

davelopez
Copy link
Contributor

Follow up to #18333

For anonymous users, if a history_id is provided, do not override it with the current session history; instead, rely on the history accessibility.

Hopefully addresses #18333 (comment)

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

For anonymous users, if a history_id is provided, do not override with the current session history and instead rely on the history accessibility
):
# If the user is anonymous and no specific history_id was provided
# we can only return jobs from the history in the current session
history_id = trans.galaxy_session.current_history_id
Copy link
Member

@mvdbeek mvdbeek Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest filtering on the session id instead, that feel more direct ? Then you can change line 226-227 to

 if history_id is None and invocation_id is None and implicit_collection_jobs_id is None:
    # If we're not filtering on history, invocation or collection we filter the jobs owned by the current user
    if trans.user:
        stmt = stmt.where(Job.user_id == trans.user.id)
    elif trans.galaxy_session:
        stmt = stmt.where(Job.session_id == trans.galaxy_session.id)
    else:
        return None

(or instead of None the @nsoranzo variant to require a session ... I think we have an API decorator or depend method to annotate this on the API endpoint.)

@davelopez davelopez marked this pull request as draft June 10, 2024 11:06
@davelopez davelopez marked this pull request as ready for review June 10, 2024 11:37
@mvdbeek mvdbeek requested a review from nsoranzo June 10, 2024 11:47
Copy link
Member

@mvdbeek mvdbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

elif trans.galaxy_session:
stmt = stmt.where(Job.session_id == trans.galaxy_session.id)
else:
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, nice improvement! Going back to my original point, maybe raise an exception here?
It looks to me that an API client should either pass one of the 3 IDs or have at least an active session.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I can do that, no-op seems fine, but I guess an error message will be more informative for API users in case they miss the parameter accidentally.

@davelopez davelopez force-pushed the 24.0_fix_condition_anonymous_jobs branch from 1a852de to 1e98b9d Compare June 10, 2024 14:31
@davelopez davelopez force-pushed the 24.0_fix_condition_anonymous_jobs branch from 1e98b9d to 9df23a6 Compare June 10, 2024 14:34
Copy link
Member

@nsoranzo nsoranzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@martenson martenson merged commit d7dad3a into galaxyproject:release_24.0 Jun 11, 2024
49 checks passed
@davelopez davelopez deleted the 24.0_fix_condition_anonymous_jobs branch June 11, 2024 08:23
@jdavcs jdavcs added this to the 24.1 milestone Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants