cwl_utils.expression

CWL Expression parsing.

Attributes

default_timeout

Default number of seconds to wait while running a javascript engine.

param_re

CWLObjectType

CWLOutputType

Exceptions

JavascriptException

Common base class for all non-exit exceptions.

SubstitutionError

Common base class for all non-exit exceptions.

WorkflowException

Common base class for all non-exit exceptions.

Classes

JSEngine

Helper class that provides a standard way to create an ABC using

Functions

get_js_engine()

bytes2str_in_dicts(inp)

Convert any present byte string to unicode string, inplace.

scanner(scan)

evaluator(js_engine, ex, obj, jslib, fullJS, **kwargs)

interpolate(scan, rootvars[, jslib, fullJS, ...])

Interpolate and evaluate.

jshead(engine_config, rootvars)

needs_parsing(snippet)

do_eval(ex, jobinput, requirements, outdir, tmpdir, ...)

Evaluate the given CWL expression, in context.

Module Contents

exception cwl_utils.expression.JavascriptException

Bases: Exception

Inheritance diagram of cwl_utils.expression.JavascriptException

Common base class for all non-exit exceptions.

exception cwl_utils.expression.SubstitutionError

Bases: Exception

Inheritance diagram of cwl_utils.expression.SubstitutionError

Common base class for all non-exit exceptions.

exception cwl_utils.expression.WorkflowException

Bases: Exception

Inheritance diagram of cwl_utils.expression.WorkflowException

Common base class for all non-exit exceptions.

class cwl_utils.expression.JSEngine

Bases: abc.ABC

Inheritance diagram of cwl_utils.expression.JSEngine

Helper class that provides a standard way to create an ABC using inheritance.

abstract eval(scan, jslib='', **kwargs)
Parameters:
  • scan (str) –

  • jslib (str) –

  • kwargs (Any) –

Return type:

Union[cwl_utils.types.CWLOutputType, Awaitable[cwl_utils.types.CWLOutputType]]

abstract regex_eval(parsed_string, remaining_string, current_value, **kwargs)
Parameters:
  • parsed_string (str) –

  • remaining_string (str) –

  • current_value (cwl_utils.types.CWLOutputType) –

  • kwargs (Any) –

Return type:

Union[cwl_utils.types.CWLOutputType, Awaitable[cwl_utils.types.CWLOutputType]]

cwl_utils.expression.default_timeout = 20

Default number of seconds to wait while running a javascript engine.

cwl_utils.expression.get_js_engine()
Return type:

JSEngine

cwl_utils.expression.param_re
cwl_utils.expression.CWLObjectType
cwl_utils.expression.CWLOutputType
cwl_utils.expression.bytes2str_in_dicts(inp)

Convert any present byte string to unicode string, inplace.

input is a dict of nested dicts and lists

Parameters:

inp (Union[MutableMapping[str, Any], MutableSequence[Any], Any]) –

Return type:

Union[str, MutableSequence[Any], MutableMapping[str, Any]]

cwl_utils.expression.scanner(scan)
Parameters:

scan (str) –

Return type:

Optional[Tuple[int, int]]

cwl_utils.expression.evaluator(js_engine, ex, obj, jslib, fullJS, **kwargs)
Parameters:
Return type:

Optional[cwl_utils.types.CWLOutputType]

cwl_utils.expression.interpolate(scan, rootvars, jslib='', fullJS=False, strip_whitespace=True, escaping_behavior=2, convert_to_expression=False, js_engine=None, **kwargs)

Interpolate and evaluate.

Note: only call with convert_to_expression=True on CWL Expressions in $() form that need interpolation.

Parameters:
  • scan (str) –

  • rootvars (cwl_utils.types.CWLObjectType) –

  • jslib (str) –

  • fullJS (bool) –

  • strip_whitespace (bool) –

  • escaping_behavior (int) –

  • convert_to_expression (bool) –

  • js_engine (Optional[cwl_utils.sandboxjs.JSEngine]) –

  • kwargs (Any) –

Return type:

Optional[cwl_utils.types.CWLOutputType]

cwl_utils.expression.jshead(engine_config, rootvars)
Parameters:
  • engine_config (List[str]) –

  • rootvars (cwl_utils.types.CWLObjectType) –

Return type:

str

cwl_utils.expression.needs_parsing(snippet)
Parameters:

snippet (Any) –

Return type:

bool

cwl_utils.expression.do_eval(ex, jobinput, requirements, outdir, tmpdir, resources, context=None, timeout=default_timeout, strip_whitespace=True, cwlVersion='', **kwargs)

Evaluate the given CWL expression, in context.

Parameters:
  • timeout (float) – The maximum number of seconds to wait while executing.

  • ex (Optional[cwl_utils.types.CWLOutputType]) –

  • jobinput (cwl_utils.types.CWLObjectType) –

  • requirements (List[cwl_utils.types.CWLObjectType]) –

  • outdir (Optional[str]) –

  • tmpdir (Optional[str]) –

  • resources (Dict[str, Union[float, int]]) –

  • context (Optional[cwl_utils.types.CWLOutputType]) –

  • strip_whitespace (bool) –

  • cwlVersion (str) –

  • kwargs (Any) –

Return type:

Optional[cwl_utils.types.CWLOutputType]