55import logging
66import argparse
77from lib import Keys , INVOCATIONS_DIR , METRICS_DIR
8- from lib .common import connect , Context
8+ from lib .common import connect , Context , print_json
99from bioblend .galaxy import GalaxyInstance
1010
1111log = logging .getLogger ('abm' )
@@ -122,19 +122,37 @@ def run(context: Context, workflow_path, history_prefix: str, experiment: str):
122122 print (f'ERROR: Invalid input specification for { spec [Keys .NAME ]} ' )
123123 return False
124124
125- dsname = spec [Keys .DATASET_ID ]
126- input_names .append (dsname )
127- #inputs.append(dsname)
128- # dsid = find_dataset_id(gi, dsname)
129- dsdata = _get_dataset_data (gi , dsname )
130- if dsdata is None :
131- raise Exception (f"ERROR: unable to resolve { dsname } to a dataset." )
132- dsid = dsdata ['id' ]
133- dssize = dsdata ['size' ]
134- input_data_size .append (dssize )
135- print (f"Input dataset ID: { dsname } [{ dsid } ] { dssize } " )
136- inputs [input [0 ]] = {'id' : dsid , 'src' : 'hda' , 'size' : dssize }
137-
125+ if 'value' in spec :
126+ inputs [input [0 ]] = spec ['value' ]
127+ print (f"Input data value: { spec ['value' ]} " )
128+ elif 'collection' in spec :
129+ dsname = spec ['collection' ]
130+ input_names .append (dsname )
131+ #inputs.append(dsname)
132+ # dsid = find_dataset_id(gi, dsname)
133+ dsdata = _get_dataset_data (gi , dsname )
134+ if dsdata is None :
135+ raise Exception (f"ERROR: unable to resolve { dsname } to a dataset." )
136+ dsid = dsdata ['id' ]
137+ dssize = dsdata ['size' ]
138+ input_data_size .append (dssize )
139+ print (f"Input dataset ID: { dsname } [{ dsid } ] { dssize } " )
140+ inputs [input [0 ]] = {'id' : dsid , 'src' : 'hdca' , 'size' : dssize }
141+ elif Keys .DATASET_ID in spec :
142+ dsname = spec [Keys .DATASET_ID ]
143+ input_names .append (dsname )
144+ #inputs.append(dsname)
145+ # dsid = find_dataset_id(gi, dsname)
146+ dsdata = _get_dataset_data (gi , dsname )
147+ if dsdata is None :
148+ raise Exception (f"ERROR: unable to resolve { dsname } to a dataset." )
149+ dsid = dsdata ['id' ]
150+ dssize = dsdata ['size' ]
151+ input_data_size .append (dssize )
152+ print (f"Input dataset ID: { dsname } [{ dsid } ] { dssize } " )
153+ inputs [input [0 ]] = {'id' : dsid , 'src' : 'hda' , 'size' : dssize }
154+ else :
155+ raise Exception (f'Invalid input value' )
138156 print (f"Running workflow { wfid } " )
139157 new_history_name = output_history_name
140158 if history_prefix is not None :
@@ -415,12 +433,33 @@ def make_result(data):
415433 try :
416434 datasets = gi .datasets .get_datasets (name = name_or_id ) # , deleted=True, purged=True)
417435 for ds in datasets :
418- if ds ['state' ] == 'ok' and not ds ['deleted' ] and ds ['visible' ]:
436+ print_json (ds )
437+ state = True
438+ if 'state' in ds :
439+ state = ds ['state' ] == 'ok'
440+ if state and not ds ['deleted' ] and ds ['visible' ]:
419441 # The dict returned by get_datasets does not include the input
420442 # file sizes so we need to make another call to show_datasets
421443 return make_result (gi .datasets .show_dataset (ds ['id' ]))
444+ # if ds['state'] == 'ok':
445+ # print('state is ok')
446+ # if ds['deleted']:
447+ # print('dataset deleted')
448+ # else:
449+ # print('dataset not deleted')
450+ # if ds['visible']:
451+ # print('dataset visible')
452+ # else:
453+ # print('dataset not visible')
422454 except Exception as e :
423- print ( e )
455+ pass
424456
425457 return None
426458
459+
460+ from pprint import pprint
461+ def test (context :Context , args :list ):
462+ id = 'c90fffcf98b31cd3'
463+ gi = connect (context )
464+ inputs = gi .workflows .get_workflow_inputs (id , 'PE fastq input' )
465+ pprint (inputs )
0 commit comments