-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added stdstreams to file conversion utils (#144)
- Loading branch information
1 parent
9a4f9d1
commit 9fee238
Showing
5 changed files
with
479 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,3 +107,7 @@ venv.bak/ | |
|
||
testenv*/ | ||
pydocstyle_report.txt | ||
|
||
# PyCharm | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import hashlib | ||
|
||
from schema_salad.exceptions import ValidationException | ||
from schema_salad.utils import json_dumps | ||
|
||
from cwl_utils.parser.cwl_v1_0 import CommandLineTool, CommandOutputBinding | ||
|
||
|
||
def convert_stdstreams_to_files(clt: CommandLineTool) -> None: | ||
for out in clt.outputs: | ||
if out.type == 'stdout': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stdout shortcut.") | ||
if clt.stdout is None: | ||
clt.stdout = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stdout) | ||
elif out.type == 'stderr': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stderr shortcut.") | ||
if clt.stderr is None: | ||
clt.stderr = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stderr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import hashlib | ||
from typing import cast | ||
|
||
from schema_salad.exceptions import ValidationException | ||
from schema_salad.utils import json_dumps | ||
|
||
from cwl_utils.parser.cwl_v1_1 import CommandLineTool, CommandOutputBinding | ||
|
||
|
||
def convert_stdstreams_to_files(clt: CommandLineTool) -> None: | ||
for out in clt.outputs: | ||
if out.type == 'stdout': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stdout shortcut.") | ||
if clt.stdout is None: | ||
clt.stdout = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stdout) | ||
elif out.type == 'stderr': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stderr shortcut.") | ||
if clt.stderr is None: | ||
clt.stderr = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stderr) | ||
for inp in clt.inputs: | ||
if inp.type == 'stdin': | ||
if inp.inputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify unputBinding when using stdin shortcut.") | ||
if clt.stdin is not None: | ||
raise ValidationException( | ||
"Not allowed to specify stdin path when using stdin type shortcut.") | ||
else: | ||
clt.stdin = '$(inputs.%s.path)' % cast(str, inp.id).rpartition('#')[2].split('/')[-1] | ||
inp.type = 'File' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import hashlib | ||
from typing import cast | ||
|
||
from schema_salad.exceptions import ValidationException | ||
from schema_salad.utils import json_dumps | ||
|
||
from cwl_utils.parser.cwl_v1_2 import CommandLineTool, CommandOutputBinding | ||
|
||
|
||
def convert_stdstreams_to_files(clt: CommandLineTool) -> None: | ||
for out in clt.outputs: | ||
if out.type == 'stdout': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stdout shortcut.") | ||
if clt.stdout is None: | ||
clt.stdout = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stdout) | ||
elif out.type == 'stderr': | ||
if out.outputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify outputBinding when using stderr shortcut.") | ||
if clt.stderr is None: | ||
clt.stderr = str(hashlib.sha1(json_dumps( # nosec | ||
clt.save(), sort_keys=True).encode('utf-8')).hexdigest()) | ||
out.type = 'File' | ||
out.outputBinding = CommandOutputBinding(glob=clt.stderr) | ||
for inp in clt.inputs: | ||
if inp.type == 'stdin': | ||
if inp.inputBinding is not None: | ||
raise ValidationException( | ||
"Not allowed to specify unputBinding when using stdin shortcut.") | ||
if clt.stdin is not None: | ||
raise ValidationException( | ||
"Not allowed to specify stdin path when using stdin type shortcut.") | ||
else: | ||
clt.stdin = '$(inputs.%s.path)' % cast(str, inp.id).rpartition('#')[2].split('/')[-1] | ||
inp.type = 'File' |
Oops, something went wrong.