mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Allow collection creation API to hide original datasets during creation.
This commit is contained in:
@@ -51,6 +51,7 @@ class DatasetCollectionManager( object ):
|
||||
elements=None,
|
||||
implicit_collection_info=None,
|
||||
trusted_identifiers=None, # Trust preloaded element objects
|
||||
hide_source_items=False,
|
||||
):
|
||||
"""
|
||||
"""
|
||||
@@ -66,6 +67,7 @@ class DatasetCollectionManager( object ):
|
||||
collection_type=collection_type,
|
||||
element_identifiers=element_identifiers,
|
||||
elements=elements,
|
||||
hide_source_items=hide_source_items,
|
||||
)
|
||||
|
||||
if isinstance( parent, model.History ):
|
||||
@@ -114,6 +116,7 @@ class DatasetCollectionManager( object ):
|
||||
collection_type,
|
||||
element_identifiers=None,
|
||||
elements=None,
|
||||
hide_source_items=False,
|
||||
):
|
||||
if element_identifiers is None and elements is None:
|
||||
raise RequestParameterInvalidException( ERROR_INVALID_ELEMENTS_SPECIFICATION )
|
||||
@@ -133,11 +136,16 @@ class DatasetCollectionManager( object ):
|
||||
elements = self.__load_elements(trans, element_identifier['element_identifiers'])
|
||||
if not new_collection:
|
||||
elements = self.__load_elements( trans, element_identifiers )
|
||||
|
||||
# else if elements is set, it better be an ordered dict!
|
||||
|
||||
if elements is not self.ELEMENTS_UNINITIALIZED:
|
||||
type_plugin = collection_type_description.rank_type_plugin()
|
||||
dataset_collection = builder.build_collection( type_plugin, elements )
|
||||
if hide_source_items:
|
||||
log.debug("Hiding source items during dataset collection creation")
|
||||
for dataset in dataset_collection.dataset_instances:
|
||||
dataset.visible = False
|
||||
else:
|
||||
dataset_collection = model.DatasetCollection( populated=False )
|
||||
dataset_collection.collection_type = collection_type
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from galaxy import exceptions, model, web
|
||||
from galaxy.util import string_as_bool
|
||||
|
||||
log = logging.getLogger( __name__ )
|
||||
|
||||
@@ -26,6 +27,7 @@ def api_payload_to_create_params( payload ):
|
||||
collection_type=payload.get( "collection_type" ),
|
||||
element_identifiers=payload.get( "element_identifiers" ),
|
||||
name=payload.get( "name", None ),
|
||||
hide_source_items=string_as_bool( payload.get( "hide_source_items", False ) )
|
||||
)
|
||||
return params
|
||||
|
||||
|
||||
@@ -161,6 +161,23 @@ class HistoryContentsApiTestCase( api.ApiTestCase, TestsDatasets ):
|
||||
dataset_collection = show_response.json()
|
||||
assert dataset_collection[ "deleted" ]
|
||||
|
||||
def test_dataset_collection_hide_originals( self ):
|
||||
payload = self.dataset_collection_populator.create_pair_payload(
|
||||
self.history_id,
|
||||
type="dataset_collection"
|
||||
)
|
||||
|
||||
payload["hide_source_items"] = True
|
||||
dataset_collection_response = self._post( "histories/%s/contents" % self.history_id, payload )
|
||||
self.__check_create_collection_response( dataset_collection_response )
|
||||
|
||||
contents_response = self._get( "histories/%s/contents" % self.history_id )
|
||||
datasets = [d for d in contents_response.json() if d["history_content_type"] == "dataset" and d["hid"] in [1, 2]]
|
||||
# Assert two datasets in source were hidden.
|
||||
assert len(datasets) == 2
|
||||
assert not datasets[0]["visible"]
|
||||
assert not datasets[1]["visible"]
|
||||
|
||||
def test_update_dataset_collection( self ):
|
||||
payload = self.dataset_collection_populator.create_pair_payload(
|
||||
self.history_id,
|
||||
|
||||
Reference in New Issue
Block a user