mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Validating on upload. Still need to make template display a peek or something.
This commit is contained in:
@@ -230,15 +230,8 @@ class JobWrapper( object ):
|
||||
data = dataset_assoc.dataset
|
||||
if data.state == data.states.FAKE:
|
||||
data.deleted = True
|
||||
# TODO
|
||||
# validate output datasets
|
||||
for out_dataset in job.output_datasets:
|
||||
# file must exist in order to validate it
|
||||
if os.path.exists(out_dataset.dataset.file_name):
|
||||
errors = out_dataset.dataset.datatype.validate(out_dataset.dataset)
|
||||
for error in errors:
|
||||
out_dataset.dataset.add_validation_error(
|
||||
model.ValidationError( message=str( error ), err_type=error.__class__.__name__, attributes=str( error.__dict__ ) ) )
|
||||
print str( error )
|
||||
|
||||
mapping.context.current.flush()
|
||||
log.debug('job ended, id: %d' % self.job_id )
|
||||
|
||||
@@ -254,7 +254,10 @@ class Dataset( object ):
|
||||
|
||||
def add_validation_error( self, validation_error ):
|
||||
self.validation_errors.append( validation_error )
|
||||
|
||||
|
||||
def extend_validation_errors( self, validation_errors ):
|
||||
self.validation_errors.extend(validation_errors)
|
||||
|
||||
# FIXME: sqlalchemy will replace this
|
||||
def _delete(self):
|
||||
"""Remove the file that corresponds to this data"""
|
||||
@@ -302,4 +305,4 @@ class GalaxySession( object ):
|
||||
class GalaxySessionToHistoryAssociation( object ):
|
||||
def __init__( self, galaxy_session, history ):
|
||||
self.galaxy_session = galaxy_session
|
||||
self.history = history
|
||||
self.history = history
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import os, shutil, urllib, StringIO
|
||||
from galaxy import datatypes, jobs
|
||||
from galaxy.datatypes import sniff
|
||||
from galaxy import model
|
||||
|
||||
class UploadToolAction( object ):
|
||||
"""
|
||||
@@ -82,6 +83,12 @@ class UploadToolAction( object ):
|
||||
if isinstance( data.datatype, datatypes.interval.Interval ):
|
||||
if data.missing_meta():
|
||||
data.extension = 'tabular'
|
||||
|
||||
# validate incomming data
|
||||
for error in data.datatype.validate( data ):
|
||||
data.add_validation_error(
|
||||
model.ValidationError( message=str( error ), err_type=error.__class__.__name__, attributes=str( error.__dict__ ) ) )
|
||||
|
||||
trans.history.add_dataset( data )
|
||||
trans.app.model.flush()
|
||||
return data
|
||||
|
||||
+3
-7
@@ -5,7 +5,7 @@ Validate a dataset based on extension a metadata passed in on the
|
||||
command line. Outputs a binhex'd representation of the exceptions.
|
||||
|
||||
usage: %prog input output
|
||||
-c, --cols=N,N,N,N: column metadata, in the case of GFF, BED, or intervals
|
||||
-m, --metadata=N: base64 pickeled metadata
|
||||
-x, --ext=N: extension as understood by galaxy
|
||||
"""
|
||||
from cookbook import doc_optparse
|
||||
@@ -25,12 +25,8 @@ def main():
|
||||
data = model.Dataset( extension=extension, id=int( args[0] ) )
|
||||
data.file_path = "/home/ian/trunk/database/files/"
|
||||
|
||||
if options.cols:
|
||||
cols = options.cols.split(",")
|
||||
data.metadata.chromCol = cols[0]
|
||||
data.metadata.startCol = cols[1]
|
||||
data.metadata.endCol = cols[2]
|
||||
data.metadata.strandCol = cols[3]
|
||||
if options.metadata:
|
||||
data.metadata = util.string_to_object( options.metadata )
|
||||
|
||||
errors = data.datatype.validate( data )
|
||||
print util.object_to_string(errors)
|
||||
|
||||
Reference in New Issue
Block a user