コード例 #1
0
ファイル: entrypoint.py プロジェクト: adorsk/mission_control
def main():
    flow_spec = {
        'label': 'test_flow',
        'tasks': [
            {
                'key': 'task_1',
                'task_type': 'wire',
                'task_params': {
                    'wirings': [
                        {'dest': 'ctx.flow.tasks.task_2.task_params.msg',
                         'value': 'msg set by task_1'}
                    ]
                },
                'data': {'some_key': 'value from task_1.data'},
            },
            {
                'key': 'task_2',
                'task_type': 'print',
                'task_params': {'msg': 'I will be set from task_1'},
            },
            {
                'key': 'task_3',
                'task_type': 'print',
                'task_params': {'msg': '$ctx.flow.tasks.task_1.data.some_key'},
            }
        ]
    }
    flow_engine = FlowEngine()
    flow = flow_engine.flow_spec_to_flow(flow_spec=flow_spec)
    flow_engine.run_flow(flow=flow)
コード例 #2
0
def main():
    flow_spec = {
        'label':
        'test_flow',
        'tasks': [{
            'key': 'task_1',
            'task_type': 'wire',
            'task_params': {
                'wirings': [{
                    'dest': ('ctx.flow.tasks.task_2.task_params.msg'),
                    'value': 'message set by task_1'
                }]
            },
            'precursors': ['ROOT'],
        }, {
            'key': 'task_2',
            'task_type': 'print',
            'task_params': {
                'msg': 'I will be set from task_1'
            },
            'precursors': ['task_1'],
        }]
    }
    flow_engine = FlowEngine()
    flow = flow_engine.flow_spec_to_flow(flow_spec=flow_spec)
    flow_engine.run_flow(flow=flow)
コード例 #3
0
def main():
    flow_spec = {
        'label': 'test_flow',
        'tasks': [
            {
                'key': 'spreader',
                'task_type': 'spread',
                'task_params': {
                    'container_task_type': 'mc.tasks.inline_flow',
                    'items': ['item_%s' % i for i in range(3)],
                    'mapping_params': {
                        'skeleton': {
                            'task_type': 'print',
                            'task_params': {'msg': 'TO BE WIRED'}
                        },
                        'wirings': [
                            'ctx.item.value => ctx.skeleton.task_params.msg'
                        ]
                    }
                }
            }
        ]
    }
    flow_engine = FlowEngine()
    flow = flow_engine.flow_spec_to_flow(flow_spec=flow_spec)
    flow_engine.run_flow(flow=flow)
コード例 #4
0
ファイル: entrypoint.py プロジェクト: adorsk/mission_control
def main():
    flow_spec = {
        'label':
        'example_flow',
        'tasks': [{
            'key': 'task_1',
            'task_type': 'print',
            'task_params': {
                'msg': 'I am task_1.'
            },
        }, {
            'key': 'task_2',
            'task_type': 'print',
            'task_params': {
                'msg': 'I am task_2.'
            },
        }, {
            'key': 'task_3',
            'task_type': 'print',
            'task_params': {
                'msg': 'I am task_3.'
            },
        }]
    }
    flow_engine = FlowEngine()
    flow = flow_engine.flow_spec_to_flow(flow_spec=flow_spec)
    flow_engine.run_flow(flow=flow)
コード例 #5
0
    def create_flow_record_from_flow_spec(self, flow_spec=None):
        """Create a flow record from flow spec.

        Converts flow_spec to flow via flow_engine.

        Args:
            flow_spec (dict): a flow_spec

        Returns:
            flow_record (dict): a flow_record.
        """
        flow = FlowEngine.flow_spec_to_flow(flow_spec=flow_spec)
        flow_dict = FlowEngine.flow_to_flow_dict(flow=flow)
        return self.create_flow_record(flow_kwargs=flow_dict)
コード例 #6
0
def main():
    sys.path.insert(1, _DIR)
    flow_spec = {
        'label': 'test_flow',
        'tasks': [
            {
                'key': 'task_1',
                'task_type': 'my_custom_proxying_task',
                'task_params': {
                    'param1': 'value1',
                    'param2': 'value2',
                },
                'precursors': ['ROOT'],
            }
        ]
    }
    flow_engine = FlowEngine()
    flow = flow_engine.flow_spec_to_flow(flow_spec=flow_spec)
    try: flow_engine.run_flow(flow=flow)
    except flow_engine.FlowError as exc:
        for error in exc.flow.data.get('errors', []): print(error)
        raise exc
コード例 #7
0
ファイル: entrypoint.py プロジェクト: adorsk/mission_control
def main():
    sandbox = McSandbox()
    mc_db = sandbox.mc_db
    flow_engine = FlowEngine()
    create_flows(mc_db=mc_db, flow_engine=flow_engine)
    flow_runner = FlowRunner(
        flow_engine=flow_engine,
        flow_record_client=sandbox.flow_record_client,
    )
    tick_stats = flow_runner.tick()
    while tick_stats['claimed'] > 0:
        tick_stats = flow_runner.tick()
    print("No more flows to claimed.")
コード例 #8
0
 def setup_flow_engine(self):
     return FlowEngine()
コード例 #9
0
 def flow_engine(self):
     if not hasattr(self, '_flow_engine'):
         self._flow_engine = FlowEngine()
     return self._flow_engine
コード例 #10
0
ファイル: flow_runner.py プロジェクト: adorsk/mission_control
 def get_default_flow_engine(self):
     from mc.flows.flow_engine import FlowEngine
     return FlowEngine()