mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-21 13:50:20 +08:00
Get rid of the hacky "alternate path" stuff used by the upload tool and fix setting metadata when using autodetect and set_metadata_externally
This commit is contained in:
@@ -115,7 +115,14 @@ def check_zip( temp_name ):
|
||||
return ( True, False, test_ext )
|
||||
return ( True, True, test_ext )
|
||||
|
||||
def add_file( dataset, json_file ):
|
||||
def parse_outputs( args ):
|
||||
rval = {}
|
||||
for arg in args:
|
||||
id, path = arg.split( ':', 1 )
|
||||
rval[int( id )] = path
|
||||
return rval
|
||||
|
||||
def add_file( dataset, json_file, output_path ):
|
||||
data_type = None
|
||||
line_count = None
|
||||
|
||||
@@ -229,16 +236,18 @@ def add_file( dataset, json_file ):
|
||||
ext = dataset.ext
|
||||
if ext == 'auto':
|
||||
ext = 'data'
|
||||
# Move the dataset to its "real" path
|
||||
shutil.move( dataset.path, output_path )
|
||||
# Write the job info
|
||||
info = dict( type = 'dataset',
|
||||
dataset_id = dataset.dataset_id,
|
||||
path = dataset.path,
|
||||
ext = ext,
|
||||
stdout = 'uploaded %s file' % data_type,
|
||||
name = dataset.name,
|
||||
line_count = line_count )
|
||||
json_file.write( to_json_string( info ) + "\n" )
|
||||
|
||||
def add_composite_file( dataset, json_file ):
|
||||
def add_composite_file( dataset, json_file, output_path ):
|
||||
if dataset.composite_files:
|
||||
os.mkdir( dataset.extra_files_path )
|
||||
for name, value in dataset.composite_files.iteritems():
|
||||
@@ -253,28 +262,38 @@ def add_composite_file( dataset, json_file ):
|
||||
else:
|
||||
sniff.convert_newlines( dataset.composite_file_paths[ value.name ][ 'path' ] )
|
||||
shutil.move( dataset.composite_file_paths[ value.name ][ 'path' ], os.path.join( dataset.extra_files_path, name ) )
|
||||
# Move the dataset to its "real" path
|
||||
shutil.move( dataset.primary_file, output_path )
|
||||
# Write the job info
|
||||
info = dict( type = 'dataset',
|
||||
dataset_id = dataset.dataset_id,
|
||||
path = dataset.primary_file,
|
||||
stdout = 'uploaded %s file' % dataset.file_type )
|
||||
json_file.write( to_json_string( info ) + "\n" )
|
||||
|
||||
def __main__():
|
||||
|
||||
if len( sys.argv ) != 2:
|
||||
print >>sys.stderr, 'usage: upload.py <json paramfile>'
|
||||
if len( sys.argv ) < 2:
|
||||
print >>sys.stderr, 'usage: upload.py <json paramfile> <output spec> ...'
|
||||
sys.exit( 1 )
|
||||
|
||||
output_paths = parse_outputs( sys.argv[2:] )
|
||||
|
||||
json_file = open( 'galaxy.json', 'w' )
|
||||
|
||||
for line in open( sys.argv[1], 'r' ):
|
||||
dataset = from_json_string( line )
|
||||
dataset = util.bunch.Bunch( **safe_dict( dataset ) )
|
||||
|
||||
try:
|
||||
output_path = output_paths[int( dataset.dataset_id )]
|
||||
except:
|
||||
print >>sys.stderr, 'Output path for dataset %s not found on command line' % dataset.dataset_id
|
||||
sys.exit( 1 )
|
||||
|
||||
if dataset.type == 'composite':
|
||||
add_composite_file( dataset, json_file )
|
||||
add_composite_file( dataset, json_file, output_path )
|
||||
else:
|
||||
add_file( dataset, json_file )
|
||||
add_file( dataset, json_file, output_path )
|
||||
|
||||
# clean up paramfile
|
||||
try:
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
<action module="galaxy.tools.actions.upload" class="UploadToolAction"/>
|
||||
<command interpreter="python">
|
||||
upload.py $paramfile
|
||||
#set $outnum = 0
|
||||
#while $varExists('output%i' % $outnum):
|
||||
#set $output = $getVar('output%i' % $outnum)
|
||||
#set $outnum += 1
|
||||
${output.dataset.dataset.id}:${output}
|
||||
#end while
|
||||
</command>
|
||||
<inputs>
|
||||
<param name="file_type" type="select" label="File Format" help="Which format? See help below">
|
||||
|
||||
Reference in New Issue
Block a user