当前位置: 首页>>代码示例>>Python>>正文


Python expressions.evaluate_recursively函数代码示例

本文整理汇总了Python中mistral.expressions.evaluate_recursively函数的典型用法代码示例。如果您正苦于以下问题:Python evaluate_recursively函数的具体用法?Python evaluate_recursively怎么用?Python evaluate_recursively使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了evaluate_recursively函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_evaluate_recursively_arbitrary_dict

    def test_evaluate_recursively_arbitrary_dict(self):
        context = {
            "auth_token": "123",
            "project_id": "mistral"
        }
        data = {
            "parameters": {
                "parameter1": {
                    "name1": "$.auth_token",
                    "name2": "val_name2"
                },
                "param2": [
                    "var1",
                    "var2",
                    "/servers/{$.project_id}/bla"
                ]
            },
            "token": "$.auth_token"
        }

        applied = expr.evaluate_recursively(data, context)

        self.assertDictEqual(
            {
                "parameters": {
                    "parameter1": {
                        "name1": "123",
                        "name2": "val_name2"
                    },
                    "param2": ["var1", "var2", "/servers/mistral/bla"]
                },
                "token": "123"
            },
            applied)
开发者ID:TimurNurlygayanov,项目名称:mistral,代码行数:34,代码来源:test_expressions.py

示例2: _convert_params

    def _convert_params(self, params):
        base_params_spec = self.action_spec.base_parameters

        if not base_params_spec:
            return {}

        return expr.evaluate_recursively(base_params_spec, params)
开发者ID:dshulyak,项目名称:mistral,代码行数:7,代码来源:std_actions.py

示例3: _get_adhoc_action_input

def _get_adhoc_action_input(action_def, input_dict,
                            wf_name=None, wf_spec=None):
    action_spec = spec_parser.get_action_spec(action_def.spec)

    base_name = action_spec.get_base()

    action_def = resolve_action_definition(
        base_name,
        wf_name if wf_name else None,
        wf_spec.get_name() if wf_spec else None
    )

    _inject_action_ctx_for_validating(action_def, input_dict)
    e_utils.validate_input(action_def, input_dict, action_spec)

    base_input = action_spec.get_base_input()

    if base_input:
        input_dict = expr.evaluate_recursively(
            base_input,
            input_dict
        )
    else:
        input_dict = {}

    return input_dict
开发者ID:cibingeorge,项目名称:mistral,代码行数:26,代码来源:action_handler.py

示例4: _get_environment

def _get_environment(params):
    env = params.get('env', {})

    if not env:
        return {}

    if isinstance(env, dict):
        env_dict = env
    elif isinstance(env, six.string_types):
        env_db = db_api.load_environment(env)

        if not env_db:
            raise exc.InputException(
                'Environment is not found: %s' % env
            )

        env_dict = env_db.variables
    else:
        raise exc.InputException(
            'Unexpected value type for environment [env=%s, type=%s]'
            % (env, type(env))
        )

    if ('evaluate_env' in params and
            not params['evaluate_env']):
        return env_dict
    else:
        return expr.evaluate_recursively(env_dict, {'__env': env_dict})
开发者ID:openstack,项目名称:mistral,代码行数:28,代码来源:workflows.py

示例5: test_evaluate_recursively

    def test_evaluate_recursively(self):
        task_spec_dict = {
            'parameters': {
                'p1': 'My string',
                'p2': '<% $.param2 %>',
                'p3': ''
            },
            'publish': {
                'new_key11': 'new_key1'
            }
        }

        modified_task = expr.evaluate_recursively(
            task_spec_dict,
            {'param2': 'val32'}
        )

        self.assertDictEqual(
            {
                'parameters': {
                    'p1': 'My string',
                    'p2': 'val32',
                    'p3': ''
                },
                'publish': {
                    'new_key11': 'new_key1'
                }
            },
            modified_task
        )
开发者ID:ainkov,项目名称:mistral,代码行数:30,代码来源:test_expressions.py

示例6: add_workflow_variables_to_context

def add_workflow_variables_to_context(wf_ex, wf_spec):
    wf_ex.context = wf_ex.context or {}

    return utils.merge_dicts(
        wf_ex.context,
        expr.evaluate_recursively(wf_spec.get_vars(), wf_ex.context)
    )
开发者ID:ISCAS-VDI,项目名称:mistral-base,代码行数:7,代码来源:data_flow.py

示例7: _schedule_run_action

def _schedule_run_action(task_ex, task_spec, action_input, index):
    wf_ex = task_ex.workflow_execution
    wf_spec = spec_parser.get_workflow_spec(wf_ex.spec)

    action_spec_name = task_spec.get_action_name()

    action_def = action_handler.resolve_definition(
        action_spec_name,
        task_ex,
        wf_spec
    )

    action_ex = action_handler.create_action_execution(
        action_def, action_input, task_ex, index
    )

    target = expr.evaluate_recursively(
        task_spec.get_target(),
        utils.merge_dicts(
            copy.deepcopy(action_input),
            copy.copy(task_ex.in_context)
        )
    )

    scheduler.schedule_call(
        None,
        'mistral.engine.action_handler.run_existing_action',
        0,
        action_ex_id=action_ex.id,
        target=target
    )
开发者ID:dennybaa,项目名称:mistral,代码行数:31,代码来源:task_handler.py

示例8: _get_with_items_values

    def _get_with_items_values(self):
        """Returns all values evaluated from 'with-items' expression.

        Example:
          DSL:
            with-items:
              - var1 in <% $.arrayI %>
              - var2 in <% $.arrayJ %>

        where arrayI = [1,2,3] and arrayJ = [a,b,c]

        The result of the method in this case will be:
            {
                'var1': [1,2,3],
                'var2': [a,b,c]
            }

        :return: Evaluated 'with-items' expression values.
        """
        ctx_view = data_flow.ContextView(
            self.ctx,
            self.wf_ex.context,
            self.wf_ex.input
        )

        return expr.evaluate_recursively(
            self.task_spec.get_with_items(),
            ctx_view
        )
开发者ID:openstack,项目名称:mistral,代码行数:29,代码来源:tasks.py

示例9: evaluate_object_fields

def evaluate_object_fields(obj, context):
    fields = inspect_utils.get_public_fields(obj)

    evaluated_fields = expr.evaluate_recursively(fields, context)

    for k, v in evaluated_fields.items():
        setattr(obj, k, v)
开发者ID:ainkov,项目名称:mistral,代码行数:7,代码来源:data_flow.py

示例10: add_environment_to_context

def add_environment_to_context(wf_ex):
    wf_ex.context = wf_ex.context or {}

    # If env variables are provided, add an evaluated copy into the context.
    if 'env' in wf_ex.params:
        env = copy.deepcopy(wf_ex.params['env'])
        # An env variable can be an expression of other env variables.
        wf_ex.context['__env'] = expr.evaluate_recursively(env, {'__env': env})
开发者ID:kantorv,项目名称:mistral,代码行数:8,代码来源:data_flow.py

示例11: _convert_result

    def _convert_result(self, result):
        transformer = self.action_spec.output

        if not transformer:
            return result

        # Use base action result as a context for evaluating expressions.
        return expr.evaluate_recursively(transformer, result)
开发者ID:dshulyak,项目名称:mistral,代码行数:8,代码来源:std_actions.py

示例12: _get_target

 def _get_target(self, input_dict):
     return expr.evaluate_recursively(
         self.task_spec.get_target(),
         utils.merge_dicts(
             copy.deepcopy(input_dict),
             copy.deepcopy(self.ctx)
         )
     )
开发者ID:prabhuinbarajan,项目名称:mistral,代码行数:8,代码来源:tasks.py

示例13: get_task_output

def get_task_output(task, result):
    publish_transformer = task['task_spec'].get('publish')

    output = expr.evaluate_recursively(publish_transformer, result) or {}

    if result:
        output['task'] = {task['name']: result}

    return output
开发者ID:dshulyak,项目名称:mistral,代码行数:9,代码来源:data_flow.py

示例14: _evaluate_expression

    def _evaluate_expression(self, expression, ctx=None):
        ctx_view = data_flow.ContextView(
            data_flow.get_current_task_dict(self.task_ex),
            data_flow.get_workflow_environment_dict(self.wf_ex),
            ctx or self.ctx,
            self.wf_ex.context,
            self.wf_ex.input
        )

        return expr.evaluate_recursively(expression, ctx_view)
开发者ID:openstack,项目名称:mistral,代码行数:10,代码来源:tasks.py

示例15: convert

    def convert(self, event_type, event):
        edef = self.get_event_definition(event_type)

        if edef is None:
            LOG.debug('No event definition found for type: %s, use default '
                      'settings instead.', event_type)

            return expressions.evaluate_recursively(DEFAULT_PROPERTIES, event)

        return edef.convert(event)
开发者ID:Tesora,项目名称:tesora-mistral,代码行数:10,代码来源:event_engine.py


注:本文中的mistral.expressions.evaluate_recursively函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。