Esempio n. 1
0
    def _create_task_execution(self, state=states.RUNNING, state_info=None):
        task_id = utils.generate_unicode_uuid()
        task_name = self.task_spec.get_name()
        task_type = self.task_spec.get_type()

        values = {
            'id': task_id,
            'name': task_name,
            'workflow_execution_id': self.wf_ex.id,
            'workflow_name': self.wf_ex.workflow_name,
            'workflow_namespace': self.wf_ex.workflow_namespace,
            'workflow_id': self.wf_ex.workflow_id,
            'state': state,
            'state_info': state_info,
            'spec': self.task_spec.to_dict(),
            'unique_key': self.unique_key,
            'in_context': self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id': self.wf_ex.project_id,
            'type': task_type
        }

        if self.triggered_by:
            values['runtime_context']['triggered_by'] = self.triggered_by

        self.task_ex = db_api.create_task_execution(values)

        self.created = True
Esempio n. 2
0
    def _create_task_execution(self, state=states.RUNNING, state_info=None):
        task_id = utils.generate_unicode_uuid()
        task_name = self.task_spec.get_name()
        task_type = self.task_spec.get_type()

        data_flow.add_current_task_to_context(self.ctx, task_id, task_name)

        values = {
            'id': task_id,
            'name': task_name,
            'workflow_execution_id': self.wf_ex.id,
            'workflow_name': self.wf_ex.workflow_name,
            'workflow_namespace': self.wf_ex.workflow_namespace,
            'workflow_id': self.wf_ex.workflow_id,
            'state': state,
            'state_info': state_info,
            'spec': self.task_spec.to_dict(),
            'unique_key': self.unique_key,
            'in_context': self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id': self.wf_ex.project_id,
            'type': task_type
        }

        if self.triggered_by:
            values['runtime_context']['triggered_by'] = self.triggered_by

        self.task_ex = db_api.create_task_execution(values)

        # Add to collection explicitly so that it's in a proper
        # state within the current session.
        self.wf_ex.task_executions.append(self.task_ex)

        self.created = True
Esempio n. 3
0
    def _create_task_execution(self, state=states.RUNNING, state_info=None):
        task_id = utils.generate_unicode_uuid()
        task_name = self.task_spec.get_name()
        task_type = self.task_spec.get_type()

        values = {
            'id': task_id,
            'name': task_name,
            'workflow_execution_id': self.wf_ex.id,
            'workflow_name': self.wf_ex.workflow_name,
            'workflow_namespace': self.wf_ex.workflow_namespace,
            'workflow_id': self.wf_ex.workflow_id,
            'state': state,
            'state_info': state_info,
            'spec': self.task_spec.to_dict(),
            'unique_key': self.unique_key,
            'in_context': self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id': self.wf_ex.project_id,
            'type': task_type
        }

        if self.triggered_by:
            values['runtime_context']['triggered_by'] = self.triggered_by

        self.task_ex = db_api.create_task_execution(values)

        self.created = True
Esempio n. 4
0
    def _create_task_execution(self, state=states.RUNNING, state_info=None):
        task_id = utils.generate_unicode_uuid()
        task_name = self.task_spec.get_name()
        task_type = self.task_spec.get_type()

        data_flow.add_current_task_to_context(self.ctx, task_id, task_name)

        values = {
            'id': task_id,
            'name': task_name,
            'workflow_execution_id': self.wf_ex.id,
            'workflow_name': self.wf_ex.workflow_name,
            'workflow_id': self.wf_ex.workflow_id,
            'state': state,
            'state_info': state_info,
            'spec': self.task_spec.to_dict(),
            'unique_key': self.unique_key,
            'in_context': self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id': self.wf_ex.project_id,
            'type': task_type
        }

        self.task_ex = db_api.create_task_execution(values)

        # Add to collection explicitly so that it's in a proper
        # state within the current session.
        self.wf_ex.task_executions.append(self.task_ex)

        self.created = True
Esempio n. 5
0
    def _create_task_execution(self, state=states.RUNNING):
        self.task_ex = db_api.create_task_execution({
            'name':
            self.task_spec.get_name(),
            'workflow_execution_id':
            self.wf_ex.id,
            'workflow_name':
            self.wf_ex.workflow_name,
            'workflow_id':
            self.wf_ex.workflow_id,
            'state':
            state,
            'spec':
            self.task_spec.to_dict(),
            'in_context':
            self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id':
            self.wf_ex.project_id
        })

        # Add to collection explicitly so that it's in a proper
        # state within the current session.
        self.wf_ex.task_executions.append(self.task_ex)
Esempio n. 6
0
    def _create_task_execution(self, name, state):
        tasks_spec = self.wb_spec.get_workflows()['wf'].get_tasks()

        return db_api.create_task_execution({
            'name': name,
            'spec': tasks_spec[name].to_dict(),
            'state': state,
            'workflow_execution_id': self.wf_ex.id
        })
Esempio n. 7
0
    def _create_task_execution(self, state=states.RUNNING):
        self.task_ex = db_api.create_task_execution({
            'name': self.task_spec.get_name(),
            'workflow_execution_id': self.wf_ex.id,
            'workflow_name': self.wf_ex.workflow_name,
            'workflow_id': self.wf_ex.workflow_id,
            'state': state,
            'spec': self.task_spec.to_dict(),
            'in_context': self.ctx,
            'published': {},
            'runtime_context': {},
            'project_id': self.wf_ex.project_id
        })

        # Add to collection explicitly so that it's in a proper
        # state within the current session.
        self.wf_ex.task_executions.append(self.task_ex)
Esempio n. 8
0
def _create_workflow_executions():
    time_now = datetime.datetime.utcnow()

    wf_execs = [
        {
            'id': 'success_expired',
            'name': 'success_expired',
            'created_at': time_now - datetime.timedelta(minutes=60),
            'updated_at': time_now - datetime.timedelta(minutes=59),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
        },
        {
            'id': 'error_expired',
            'name': 'error_expired',
            'created_at': time_now - datetime.timedelta(days=3, minutes=10),
            'updated_at': time_now - datetime.timedelta(days=3),
            'workflow_name': 'test_exec',
            'state': "ERROR",
        },
        {
            'id': 'running_not_expired',
            'name': 'running_not_expired',
            'created_at': time_now - datetime.timedelta(days=3, minutes=10),
            'updated_at': time_now - datetime.timedelta(days=3),
            'workflow_name': 'test_exec',
            'state': "RUNNING",
        },
        {
            'id': 'running_not_expired2',
            'name': 'running_not_expired2',
            'created_at': time_now - datetime.timedelta(days=3, minutes=10),
            'updated_at': time_now - datetime.timedelta(days=4),
            'workflow_name': 'test_exec',
            'state': "RUNNING",
        },
        {
            'id': 'success_not_expired',
            'name': 'success_not_expired',
            'created_at': time_now - datetime.timedelta(minutes=15),
            'updated_at': time_now - datetime.timedelta(minutes=5),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
        },
        {
            'id': 'abc',
            'name': 'cancelled_expired',
            'created_at': time_now - datetime.timedelta(minutes=60),
            'updated_at': time_now - datetime.timedelta(minutes=59),
            'workflow_name': 'test_exec',
            'state': "CANCELLED",
        },
        {
            'id': 'cancelled_not_expired',
            'name': 'cancelled_not_expired',
            'created_at': time_now - datetime.timedelta(minutes=15),
            'updated_at': time_now - datetime.timedelta(minutes=6),
            'workflow_name': 'test_exec',
            'state': "CANCELLED",
        }
    ]

    for wf_exec in wf_execs:
        db_api.create_workflow_execution(wf_exec)

    # Create a nested workflow execution.

    db_api.create_task_execution(
        {
            'id': 'running_not_expired',
            'workflow_execution_id': 'success_not_expired',
            'name': 'my_task'
        }
    )

    db_api.create_workflow_execution(
        {
            'id': 'expired_but_not_a_parent',
            'name': 'expired_but_not_a_parent',
            'created_at': time_now - datetime.timedelta(days=15),
            'updated_at': time_now - datetime.timedelta(days=10),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
            'task_execution_id': 'running_not_expired'
        }
    )
def _create_workflow_executions():
    time_now = datetime.datetime.now()

    wf_execs = [
        {
            'id': '123',
            'name': 'success_expired',
            'created_at': time_now - datetime.timedelta(minutes=60),
            'updated_at': time_now - datetime.timedelta(minutes=59),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
        },
        {
            'id': '456',
            'name': 'error_expired',
            'created_at': time_now - datetime.timedelta(days=3, minutes=10),
            'updated_at': time_now - datetime.timedelta(days=3),
            'workflow_name': 'test_exec',
            'state': "ERROR",
        },
        {
            'id': '789',
            'name': 'running_not_expired',
            'created_at': time_now - datetime.timedelta(days=3, minutes=10),
            'updated_at': time_now - datetime.timedelta(days=3),
            'workflow_name': 'test_exec',
            'state': "RUNNING",
        },
        {
            'id': '987',
            'name': 'success_not_expired',
            'created_at': time_now - datetime.timedelta(minutes=15),
            'updated_at': time_now - datetime.timedelta(minutes=5),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
        },
        {
            'id': 'abc',
            'name': 'cancelled_expired',
            'created_at': time_now - datetime.timedelta(minutes=60),
            'updated_at': time_now - datetime.timedelta(minutes=59),
            'workflow_name': 'test_exec',
            'state': "CANCELLED",
        },
        {
            'id': 'def',
            'name': 'cancelled_not_expired',
            'created_at': time_now - datetime.timedelta(minutes=15),
            'updated_at': time_now - datetime.timedelta(minutes=5),
            'workflow_name': 'test_exec',
            'state': "CANCELLED",
        }
    ]

    for wf_exec in wf_execs:
        db_api.create_workflow_execution(wf_exec)

    # Create a nested workflow execution.

    db_api.create_task_execution(
        {
            'id': '789',
            'workflow_execution_id': '987',
            'name': 'my_task'
        }
    )

    db_api.create_workflow_execution(
        {
            'id': '654',
            'name': 'expired but not a parent',
            'created_at': time_now - datetime.timedelta(days=15),
            'updated_at': time_now - datetime.timedelta(days=10),
            'workflow_name': 'test_exec',
            'state': "SUCCESS",
            'task_execution_id': '789'
        }
    )