Skip to content

Commit ff91b31

Browse files
vjaganat90Vasu Jaganath
andauthored
minor clarity and perf improvements (PolusAI#340)
Co-authored-by: Vasu Jaganath <[email protected]>
1 parent 7d4bb80 commit ff91b31

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/sophios/input_output.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from shutil import copytree, ignore_patterns
44
import json
55
from pathlib import Path
6-
import sys
76
from typing import Any, List, Tuple
87

98
import yaml

src/sophios/plugins.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import copy
22
import logging
3-
import json
43
import glob
54
import os
65
from pathlib import Path
76
import re
8-
import sys
97
import tempfile
10-
import traceback
118
from typing import Any, Dict, Union
129

1310
import cwltool.load_tool
@@ -16,8 +13,7 @@
1613
import docker
1714

1815

19-
from . import input_output as io, utils_cwl, cli
20-
from .python_cwl_adapter import import_python_file
16+
from . import utils_cwl, cli
2117
from .wic_types import Cwl, NodeData, RoseTree, StepId, Tool, Tools, Json
2218

2319

@@ -182,19 +178,21 @@ def cwl_update_inline_runtag(cwl: Cwl, path: Path, relative_run_path: bool) -> C
182178
cwl_mod = copy.deepcopy(cwl)
183179
for step in cwl_mod['steps']:
184180
runtag_orig = step.get('run', '')
185-
if isinstance(runtag_orig, str) and runtag_orig.endswith('.cwl'):
186-
if relative_run_path:
187-
yml_path = Path.cwd() / path / runtag_orig
188-
else:
189-
yml_path = Path(runtag_orig) # Assume absolute path in the runtag
190-
with open(yml_path, mode='r', encoding='utf-8') as f:
191-
runtag_raw = yaml.safe_load(f.read())
192-
# local $namespace and $schema tag shouldn't be in inline cwl steps
193-
runtag_raw.pop('$namespaces', None)
194-
runtag_raw.pop('$schemas', None)
195-
step['run'] = runtag_raw
196-
else:
197-
pass # We only care if the runtag is a cwl filepath
181+
match runtag_orig:
182+
case str():
183+
if runtag_orig.endswith('.cwl'):
184+
if relative_run_path:
185+
yml_path = Path.cwd() / path / runtag_orig
186+
else:
187+
yml_path = Path(runtag_orig) # Assume absolute path in the runtag
188+
with open(yml_path, mode='r', encoding='utf-8') as f:
189+
runtag_raw = yaml.safe_load(f.read())
190+
# local $namespace and $schema tag shouldn't be in inline cwl steps
191+
runtag_raw.pop('$namespaces', None)
192+
runtag_raw.pop('$schemas', None)
193+
step['run'] = runtag_raw
194+
case _:
195+
pass # We only care if the runtag is a cwl filepath
198196
return cwl_mod
199197

200198

0 commit comments

Comments
 (0)