Ejemplo n.º 1
0
    def execute(self, context: 'Context'):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
        self.log.info("Creating execution")
        execution = hook.create_execution(
            workflow_id=self.workflow_id,
            execution=self.execution,
            location=self.location,
            project_id=self.project_id,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )
        execution_id = execution.name.split("/")[-1]
        self.xcom_push(context, key="execution_id", value=execution_id)

        WorkflowsExecutionLink.persist(
            context=context,
            task_instance=self,
            location_id=self.location,
            workflow_id=self.workflow_id,
            execution_id=execution_id,
            project_id=self.project_id or hook.project_id,
        )

        return Execution.to_dict(execution)
Ejemplo n.º 2
0
 def execute(self, context: 'Context'):
     hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
     self.log.info("Retrieving execution %s for workflow %s", self.execution_id, self.workflow_id)
     execution = hook.get_execution(
         workflow_id=self.workflow_id,
         execution_id=self.execution_id,
         location=self.location,
         project_id=self.project_id,
         retry=self.retry,
         timeout=self.timeout,
         metadata=self.metadata,
     )
     return Execution.to_dict(execution)
Ejemplo n.º 3
0
    def execute(self, context: 'Context'):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
        self.log.info("Retrieving executions for workflow %s", self.workflow_id)
        execution_iter = hook.list_executions(
            workflow_id=self.workflow_id,
            location=self.location,
            project_id=self.project_id,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )

        return [Execution.to_dict(e) for e in execution_iter if e.start_time > self.start_date_filter]
Ejemplo n.º 4
0
    def execute(self, context: 'Context'):
        hook = WorkflowsHook(gcp_conn_id=self.gcp_conn_id, impersonation_chain=self.impersonation_chain)
        self.log.info("Canceling execution %s", self.execution_id)
        execution = hook.cancel_execution(
            workflow_id=self.workflow_id,
            execution_id=self.execution_id,
            location=self.location,
            project_id=self.project_id,
            retry=self.retry,
            timeout=self.timeout,
            metadata=self.metadata,
        )

        WorkflowsExecutionLink.persist(
            context=context,
            task_instance=self,
            location_id=self.location,
            workflow_id=self.workflow_id,
            execution_id=self.execution_id,
            project_id=self.project_id or hook.project_id,
        )

        return Execution.to_dict(execution)