Expressions module

This module implements parameterizable strings for use within experiment spec.

Expressions employ self variable, which corresponds to the currently executing stage.

See also yaml_loader.py module for more implementation details.

class Expression(value, pattern=re.compile('\\$\\{([^}^{]+)\\}'), ctx=None, doc=None)[исходный код]

Базовые классы: object

Implements a parameterizable string which values are computed at runtime from the currently available parameters in the context

to_json()[исходный код]
class defaultdict_v2(*args, default=None, **kwargs)[исходный код]

Базовые классы: dict

eval_ctx(p, ctx=None, doc=None)[исходный код]

Evaluates an expression p in context ctx

The following variables are available for expressions:

  • env : a dict that includes os.environ and MLDevSettings().environ if a key is missing, None is returned to expression

  • _ : a context object

These functions are available for expressions:

  • json(o) : converts its argument o to json string

  • path(p) : expands its argument to an absolute path

  • params(dict) : converts dict to a sequence of --<key> <value> pairs

See _EVAL_FUNCTIONS

Параметры
  • ctx – context to evaluate p

  • p – expression to evaluate

Результат

result of evaluation