Skip to content

Commit

Permalink
added support to return a dir for VRE tool that they need it
Browse files Browse the repository at this point in the history
  • Loading branch information
lrodrin committed Sep 23, 2021
1 parent 9449f73 commit 979f462
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
28 changes: 17 additions & 11 deletions cwl/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,22 @@ def createOutputsFiles(output_files, output_metadata, outputs_execution, executi
outputs = list() # list of tuples (path, type of output)
if out_id in outputs_execution.keys():
if not metadata['allow_multiple']: # allow multiple false
file_path = None
file_type = None
if isinstance(outputs_execution[out_id], list): # list of files # TODO check case
print(1)
file_path = outputs_execution[next(iter(outputs_execution))][0][out_keys[1]]
file_type = outputs_execution[next(iter(outputs_execution))][0][out_keys[0]].lower()
elif isinstance(outputs_execution, dict): # file
print(2)
file_path = outputs_execution[out_id][out_keys[1]]
file_type = outputs_execution[out_id][out_keys[0]].lower()
# if isinstance(outputs_execution[out_id], list): # TODO check case
# file_path = outputs_execution[next(iter(outputs_execution))][0][out_keys[1]]
# file_type = outputs_execution[next(iter(outputs_execution))][0][out_keys[0]].lower()
# elif isinstance(outputs_execution, dict):
file_path = outputs_execution[out_id][out_keys[1]]
file_type = outputs_execution[out_id][out_keys[0]]
if file_type == "File":
file_type = file_type.lower()
elif file_type == "Directory": # FIXME when VRE accept directories as output files
temp_path = os.path.join(execution_path, file_path)
shutil.make_archive(temp_path, "zip", temp_path) # Compress directory to zip
shutil.rmtree(temp_path)
file_path = temp_path + ".zip"
file_type = "file"
else:
logger.error("FIXME: Unsupported file type {}. Supported file types are File and Directory".format(file_type))

outputs.append((file_path, file_type))

Expand All @@ -133,7 +139,7 @@ def createOutputsFiles(output_files, output_metadata, outputs_execution, executi

else: # execution provenance
if out_data_type == "provenance_data": # TODO hardcoded
file_path = glob.glob(execution_path + "/*.zip")[0]
file_path = glob.glob(execution_path + "/*crate.zip")[0]
outputs.append((file_path, "file"))

output_files[out_id] = outputs
Expand Down
7 changes: 4 additions & 3 deletions tests/cosifer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
"required": true,
"allow_multiple": false,
"file": {
"file_type": "Directory",
"data_type": "",
"file_type": "MULTIPLE",
"data_type": "measurements",
"compressed": "ZIP",
"meta_data": {
"visible": true,
"description": "Consensus interaction network"
"description": "Molecular measurements"
}
}
},
Expand Down

0 comments on commit 979f462

Please sign in to comment.