-
Notifications
You must be signed in to change notification settings - Fork 1k
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 source history update_time being updated when importing a public history #17728
[24.0] Fix source history update_time being updated when importing a public history #17728
Conversation
I think the update bug does not appear at the model level because the functionality is defined correctly at the model level. I have another unit test to verify this (from a draft, post-SA2.0 branch): ce17483 - it checks that history.update_time is updated after a history hda is created or updated, but not after a history hda is copied - i.e., as expected. |
…ry_dataset_association
e3f135d should fix it. I debugged this by checking at which point the history update_time changed, which was right after creating the HDA. I then removed the source hda via session.expunge and committed the session, which emitted an sqlalchemy warning that the copied_from_history_dataset_association backref could not be followed. Simply setting just the id instead of adding in the whole instance fixed it. |
well, that's fun, the |
sidenote: We might be doing the same thing with |
most likely, when you changed the arg to copy, it broke something. For example, you are no longer assigning |
It is though, see #17728 (comment) |
Yes, i've read that comment. What adds the original hda to session.dirty is the metadata. As soon as you instantiate the new hda (inside the hda' copy method), the original hda (i.e., self) gains 2 new attributes:
I suppose that's what makes it dirty. Where they come from I don't know yet - just got there, looking now. |
That still doesn't make sense, since removing |
and dirty is just some heuristic that doesn't necessarily mean anything is getting updated, see https://docs.sqlalchemy.org/en/20/orm/session_api.html#sqlalchemy.orm.Session.dirty |
This fixes the unit test: diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py
index 3b8dc6fa2d..53d238ee7a 100644
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -4985,7 +4985,6 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
self,
hid=None,
history=None,
- copied_from_history_dataset_association=None,
copied_from_library_dataset_dataset_association=None,
sa_session=None,
**kwd,
@@ -4999,7 +4998,6 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
self.hid = hid
# Relationships
self.history = history
- self.copied_from_history_dataset_association = copied_from_history_dataset_association
self.copied_from_library_dataset_dataset_association = copied_from_library_dataset_dataset_association
def __strict_check_before_flush__(self):
@@ -5100,10 +5098,10 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
hda.purged = self.purged
hda.copy_tags_to(copy_tags)
- object_session(self).add(hda)
+ session = object_session(self)
+ session.add(hda)
hda.metadata = self.metadata
if flush:
- session = object_session(self)
with transaction(session):
session.commit()
return hda
which I admit is crazy ... |
I didn't test that with your latest commit: so |
…ory_dataset_association.id Otherwise sqlachemy will think `None` is the value we've set. A lesson we seem to have already learnt with https://github.com/galaxyproject/galaxy/blob/429c63e8563f98237770e43d94b25fdacf4ede58/lib/galaxy/model/__init__.py#L5785-L5788
Was added in galaxyproject@75ba9cf and i'm reverting this part back to the original code that now passes since I've added the correct type hint to DatasetInstance.
I've investigated this and I think I now understand what's going on. The root cause is what changes in the source HDA when nothing should. Here's what happens:
I think the solution is not to update the HDA version if nothing in the HDA is changed. If so, the implementation might be as simple as this: jdavcs@518cb58 . Does this make sense? |
It's a good commit, however on |
Yep, found step X. Accessing |
Includes a failing test for history copying updating the history update_time.
I believe I've seen this behavior for a long time but I'm happy to work on a fix for it and a test is a good place to start.
Fixes #17702
How to test the changes?
(Select all options that apply)
License