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

SA2.0 updates: handling "object is being merged into a Session along the backref cascade path" #17122

Merged
merged 43 commits into from Dec 6, 2023

Conversation

jdavcs
Copy link
Member

@jdavcs jdavcs commented Dec 1, 2023

Ref: #12541
(SA documentation refs: 1, 2, 3)

See the referenced documentation for a detailed description of the issue. This should eliminate 200+ SA2.0 warnings.

Notes:
if a cascade_backrefs=False clause is added to the relationship definition without any additional edits, that means that the addition is, most likely, inconsequential - i.e., the object is explicitly added to the appropriate session within the same block of code. Additional safeguard code in the same commit implies that we have to mimic the current behavior to ensure that turning off automated cascading via backref on the relationship will not lead to an object not being added to the session. (I doubt this would happen: judging by our code, we've been careful to add objects to the session explicitly; still, it's not impossible, so adding the safeguard seems a safe temporary step - we can remove it once we're running under SA2.0).

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.

@jdavcs jdavcs added kind/refactoring cleanup or refactoring of existing code, no functional changes area/database Galaxy's database or data access layer labels Dec 1, 2023
@jdavcs jdavcs marked this pull request as ready for review December 4, 2023 20:42
@github-actions github-actions bot added this to the 23.2 milestone Dec 4, 2023
@jdavcs
Copy link
Member Author

jdavcs commented Dec 5, 2023

I've added fixes to the last 4 cases of this warning - there're no more left, so this is done/ready for review.

@mvdbeek mvdbeek self-requested a review December 5, 2023 15:23
@@ -818,6 +819,12 @@ def _workflow_from_raw_description(

workflow.has_cycles = True
workflow.steps = steps
# Safeguard: workflow was implicitly merged into this Session prior to SQLAlchemy 2.0.
Copy link
Member

Choose a reason for hiding this comment

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

And I think that was a bug ? Either we add workflow or stored workflow or we don't ?
Is anything breaking if you remove this ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know - I haven't tried running all tests without this safeguard but with the cascade disabled for this relationship. My plan is to (1) add these safeguards to mimic the current behavior, (2) verify that nothing breaks, (3) turn on the future flag on session, and (4) remove the safeguards. I'm trying to do minimal/incremental changes to simplify debugging in case things break. I'm not opposed to fixing things here, but I'd rather be too careful.

@@ -3669,6 +3690,9 @@ def __init__(self, type, quota):
assert type in self.types.__members__.values(), "Invalid type"
self.type = type
self.quota = quota
# Safeguard: self was implicitly merged into this Session prior to SQLAlchemy 2.0.
Copy link
Member

Choose a reason for hiding this comment

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

since these are always the same and we may want to eliminate those patterns: can you move this into a utility function so we can disable this in one go later on ?

Copy link
Member Author

@jdavcs jdavcs Dec 5, 2023

Choose a reason for hiding this comment

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

sure! I considered this, but opted to keep the verbose version so it's not mistaken for a permanent feature. I'll make it a function.

@mvdbeek mvdbeek merged commit 9398079 into galaxyproject:dev Dec 6, 2023
47 of 49 checks passed
@mvdbeek
Copy link
Member

mvdbeek commented Dec 6, 2023

Awesome, thanks a lot @jdavcs!

@mvdbeek mvdbeek modified the milestones: 23.2, 24.0 Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/database Galaxy's database or data access layer kind/refactoring cleanup or refactoring of existing code, no functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants