127
127
reconstructor,
128
128
registry,
129
129
relationship,
130
+ remote,
130
131
validates,
131
132
)
132
133
from sqlalchemy.orm.attributes import flag_modified
@@ -5475,6 +5476,7 @@ class HistoryDatasetAssociation(DatasetInstance, HasTags, Dictifiable, UsesAnnot
5475
5476
dataset_id: Mapped[Optional[int]]
5476
5477
hidden_beneath_collection_instance: Mapped[Optional["HistoryDatasetCollectionAssociation"]]
5477
5478
tags: Mapped[List["HistoryDatasetAssociationTagAssociation"]]
5479
+ copied_to_history_dataset_associations: Mapped[List["HistoryDatasetAssociation"]]
5478
5480
5479
5481
def __init__(
5480
5482
self,
@@ -5562,6 +5564,9 @@ def copy_from(self, other_hda, new_dataset=None, include_tags=True, include_meta
5562
5564
self.copy_tags_from(self.user, other_hda)
5563
5565
self.dataset = new_dataset or other_hda.dataset
5564
5566
self.copied_from_history_dataset_association_id = other_hda.id
5567
+ for copied_hda in self.copied_to_history_dataset_associations:
5568
+ copied_hda.copy_from(self, include_tags=include_tags, include_metadata=include_metadata)
5569
+
5565
5570
if old_dataset:
5566
5571
old_dataset.full_delete()
5567
5572
@@ -11946,15 +11951,34 @@ def __repr__(self):
11946
11951
lazy="joined",
11947
11952
back_populates="history_associations",
11948
11953
),
11954
+ copied_to_history_dataset_associations=relationship(
11955
+ "HistoryDatasetAssociation",
11956
+ primaryjoin=lambda: and_(
11957
+ HistoryDatasetAssociation.id
11958
+ == remote(HistoryDatasetAssociation.copied_from_history_dataset_association_id),
11959
+ # Include dataset_id, not technically necessary but allows filtering early
11960
+ # and avoid the need for an index on copied_from_history_dataset_association_id
11961
+ HistoryDatasetAssociation.dataset_id == remote(HistoryDatasetAssociation.dataset_id),
11962
+ ),
11963
+ remote_side=lambda: [
11964
+ HistoryDatasetAssociation.copied_from_history_dataset_association_id,
11965
+ HistoryDatasetAssociation.dataset_id,
11966
+ ],
11967
+ back_populates="copied_from_history_dataset_association",
11968
+ ),
11949
11969
copied_from_history_dataset_association=relationship(
11950
- HistoryDatasetAssociation,
11951
- primaryjoin=(
11952
- HistoryDatasetAssociation.table.c.copied_from_history_dataset_association_id
11953
- == HistoryDatasetAssociation.table.c.id
11970
+ "HistoryDatasetAssociation",
11971
+ primaryjoin=lambda: and_(
11972
+ HistoryDatasetAssociation.copied_from_history_dataset_association_id
11973
+ == remote(HistoryDatasetAssociation.id),
11974
+ HistoryDatasetAssociation.dataset_id == remote(HistoryDatasetAssociation.dataset_id),
11954
11975
),
11955
- remote_side=[HistoryDatasetAssociation.table.c.id],
11956
- uselist=False,
11976
+ remote_side=lambda: [
11977
+ HistoryDatasetAssociation.id,
11978
+ HistoryDatasetAssociation.dataset_id,
11979
+ ],
11957
11980
back_populates="copied_to_history_dataset_associations",
11981
+ uselist=False,
11958
11982
),
11959
11983
copied_from_library_dataset_dataset_association=relationship(
11960
11984
LibraryDatasetDatasetAssociation,
@@ -11964,14 +11988,6 @@ def __repr__(self):
11964
11988
),
11965
11989
back_populates="copied_to_history_dataset_associations",
11966
11990
),
11967
- copied_to_history_dataset_associations=relationship(
11968
- HistoryDatasetAssociation,
11969
- primaryjoin=(
11970
- HistoryDatasetAssociation.table.c.copied_from_history_dataset_association_id
11971
- == HistoryDatasetAssociation.table.c.id
11972
- ),
11973
- back_populates="copied_from_history_dataset_association",
11974
- ),
11975
11991
copied_to_library_dataset_dataset_associations=relationship(
11976
11992
LibraryDatasetDatasetAssociation,
11977
11993
primaryjoin=(
0 commit comments