Skip to content

Commit ae6652e

Browse files
vjaganat90Vasu Jaganath
andauthored
fix ict->clt conversion for directory (PolusAI#290)
* fix cwl_inline_runtag(name) and post_compile functions * fix ict->clt io_type when specified directory --------- Co-authored-by: Vasu Jaganath <[email protected]>
1 parent 5d64de3 commit ae6652e

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

src/sophios/api/http/restapi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ async def compile_wf(request: Request) -> Json:
101101
# schema non-preserving
102102
workflow_temp = converter.wfb_to_wic(wfb_payload)
103103
wkflw_name = "generic_workflow"
104-
args = get_args(wkflw_name, ['--inline_cwl_runtag', '--generate_cwl_workflow'])
104+
args = get_args(wkflw_name, ['--cwl_inline_runtag', '--generate_cwl_workflow'])
105105

106106
# Build canonical workflow object
107107
workflow_can = utils_cwl.desugar_into_canonical_normal_form(workflow_temp)
@@ -134,7 +134,7 @@ async def compile_wf(request: Request) -> Json:
134134

135135
rose_tree = compiler_info.rose
136136
input_output.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
137-
cwl_inline_runtag(args, rose_tree)
137+
rose_tree = cwl_inline_runtag(args, rose_tree)
138138
# ======== OUTPUT PROCESSING ================
139139
# ========= PROCESS COMPILED OBJECT =========
140140
sub_node_data: NodeData = rose_tree.data

src/sophios/api/pythonapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def run(self) -> None:
757757
rose_tree: RoseTree = compiler_info.rose
758758

759759
post_compile.cwl_docker_extract(args, self.process_name)
760-
post_compile.remove_entrypoints(args, rose_tree)
760+
rose_tree = post_compile.remove_entrypoints(args, rose_tree)
761761

762762
# Do NOT capture stdout and/or stderr and pipe warnings and errors into a black hole.
763763
retval = run_local_module.run_local(args, rose_tree, args.cachedir, args.cwl_runner, True)

src/sophios/api/utils/ict/ict_spec/io/objects.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ def _output_to_cwl(self, inputs: Any) -> dict:
128128
== "file" # pylint: disable=unsubscriptable-object
129129
):
130130
cwl_type = "File"
131+
elif (
132+
isinstance(self.io_format, list)
133+
and len(self.io_format) == 1
134+
and self.io_format[0].lower() == 'directory'
135+
):
136+
cwl_type = "Directory"
131137
else:
132138
cwl_type = "File"
133139

src/sophios/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
(You should only disable provenance if absolutely necessary.)''')
4040
parser.add_argument('--copy_output_files', default=False, action="store_true",
4141
help='Copies output files from the cachedir to outdir/ (automatically enabled with --run_local)')
42-
parser.add_argument('--inline_cwl_runtag', default=False, action="store_true",
42+
parser.add_argument('--cwl_inline_runtag', default=False, action="store_true",
4343
help='Copies cwl adapter file contents inline into the final .cwl in autogenerated/')
4444
# This is a hidden flag
4545
parser.add_argument('--ignore_dir_path', type=bool,

src/sophios/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def main() -> None:
171171

172172
io.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
173173

174-
pc.cwl_inline_runtag(args, rose_tree)
174+
rose_tree = pc.cwl_inline_runtag(args, rose_tree)
175175
io.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
176176

177177
if args.graphviz:
@@ -194,7 +194,8 @@ def main() -> None:
194194

195195
if args.run_local or args.generate_run_script:
196196
pc.cwl_docker_extract(args, yaml_stem)
197-
pc.remove_entrypoints(args, rose_tree)
197+
rose_tree = pc.remove_entrypoints(args, rose_tree)
198+
io.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
198199

199200
run_local.run_local(args, rose_tree, args.cachedir, args.cwl_runner, False)
200201

src/sophios/plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,13 @@ def cwl_update_inline_runtag_rosetree(rose_tree: RoseTree, path: Path, relative_
279279
"""
280280
n_d: NodeData = rose_tree.data
281281
if n_d.compiled_cwl['class'] == 'Workflow':
282-
outputs_inline_cwl_runtag = cwl_update_inline_runtag(n_d.compiled_cwl, path, relative_run_path)
282+
outputs_cwl_inline_runtag = cwl_update_inline_runtag(n_d.compiled_cwl, path, relative_run_path)
283283
else:
284-
outputs_inline_cwl_runtag = n_d.compiled_cwl
284+
outputs_cwl_inline_runtag = n_d.compiled_cwl
285285

286286
sub_trees_path = [cwl_update_inline_runtag_rosetree(sub_rose_tree, path, relative_run_path) for
287287
sub_rose_tree in rose_tree.sub_trees]
288-
node_data_path = NodeData(n_d.namespaces, n_d.name, n_d.yml, outputs_inline_cwl_runtag, n_d.tool,
288+
node_data_path = NodeData(n_d.namespaces, n_d.name, n_d.yml, outputs_cwl_inline_runtag, n_d.tool,
289289
n_d.workflow_inputs_file, n_d.explicit_edge_defs, n_d.explicit_edge_calls,
290290
n_d.graph, n_d.inputs_workflow, n_d.step_name_1)
291291
return RoseTree(node_data_path, sub_trees_path)

src/sophios/post_compile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import subprocess as sub
44

55
from . import plugins
6-
from . import input_output as io
76
from .wic_types import RoseTree
87

98

@@ -22,15 +21,16 @@ def cwl_docker_extract(args: argparse.Namespace, file_name: str) -> None:
2221
sub.run(cmd, check=True)
2322

2423

25-
def cwl_inline_runtag(args: argparse.Namespace, rose_tree: RoseTree) -> None:
24+
def cwl_inline_runtag(args: argparse.Namespace, rose_tree: RoseTree) -> RoseTree:
2625
"""Transform with cwl inline runtag"""
2726
# this has to happen after at least one write
2827
# so we can copy from local cwl_dapters in autogenerated/
29-
if args.inline_cwl_runtag:
28+
if args.cwl_inline_runtag:
3029
rose_tree = plugins.cwl_update_inline_runtag_rosetree(rose_tree, Path('autogenerated/'), True)
30+
return rose_tree
3131

3232

33-
def remove_entrypoints(args: argparse.Namespace, rose_tree: RoseTree) -> None:
33+
def remove_entrypoints(args: argparse.Namespace, rose_tree: RoseTree) -> RoseTree:
3434
"""Remove entry points"""
3535
if args.docker_remove_entrypoints:
3636
# Requires root, so guard behind CLI option
@@ -40,4 +40,4 @@ def remove_entrypoints(args: argparse.Namespace, rose_tree: RoseTree) -> None:
4040
plugins.remove_entrypoints_podman()
4141

4242
rose_tree = plugins.dockerPull_append_noentrypoint_rosetree(rose_tree)
43-
io.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
43+
return rose_tree

tests/test_examples.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from sophios import auto_gen_header
2323
from sophios.cli import get_args
2424
from sophios.utils_yaml import wic_loader
25-
from sophios.post_compile import cwl_docker_extract
25+
from sophios.post_compile import cwl_docker_extract, remove_entrypoints
2626
from sophios.wic_types import NodeData, StepId, Yaml, YamlTree, Json
2727
from sophios.utils_graphs import get_graph_reps
2828

@@ -216,15 +216,8 @@ def run_workflows(yml_path_str: str, yml_path: Path, cwl_runner: str, args: argp
216216
cwl_docker_extract(args, Path(yml_path).stem)
217217
return
218218

219-
if args.docker_remove_entrypoints:
220-
# Requires root, so guard behind CLI option
221-
if args.container_engine == 'docker':
222-
sophios.plugins.remove_entrypoints_docker()
223-
if args.container_engine == 'podman':
224-
sophios.plugins.remove_entrypoints_podman()
225-
226-
rose_tree = sophios.plugins.dockerPull_append_noentrypoint_rosetree(rose_tree)
227-
sophios.input_output.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
219+
rose_tree = remove_entrypoints(args, rose_tree)
220+
sophios.input_output.write_to_disk(rose_tree, Path('autogenerated/'), True, args.inputs_file)
228221

229222
if args.partial_failure_enable:
230223
rose_tree = sophios.plugins.cwl_update_outputs_optional_rosetree(rose_tree)

0 commit comments

Comments
 (0)