dal.helpers package

Subpackages

Submodules

dal.helpers.cache module

# Size of each object in bytes, calculated using pympler asizeof

Type | Models |

│ Flow | 19.36 MB | │ Configuration | 21.86 MB | │ Ports | 23.18 MB | | Layout | 23.04 MB | | Annotation | 23.04 MB | | GraphicScene | 22.7 MB | ———————————

class dal.helpers.cache.ThreadSafeCache(maxsize=100, ttl=10800)

Bases: object

cache: TTLCache
get(key, default=None)

dal.helpers.helpers module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Manuel Silva (manuel.silva@mov.ai) - 2020 - Tiago Paulino (tiago@mov.ai) - 2020

class dal.helpers.helpers.Helpers

Bases: object

Helper Methods

static find_by_key(data, target)
static get_args(prev_struct) dict
static get_partial_dict(_input: dict, key: dict) dict

Giving a full dict and a beggining return the full dict containing that beggining

static join_first(add_struct: dict, prev_struct: dict) dict
static replace_dict_values(haystack: dict, needle: any, value: any) None
static update_dict(_base_dict: dict, _add_dict: dict) dict

Join a dictionary with another dictionary

dal.helpers.helpers.flatten(data: dict, output: list, path: str, join_char: str = '.') list

Returns a list of paths

Parameters:
  • data (dict) – expects a dictionary to start

  • output (list) – variable to save the list of paths

  • path (str) – accumulative path

  • join_char (str) – character to join path entries

Returns:

a list of paths

Return type:

output (list)

dal.helpers.parsers module

Copyright (C) Mov.ai - All Rights Reserved Unauthorized copying of this file, via any medium is strictly prohibited Proprietary and confidential

Developers: - Manuel Silva (manuel.silva@mov.ai) - 2020

class dal.helpers.parsers.ObjectWithName(*args, **kwargs)

Bases: Protocol

property name: str
class dal.helpers.parsers.ParamParser(flow: Flow)

Bases: object

Parser for the node instance, container and flow parameters Supports configuration. parameters, var, flow and env variables

eval_config(_config: str, *__)
Returns the config expression evaluated

$(<contex> <configuration name>.<parameter reference>) ex.: $(config name.var1.var2)

Parameters:

_config (str) – <configuration name>.<parameter reference>

Returns:

the expression evaluated

Return type:

output (any)

eval_flow(param_name: str, default: str, instance: NodeInst | Container, node_name: str) any
Returns the flow expression evaluated

ex.: $(flow myvar)

Parameters:

param_name (str): reference to a parameter default (str): default value with parsing instance (NodeInst || Container): an instance node_name (str): node instance name (may be in the context of a subflow)

Returns:

output (any): the expression evaluated

eval_param(param_name: str, default: str, instance: Flow | NodeInst | Container, node_name: str) any
Returns the param expression evaluated or default

ex.: $(param name)

Parameters:
  • param_name (str) – reference to a parameter

  • default (str) – default value with parsing

  • instance (NodeInst || Container) – an instance

  • node_name (str) – node instance name (may be in the context of a subflow)

Returns:

the value of the parameter or the default

Return type:

output (any)

eval_reference(key: str, expression: str, instance: ObjectWithName, node_name: str) str

Calls a specific function to evaluate the expression

Parameters:
  • key (str) – name of the requested parameter

  • expression (str) – the expression to be evaluated format: $(context reference)

  • instance (NodeInst || Container) – an instance

  • node_name (str) – node instance name (may be in the context of a subflow)

Returns:

the parameter value after evaluation

Return type:

output (str)

eval_var(reference: str, *__) Any
Returns the var expression evaluated

ex.: $(var robot.name)

Parameters:
reference (str): reference to

a parameter <fleet or robot>.<parameter reference>

Returns:

output (any): the expression evaluated

logger = <Logger ParamParser.mov.ai (INFO)>
parse(key: str, expression: str, node_name: str, instance: ObjectWithName, context: str | None = None) Any

Returns the parameter value. If the value is a valid expression, it is evaluated.

Parameters:
  • key (str) – name of the requested parameter

  • expression (str) – the expression to be evaluated format: $(context reference)

  • node_name (str) – the node name

  • instance (NodeInst || Container) – an instance

  • context (str) – the context of the evaluation (main flow)

Returns:

the parameter value after evaluation

Return type:

output (str)

dal.helpers.parsers.get_string_from_template(template: str, task_entry: object) str

Applies a task entry into a template

Module contents