mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 02:04:04 +08:00
Fix #1514.
Prior to PR #1302 workflows wouldn't validate call validate at all on inputs. 1302 was perhaps an over correction that causes validate to be called on datasets that aren't yet READY but require metadata. This rolls that back somewhat, other parameters will still validate - but validation asserting the existence of metadata won't get called in workflows. This is still not ideal but after 1302 and this - we are still in a better, more secure place than beforehand. One might argue that since we need to introduce a new validation point (right before a job is scheduled and set to QUEUED) - that we would be better off rolling back #1302 entirely. I've considered that, but I still think it is better to fail fast on the other problems, also I would rather call the validation code too many times than not enough and it would be very late in the release cycle for such a change.
This commit is contained in:
@@ -2114,6 +2114,12 @@ class DataToolParameter( BaseDataToolParameter ):
|
||||
def validate( self, value, history=None, workflow_building_mode=False ):
|
||||
dataset_count = 0
|
||||
for validator in self.validators:
|
||||
def do_validate( v ):
|
||||
if validator.requires_dataset_metadata and v and v.dataset.state != galaxy.model.Dataset.states.OK:
|
||||
return
|
||||
else:
|
||||
validator.validate( v, history )
|
||||
|
||||
if value and self.multiple:
|
||||
if not isinstance( value, list ):
|
||||
value = [ value ]
|
||||
@@ -2121,14 +2127,14 @@ class DataToolParameter( BaseDataToolParameter ):
|
||||
if isinstance(v, galaxy.model.HistoryDatasetCollectionAssociation):
|
||||
for dataset_instance in v.collection.dataset_instances:
|
||||
dataset_count += 1
|
||||
validator.validate( dataset_instance, history )
|
||||
do_validate( dataset_instance )
|
||||
else:
|
||||
dataset_count += 1
|
||||
validator.validate( v, history )
|
||||
do_validate( v )
|
||||
else:
|
||||
if value:
|
||||
dataset_count += 1
|
||||
validator.validate( value, history )
|
||||
do_validate( value )
|
||||
|
||||
if self.min is not None:
|
||||
if self.min > dataset_count:
|
||||
|
||||
@@ -20,6 +20,7 @@ class Validator( object ):
|
||||
"""
|
||||
A validator checks that a value meets some conditions OR raises ValueError
|
||||
"""
|
||||
requires_dataset_metadata = False
|
||||
|
||||
@classmethod
|
||||
def from_element( cls, param, elem ):
|
||||
@@ -236,6 +237,7 @@ class MetadataValidator( Validator ):
|
||||
"""
|
||||
Validator that checks for missing metadata
|
||||
"""
|
||||
requires_dataset_metadata = True
|
||||
|
||||
def __init__( self, message=None, check="", skip="" ):
|
||||
self.message = message
|
||||
@@ -260,6 +262,7 @@ class UnspecifiedBuildValidator( Validator ):
|
||||
"""
|
||||
Validator that checks for dbkey not equal to '?'
|
||||
"""
|
||||
requires_dataset_metadata = True
|
||||
|
||||
def __init__( self, message=None ):
|
||||
if message is None:
|
||||
@@ -319,6 +322,7 @@ class MetadataInFileColumnValidator( Validator ):
|
||||
"""
|
||||
Validator that checks if the value for a dataset's metadata item exists in a file.
|
||||
"""
|
||||
requires_dataset_metadata = True
|
||||
|
||||
@classmethod
|
||||
def from_element( cls, param, elem ):
|
||||
@@ -358,6 +362,7 @@ class MetadataInDataTableColumnValidator( Validator ):
|
||||
"""
|
||||
Validator that checks if the value for a dataset's metadata item exists in a file.
|
||||
"""
|
||||
requires_dataset_metadata = True
|
||||
|
||||
@classmethod
|
||||
def from_element( cls, param, elem ):
|
||||
|
||||
Reference in New Issue
Block a user