Skip to content

Commit 472944b

Browse files
author
Vasu Jaganath
committed
add missing dependency and merging of namespaces in inlined runtag workflows
1 parent a991306 commit 472944b

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ dependencies = [
4444
"fastapi",
4545
"python-jose",
4646
"uvicorn",
47-
"referencing"
47+
"referencing",
48+
"aiofiles"
4849
]
4950

5051
[project.readme]

src/sophios/api/pythonapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ def run(self, compile_args_dict: Dict[str, str] = {}, run_args_dict: Dict[str, s
769769
compiler_info = self.compile(
770770
args_dict=compile_args_dict, write_to_disk=False)
771771
rose_tree: RoseTree = compiler_info.rose
772-
# rose_tree = post_compile.cwl_inline_runtag(rose_tree)
772+
rose_tree = post_compile.cwl_inline_runtag(rose_tree)
773773
post_compile.find_and_create_output_dirs(rose_tree)
774774
# only write out after all the transformations
775775
input_output.write_to_disk(rose_tree, Path(

src/sophios/compiler.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
207207
graph_nx = graph.networkx
208208
graphdata = graph.graphdata
209209

210-
# plugin_ns = wic['wic'].get('namespace', 'global')
211-
212210
tools_lst: List[Tool] = []
213211

214212
for i, step_key in enumerate(steps_keys):
@@ -267,8 +265,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
267265
print('AST modified', step_key)
268266
wic_steps[f'({i+1}, {step_key})'] = {'wic': sub_node_data.yml.get('wic', {})}
269267
wic_step_i = wic_steps.get(f'({i+1}, {step_key})', {})
270-
# import yaml
271-
# print(yaml.dump(wic_steps))
272268

273269
# Add arguments to the compiled subworkflow (if any), being careful
274270
# to remove any child wic: metadata annotations. Post-compilation
@@ -355,11 +351,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
355351
# should be written to subdirectories or if everything should be
356352
# written to autogenerated/
357353
if relative_run_path:
358-
# if step_key in subkeys:
359-
# run_path = step_name_or_key + '/' + run_path
360-
# else:
361-
# run_path = os.path.relpath(run_path, 'autogenerated/')
362-
# run_path = ('../' * len(namespaces)) + run_path
363354
run_path = step_name_or_key + '/' + run_path
364355
else:
365356
if step_key in subkeys:
@@ -781,8 +772,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
781772
inputs_file_workflow, vars_workflow_output_internal,
782773
explicit_edge_defs_copy, explicit_edge_calls_copy)
783774
compiler_info = CompilerInfo(rose_tree, env_data)
784-
# node_data_dummy = NodeData(None, None, yaml_tree_mod, None, None, None, None, None, None, None)
785-
# compiler_info_dummy = CompilerInfo(RoseTree(node_data_dummy, None), None)
786775
return compiler_info
787776

788777
# Add CommandLineTool/Subworkflow outputs tags to workflow out tags.
@@ -791,7 +780,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
791780
out_keyvals = {}
792781
for out_key, out_dict in tool_i.cwl['outputs'].items():
793782
out_keyvals[out_key] = utils_cwl.copy_cwl_input_output_dict(out_dict)
794-
# print(out_key, out_keyvals[out_key])
795783
if not out_keyvals: # FYI out_keyvals should never be {}
796784
print(f'Error! no outputs for step {step_key}')
797785
outputs_workflow.append(out_keyvals)
@@ -864,7 +852,6 @@ def compile_workflow_once(yaml_tree_ast: YamlTree,
864852
def populate_scalar_val(in_dict: dict) -> Any:
865853
newval: Any = ()
866854
if 'File' == in_dict['type']:
867-
# path = Path(in_dict['value']).name # NOTE: Use .name ?
868855
newval = {'class': 'File', 'path': in_dict['value']}
869856
if 'format' in in_dict:
870857
in_format = in_dict['format']
@@ -904,8 +891,6 @@ def populate_scalar_val(in_dict: dict) -> Any:
904891
new_keyval = {key: val_list}
905892
else:
906893
new_keyval = {key: populate_scalar_val(in_dict)}
907-
# else:
908-
# raise Exception(f"Error! Unknown type: {in_dict['type']}")
909894
yaml_inputs.update(new_keyval)
910895

911896
if not testing:

src/sophios/cwl_subinterpreter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import time
88
from pathlib import Path
99
from typing import Dict, List
10-
from unittest.mock import patch
1110

1211
import graphviz
1312
import networkx as nx

src/sophios/post_compile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@ def cwl_inline_runtag(rose_tree: RoseTree) -> RoseTree:
8888
for sub_rose_tree in rose_tree_mod.sub_trees:
8989
sub_node_data: NodeData = sub_rose_tree.data
9090
sub_step_name = sub_node_data.namespaces[-1]
91-
step_to_update = next(item for item in cwl_tree['steps'] if item.get('id') == sub_step_name)
91+
step_to_update = next(
92+
item for item in cwl_tree['steps'] if item.get('id') == sub_step_name)
9293
step_to_update['run'] = sub_node_data.compiled_cwl
93-
# The below two lines needed to avoid parsing errors of the run tag
94+
# merge the steps/clt namespaces to global namespaces
95+
# as the run tag can't have namespaces and schemas
96+
cwl_tree['$namespaces'] = cwl_tree['$namespaces'] | step_to_update['run'].get(
97+
'$namespaces', {})
98+
# and then get rid off $namespaces and $schemas in the run tag
9499
step_to_update['run'].pop('$namespaces', None)
95100
step_to_update['run'].pop('$schemas', None)
96101
sub_rose_tree = cwl_inline_runtag(sub_rose_tree)

src/sophios/run_local_async.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ async def run_cwl_workflow(
4040
cwl_runner (str): The command for the CWL runner (e.g., 'cwltool', 'toil-cwl-runner').
4141
container_cmd (str): The command for the container engine (e.g., 'docker', 'podman').
4242
user_env (Dict[str, str]): A dictionary of environment variables to set for the subprocess.
43-
supported_runners (Optional[List[str]]): A list of explicitly supported CWL runner commands.
44-
If None, defaults to ['cwltool', 'toil-cwl-runner'].
4543
4644
Returns:
4745
Optional[int]: The exit code of the executed workflow process, or None if an

0 commit comments

Comments
 (0)