mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #817 from carlfeberhard/fix.creating_job
API, Datasets: fix returned tuple from creating_job
This commit is contained in:
@@ -383,6 +383,9 @@ class _UnflattenedMetadataDatasetAssociationSerializer( base.ModelSerializer,
|
||||
'meta_files' : self.serialize_meta_files,
|
||||
'metadata' : self.serialize_metadata,
|
||||
|
||||
'creating_job' : self.serialize_creating_job,
|
||||
'rerunnable' : self.serialize_rerunnable,
|
||||
|
||||
'parent_id' : self.serialize_id,
|
||||
'designation' : lambda i, k, **c: i.designation,
|
||||
|
||||
@@ -446,6 +449,27 @@ class _UnflattenedMetadataDatasetAssociationSerializer( base.ModelSerializer,
|
||||
|
||||
return metadata
|
||||
|
||||
def serialize_creating_job( self, dataset, key, **context ):
|
||||
"""
|
||||
Return the id of the Job that created this dataset (or its original)
|
||||
or None if no `creating_job` is found.
|
||||
"""
|
||||
if dataset.creating_job:
|
||||
return self.serialize_id( dataset.creating_job, 'id' )
|
||||
else:
|
||||
return None
|
||||
|
||||
def serialize_rerunnable( self, dataset, key, **context ):
|
||||
"""
|
||||
Return False if this tool that created this dataset can't be re-run
|
||||
(e.g. upload).
|
||||
"""
|
||||
if dataset.creating_job:
|
||||
tool = self.app.toolbox.get_tool( dataset.creating_job.tool_id, dataset.creating_job.tool_version )
|
||||
if tool and tool.is_workflow_compatible:
|
||||
return True
|
||||
return False
|
||||
|
||||
def serialize_converted_datasets( self, dataset_assoc, key, **context ):
|
||||
"""
|
||||
Return a file extension -> converted dataset encoded id map with all
|
||||
|
||||
@@ -328,9 +328,6 @@ class HDASerializer( # datasets._UnflattenedMetadataDatasetAssociationSerialize
|
||||
'file_path' : self._remap_from( 'file_name' ),
|
||||
|
||||
'resubmitted' : lambda i, k, **c: self.hda_manager.has_been_resubmitted( i ),
|
||||
'creating_job' : self.serialize_creating_job,
|
||||
'rerunnable' : self.rerunnable,
|
||||
|
||||
'display_apps' : self.serialize_display_apps,
|
||||
'display_types' : self.serialize_old_display_applications,
|
||||
'visualizations': self.serialize_visualization_links,
|
||||
@@ -435,19 +432,6 @@ class HDASerializer( # datasets._UnflattenedMetadataDatasetAssociationSerialize
|
||||
}
|
||||
return urls
|
||||
|
||||
def serialize_creating_job( self, hda, key, **context ):
|
||||
if hda.creating_job:
|
||||
return self.app.security.encode_id(hda.creating_job.id),
|
||||
else:
|
||||
return None
|
||||
|
||||
def rerunnable( self, hda, key, **context ):
|
||||
if hda.creating_job:
|
||||
tool = self.app.toolbox.get_tool(hda.creating_job.tool_id, hda.creating_job.tool_version)
|
||||
if tool and tool.is_workflow_compatible:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class HDADeserializer( datasets.DatasetAssociationDeserializer,
|
||||
taggable.TaggableDeserializerMixin,
|
||||
|
||||
Reference in New Issue
Block a user