11# SPDX-License-Identifier: Apache-2.0
22"""CWL Expression parsing."""
33import asyncio
4- import copy
54import inspect
65import json
7- from collections .abc import Awaitable , MutableMapping
6+ from collections .abc import Awaitable , Container
87from enum import Enum
9- from typing import Any , cast
8+ from typing import Any , Final , cast
109
1110from schema_salad .utils import json_dumps
1211
1716 CWLObjectType ,
1817 CWLOutputType ,
1918 CWLParameterContext ,
19+ CWLRuntimeParameterContext ,
2020 is_cwl_parameter_context_key ,
2121)
2222from cwl_utils .utils import bytes2str_in_dicts
2323
24+ OLD_ESCAPE_CWL_VERSIONS : Final [Container [str ]] = (
25+ "v1.0" ,
26+ "v1.1.0-dev1" ,
27+ "v1.1" ,
28+ "v1.2.0-dev1" ,
29+ "v1.2.0-dev2" ,
30+ "v1.2.0-dev3" ,
31+ )
32+
2433
2534def _convert_dumper (string : str ) -> str :
2635 return f"{ json .dumps (string )} + "
@@ -281,7 +290,7 @@ def do_eval(
281290 requirements : list [CWLObjectType ],
282291 outdir : str | None ,
283292 tmpdir : str | None ,
284- resources : dict [ str , float | int ] ,
293+ resources : CWLRuntimeParameterContext ,
285294 context : CWLOutputType | None = None ,
286295 timeout : float = default_timeout ,
287296 strip_whitespace : bool = True ,
@@ -293,9 +302,7 @@ def do_eval(
293302
294303 :param timeout: The maximum number of seconds to wait while executing.
295304 """
296- runtime = cast (MutableMapping [str , int | str | None ], copy .deepcopy (resources ))
297- runtime ["tmpdir" ] = tmpdir or None
298- runtime ["outdir" ] = outdir or None
305+ runtime = resources | {"tmpdir" : tmpdir or None , "outdir" : outdir or None }
299306
300307 rootvars = cast (
301308 CWLParameterContext ,
@@ -319,19 +326,7 @@ def do_eval(
319326 fullJS = fullJS ,
320327 jslib = jslib ,
321328 strip_whitespace = strip_whitespace ,
322- escaping_behavior = (
323- 1
324- if cwlVersion
325- in (
326- "v1.0" ,
327- "v1.1.0-dev1" ,
328- "v1.1" ,
329- "v1.2.0-dev1" ,
330- "v1.2.0-dev2" ,
331- "v1.2.0-dev3" ,
332- )
333- else 2
334- ),
329+ escaping_behavior = 1 if cwlVersion in OLD_ESCAPE_CWL_VERSIONS else 2 ,
335330 ** kwargs ,
336331 )
337332
0 commit comments