From a6ed01ced84f241309b93f19e16dfd6ee3a0e210 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 9 Feb 2015 12:22:22 -0500 Subject: [PATCH 1/2] Do not import argparse unconditionally in lib/galaxy/tools/deps/brew_exts.py. --- lib/galaxy/tools/deps/brew_exts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/galaxy/tools/deps/brew_exts.py b/lib/galaxy/tools/deps/brew_exts.py index 763bac60697..ca0cd803980 100755 --- a/lib/galaxy/tools/deps/brew_exts.py +++ b/lib/galaxy/tools/deps/brew_exts.py @@ -21,7 +21,10 @@ from __future__ import print_function -import argparse +try: + import argparse +except ImportError: + argparse = None import contextlib import json import glob From c26c8a86cba28f339a369c8a030f93e210c377a5 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 9 Feb 2015 13:29:45 -0500 Subject: [PATCH 2/2] When copying individual collections via the GUI - copy HDAs by default also. We may want to be able to turn this off someday in certain scenarios - but usually this will result in less confusion for the user. Doing this for whole histories also needs to be done - but it is a bit trickier (don't want the HDA copied twice). Might be better on the other side of eliminating the nessecity that these things have HIDs. --- lib/galaxy/model/__init__.py | 39 +++++++++++++++---- .../webapps/galaxy/controllers/dataset.py | 6 ++- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index caa058dc507..14abe5cf0a9 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2711,12 +2711,16 @@ class DatasetCollection( object, Dictifiable, UsesAnnotations ): error_message = "Dataset collection has no %s with key %s." % ( get_by_attribute, key ) raise KeyError( error_message ) - def copy( self ): + def copy( self, destination=None, element_destination=None ): new_collection = DatasetCollection( collection_type=self.collection_type, ) for element in self.elements: - element.copy_to_collection( new_collection ) + element.copy_to_collection( + new_collection, + destination=destination, + element_destination=element_destination, + ) object_session( self ).add( new_collection ) object_session( self ).flush() return new_collection @@ -2835,20 +2839,24 @@ class HistoryDatasetCollectionAssociation( DatasetCollectionInstance, Dictifiabl break return matching_collection - def copy( self ): + def copy( self, element_destination=None ): """ Create a copy of this history dataset collection association. Copy underlying collection. """ hdca = HistoryDatasetCollectionAssociation( hid=self.hid, - collection=self.collection.copy(), + collection=None, visible=self.visible, deleted=self.deleted, name=self.name, copied_from_history_dataset_collection_association=self, ) - + collection_copy = self.collection.copy( + destination=hdca, + element_destination=element_destination, + ) + hdca.collection = collection_copy object_session( self ).add( hdca ) object_session( self ).flush() return hdca @@ -2957,9 +2965,26 @@ class DatasetCollectionElement( object, Dictifiable ): else: return element_object - def copy_to_collection( self, collection ): + def copy_to_collection( self, collection, destination=None, element_destination=None ): + element_object = self.element_object + if element_destination: + if self.is_collection: + element_object = element_object.copy( + destination=destination, + element_destination=element_destination + ) + else: + new_element_object = element_object.copy( copy_children=True ) + if destination is not None and element_object.hidden_beneath_collection_instance: + new_element_object.hidden_beneath_collection_instance = destination + # Ideally we would not need to give the following + # element an HID and it would exist in the history only + # as an element of the containing collection. + element_destination.add_dataset( new_element_object ) + element_object = new_element_object + new_element = DatasetCollectionElement( - element=self.element_object, + element=element_object, collection=collection, element_index=self.element_index, element_identifier=self.element_identifier, diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index 66eb7f51227..071bbbf3c13 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -1074,7 +1074,11 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesItemRatings, Uses if content.history_content_type == "dataset": hist.add_dataset( content.copy( copy_children=True ) ) else: - hist.add_dataset_collection( content.copy( ) ) + copy_collected_datasets = True + copy_kwds = {} + if copy_collected_datasets: + copy_kwds["element_destination"] = hist + hist.add_dataset_collection( content.copy( **copy_kwds ) ) if current_history in target_histories: refresh_frames = ['history'] trans.sa_session.flush()