/tools/validation/fix_errors_code.py
Python | 49 lines | 30 code | 6 blank | 13 comment | 4 complexity | 34f8daf9fa6f36712e3e3453a490dcef MD5 | raw file
1# runs after the job (and after the default post-filter) 2 3import pkg_resources 4pkg_resources.require( "bx-python" ) 5 6from galaxy import datatypes, jobs, util 7# needed to reference ParseError types, is this bad? 8from bx.tabular.io import * 9from bx.intervals.io import * 10import sys, tempfile, os 11 12def validate(incoming): 13 """Validator""" 14 #raise Exception, 'not quite right' 15 pass 16 17def exec_before_job( app, inp_data, out_data, param_dict, tool=None): 18 """Build a temp file with errors in it""" 19 errors = [] 20 for name, data in inp_data.items(): 21 validation_errors = data.validation_errors 22 for error in validation_errors: 23 # build dummy class 24 try: 25 temp = eval(error.err_type)() 26 except: 27 temp = object() 28 # stuff attributes 29 temp.__dict__ = util.string_to_object( error.attributes ) 30 errors.append(temp) 31 # There *should* only be 1 input, so we assume there is and continue 32 # base64 pickel 33 errors_str = util.object_to_string( errors ) 34 # write 35 database_tmp = "./database/tmp" # globaly visible path 36 error_file = tempfile.NamedTemporaryFile(mode="w", dir=database_tmp, suffix=".b64") 37 error_file_name = error_file.name 38 error_file.close() 39 error_file = open(error_file_name, "w") 40 error_file.write(errors_str) 41 error_file.close() 42 param_dict["errorsfile"] = error_file_name 43 44 45def exec_after_process( app, inp_data, out_data, param_dict, tool=None, stdout=None, stderr=None): 46 # in a perfect world, changes to param_dict would persist 47 # for now, unlink from tool 48 # os.unlink(param_dict["errorsfile"]) 49 pass