def launch_with_literals( self, project, domain, literal_inputs, name=None, notification_overrides=None, label_overrides=None, annotation_overrides=None, ): """ Executes the launch plan and returns the execution identifier. This version of execution is meant for when you already have a LiteralMap of inputs. :param Text project: :param Text domain: :param flytekit.models.literals.LiteralMap literal_inputs: Inputs to the execution. :param Text name: [Optional] If specified, an execution will be created with this name. Note: the name must be unique within the context of the project and domain. :param list[flytekit.common.notifications.Notification] notification_overrides: [Optional] If specified, these are the notifications that will be honored for this execution. An empty list signals to disable all notifications. :param flytekit.models.common.Labels label_overrides: :param flytekit.models.common.Annotations annotation_overrides: :rtype: flytekit.common.workflow_execution.SdkWorkflowExecution """ # Kubernetes requires names starting with an alphabet for some resources. name = name or "f" + _uuid.uuid4().hex[:19] disable_all = notification_overrides == [] if disable_all: notification_overrides = None else: notification_overrides = _execution_models.NotificationList(notification_overrides or []) disable_all = None client = _flyte_engine.get_client() try: exec_id = client.create_execution( project, domain, name, _execution_models.ExecutionSpec( self.id, _execution_models.ExecutionMetadata( _execution_models.ExecutionMetadata.ExecutionMode.MANUAL, "sdk", # TODO: get principle 0, # TODO: Detect nesting ), notifications=notification_overrides, disable_all=disable_all, labels=label_overrides, annotations=annotation_overrides, ), literal_inputs, ) except _user_exceptions.FlyteEntityAlreadyExistsException: exec_id = _identifier.WorkflowExecutionIdentifier(project, domain, name) execution = client.get_execution(exec_id) return _workflow_execution.SdkWorkflowExecution.promote_from_model(execution)
def fetch_workflow_execution(project, domain, exec_id): eid = Flyte2Identifier.WorkflowExecutionIdentifier(project=project, domain=domain, name=exec_id) wf_exec = SdkWorkflowExecution.fetch(project=eid.project, domain=eid.domain, name=eid.name) wf_exec.sync() return wf_exec
def fetch(cls, project, domain, name): """ :param Text project: :param Text domain: :param Text name: :rtype: SdkWorkflowExecution """ wf_exec_id = _core_identifier.WorkflowExecutionIdentifier(project=project, domain=domain, name=name) admin_exec = _flyte_engine.get_client().get_execution(wf_exec_id) return cls.promote_from_model(admin_exec)
def fetch(cls, project, domain, name): """ :param Text project: :param Text domain: :param Text name: :rtype: SdkWorkflowExecution """ return cls.promote_from_model( _engine_loader.get_engine().fetch_workflow_execution( _core_identifier.WorkflowExecutionIdentifier(project=project, domain=domain, name=name)))
def launch_with_literals( self, project, domain, literal_inputs, name=None, notification_overrides=None, label_overrides=None, annotation_overrides=None, ): """ Launches a single task execution and returns the execution identifier. :param Text project: :param Text domain: :param flytekit.models.literals.LiteralMap literal_inputs: Inputs to the execution. :param Text name: [Optional] If specified, an execution will be created with this name. Note: the name must be unique within the context of the project and domain. :param list[flytekit.common.notifications.Notification] notification_overrides: [Optional] If specified, these are the notifications that will be honored for this execution. An empty list signals to disable all notifications. :param flytekit.models.common.Labels label_overrides: :param flytekit.models.common.Annotations annotation_overrides: :rtype: flytekit.common.workflow_execution.SdkWorkflowExecution """ disable_all = notification_overrides == [] if disable_all: notification_overrides = None else: notification_overrides = _admin_execution_models.NotificationList( notification_overrides or []) disable_all = None assumable_iam_role = _auth_config.ASSUMABLE_IAM_ROLE.get() kubernetes_service_account = _auth_config.KUBERNETES_SERVICE_ACCOUNT.get( ) if not (assumable_iam_role or kubernetes_service_account): _logging.warning( "Using deprecated `role` from config. " "Please update your config to use `assumable_iam_role` instead" ) assumable_iam_role = _sdk_config.ROLE.get() auth_role = _common_model.AuthRole( assumable_iam_role=assumable_iam_role, kubernetes_service_account=kubernetes_service_account, ) client = _flyte_engine.get_client() try: # TODO(katrogan): Add handling to register the underlying task if it's not already. exec_id = client.create_execution( project, domain, name, _admin_execution_models.ExecutionSpec( self.id, _admin_execution_models.ExecutionMetadata( _admin_execution_models.ExecutionMetadata. ExecutionMode.MANUAL, "sdk", # TODO: get principle 0, # TODO: Detect nesting ), notifications=notification_overrides, disable_all=disable_all, labels=label_overrides, annotations=annotation_overrides, auth_role=auth_role, ), literal_inputs, ) except _user_exceptions.FlyteEntityAlreadyExistsException: exec_id = _identifier.WorkflowExecutionIdentifier( project, domain, name) execution = client.get_execution(exec_id) return _workflow_execution.SdkWorkflowExecution.promote_from_model( execution)