ai_flow.ops package

Submodules

ai_flow.ops.namespace_ops module

ai_flow.ops.namespace_ops.add_namespace(name: str, properties: dict)ai_flow.metadata.namespace.NamespaceMeta[source]

Creates a new namespace in metadata.

Parameters
  • name – The name of namespace to be added.

  • properties – The properties of namespace.

Returns

The NamespaceMeta instance just added.

ai_flow.ops.namespace_ops.delete_namespace(name: str)[source]

Deletes the namespace from metadata.

Parameters

name – The name of namespace.

Raises

AIFlowException if failed to delete namespace.

ai_flow.ops.namespace_ops.get_namespace(name: str)Optional[ai_flow.metadata.namespace.NamespaceMeta][source]

Retrieves the namespace from metadata.

Parameters

name – The name of namespace.

Returns

The NamespaceMeta instance, return None if no namespace found.

ai_flow.ops.namespace_ops.list_namespace(limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.namespace.NamespaceMeta]][source]

Retrieves the list of namespaces from metadata.

Parameters
  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The NamespaceMeta list, return None if no namespace found.

ai_flow.ops.namespace_ops.update_namespace(name: str, properties: dict)Optional[ai_flow.metadata.namespace.NamespaceMeta][source]

Updates the properties of the namespace.

Parameters
  • name – The name of namespace to be updated.

  • properties – The properties of namespace.

Returns

The NamespaceMeta instance just updated, return None if no namespace found.

ai_flow.ops.task_execution_ops module

ai_flow.ops.task_execution_ops.get_task_execution(task_execution_id: int)ai_flow.metadata.task_execution.TaskExecutionMeta[source]

Retrieves the task execution from metadata.

Parameters

task_execution_id – The id of the task execution.

Returns

The TaskExecutionMeta instance, return None if no execution found.

ai_flow.ops.task_execution_ops.list_task_executions(workflow_execution_id: int, limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.task_execution.TaskExecutionMeta]][source]

Retrieves the list of executions of the task of the workflow execution.

Parameters
  • workflow_execution_id – The id of the workflow execution.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The TaskExecutionMeta list, return None if no task execution found.

ai_flow.ops.task_execution_ops.start_task_execution(workflow_execution_id: int, task_name: str)str[source]

Start a new execution of the task.

Parameters
  • workflow_execution_id – The workflow execution contains the task.

  • task_name – The name of the task to be started.

Returns

The TaskExecutionKey str.

Raises

AIFlowException if failed to start task execution.

ai_flow.ops.task_execution_ops.stop_task_execution(workflow_execution_id: int, task_name: str)[source]

Asynchronously stop the task execution.

Parameters
  • workflow_execution_id – The workflow execution contains the task.

  • task_name – The name of the task to be stopped.

Raises

AIFlowException if failed to stop task execution.

ai_flow.ops.workflow_execution_ops module

ai_flow.ops.workflow_execution_ops.delete_workflow_execution(workflow_execution_id: int)[source]

Deletes the workflow execution from metadata, note that the workflow execution to be deleted should be finished.

Parameters

workflow_execution_id – The id of the workflow execution.

Raises

AIFlowException if failed to delete the workflow execution.

ai_flow.ops.workflow_execution_ops.get_workflow_execution(workflow_execution_id: int)Optional[ai_flow.metadata.workflow_execution.WorkflowExecutionMeta][source]

Retrieves the workflow execution from metadata.

Parameters

workflow_execution_id – The id of the workflow execution.

Returns

The WorkflowExecutionMeta instance, return None if no execution found.

ai_flow.ops.workflow_execution_ops.list_workflow_executions(workflow_name: str, namespace: str = 'default', limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.workflow_execution.WorkflowExecutionMeta]][source]

Retrieves the list of executions of the workflow.

Parameters
  • workflow_name – The workflow to be listed.

  • namespace – The namespace which contains the workflow.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The WorkflowExecutionMeta list, return None if no workflow execution found.

ai_flow.ops.workflow_execution_ops.start_workflow_execution(workflow_name: str, namespace: str = 'default')int[source]

Start a new execution of the workflow.

Parameters
  • workflow_name – The workflow to be executed.

  • namespace – The namespace which contains the workflow.

Returns

Id of the workflow execution just started.

Raises

AIFlowException if failed to start workflow execution.

ai_flow.ops.workflow_execution_ops.stop_workflow_execution(workflow_execution_id: int)[source]

Asynchronously stop the execution of the workflow.

Parameters

workflow_execution_id – The id of workflow execution to be stopped.

Raises

AIFlowException if failed to stop the workflow execution.

ai_flow.ops.workflow_execution_ops.stop_workflow_executions(workflow_name: str, namespace: str = 'default')[source]

Asynchronously stop all executions of the workflow.

Parameters
  • workflow_name – The workflow to be stopped.

  • namespace – The namespace which contains the workflow.

Raises

AIFlowException if failed to stop workflow executions.

ai_flow.ops.workflow_ops module

ai_flow.ops.workflow_ops.delete_workflow(workflow_name: str, namespace: str = 'default')[source]

Deletes the workflow from metadata, also its executions, schedules and triggers would be cascade deleted, however if not-finished workflow execution found, the deletion would be interrupted.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace of the workflow.

Raises

AIFlowException if failed to delete the workflow.

ai_flow.ops.workflow_ops.disable_workflow(workflow_name: str, namespace: str = 'default')[source]

Disables the workflow so that no more executions would be started, however, the existed executions are not effected.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace of the workflow.

Raises

AIFlowException if failed to disable workflow.

ai_flow.ops.workflow_ops.enable_workflow(workflow_name: str, namespace: str = 'default')[source]

Enables the workflow.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace of the workflow.

Raises

AIFlowException if failed to enable workflow.

ai_flow.ops.workflow_ops.get_workflow(workflow_name: str, namespace: str = 'default')Optional[ai_flow.metadata.workflow.WorkflowMeta][source]

Retrieves the workflow from metadata.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace of the workflow.

Returns

The WorkflowMeta instance, return None if no workflow found.

ai_flow.ops.workflow_ops.list_workflows(namespace: str = 'default', limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.workflow.WorkflowMeta]][source]

Retrieves the list of workflow of the namespace from metadata.

Parameters
  • namespace – The namespace of the workflow.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The WorkflowMeta list, return None if no workflow found.

ai_flow.ops.workflow_ops.upload_workflows(workflow_file_path: str, artifacts: Optional[List[str]] = None)List[ai_flow.metadata.workflow.WorkflowMeta][source]

Upload the workflow defined in workflow_file_path along with it’s dependencies to AIFlow server.

Parameters
  • workflow_file_path – The path of the workflow to be uploaded.

  • artifacts – The artifacts that the workflow needed.

Returns

The uploaded workflows.

ai_flow.ops.workflow_schedule_ops module

ai_flow.ops.workflow_schedule_ops.add_workflow_schedule(expression: str, workflow_name: str, namespace: str = 'default')ai_flow.metadata.workflow_schedule.WorkflowScheduleMeta[source]

Creates a new workflow schedule in metadata.

Parameters
  • expression

    The string express when the workflow execution is triggered. Two types of expression are supported here: cron and interval. cron_expression:

    cron@minute, hour, day of month, month, day of week See https://en.wikipedia.org/wiki/Cron for more information on the format accepted here.

    interval_expression:

    interval@days hours minutes seconds e.g. “interval@0 1 0 0” means running every 1 hour since now.

  • workflow_name – The name of the workflow to be registered schedule.

  • namespace – The namespace of the workflow.

Returns

The WorkflowScheduleMeta instance just added.

ai_flow.ops.workflow_schedule_ops.delete_workflow_schedule(schedule_id)[source]

Deletes the workflow schedule from metadata.

Parameters

schedule_id – The id of the workflow schedule.

Raises

AIFlowException if failed to delete the workflow schedule.

ai_flow.ops.workflow_schedule_ops.delete_workflow_schedules(workflow_name: str, namespace: str = 'default')[source]

Deletes all schedules of the workflow.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace which contains the workflow.

Raises

AIFlowException if failed to delete workflow schedules.

ai_flow.ops.workflow_schedule_ops.get_workflow_schedule(schedule_id: int)Optional[ai_flow.metadata.workflow_schedule.WorkflowScheduleMeta][source]

Retrieves the workflow schedule from metadata.

Parameters

schedule_id – The id of the schedule.

Returns

The WorkflowScheduleMeta instance, return None if no schedule found.

ai_flow.ops.workflow_schedule_ops.list_workflow_schedules(workflow_name: str, namespace: str = 'default', limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.workflow_schedule.WorkflowScheduleMeta]][source]

Retrieves the list of schedules of the workflow.

Parameters
  • workflow_name – The workflow to be listed schedules.

  • namespace – The namespace which contains the workflow.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The WorkflowScheduleMeta list, return None if no workflow schedules found.

ai_flow.ops.workflow_schedule_ops.pause_workflow_schedule(schedule_id: int)[source]

Pauses the workflow schedule.

Parameters

schedule_id – The id of the workflow schedule.

Raises

AIFlowException if failed to pause the workflow schedule.

ai_flow.ops.workflow_schedule_ops.resume_workflow_schedule(schedule_id: int)[source]

Resumes the workflow schedule which is paused before.

Parameters

schedule_id – The id of the workflow schedule.

Raises

AIFlowException if failed to resume the workflow schedule.

ai_flow.ops.workflow_snapshot_ops module

ai_flow.ops.workflow_snapshot_ops.delete_workflow_snapshot(snapshot_id: int)[source]

Deletes the workflow snapshot from metadata.

Parameters

snapshot_id – The id of the workflow snapshot.

Raises

AIFlowException if failed to delete the workflow snapshot.

ai_flow.ops.workflow_snapshot_ops.delete_workflow_snapshots(workflow_name: str, namespace: str = 'default')[source]

Deletes all snapshots of the workflow.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace which contains the workflow.

Raises

AIFlowException if failed to delete workflow snapshots.

ai_flow.ops.workflow_snapshot_ops.get_workflow_snapshot(snapshot_id: int)Optional[ai_flow.metadata.workflow_snapshot.WorkflowSnapshotMeta][source]

Retrieves the workflow snapshot from metadata.

Parameters

snapshot_id – The id of the snapshot.

Returns

The WorkflowSnapshotMeta instance, return None if no snapshot found.

ai_flow.ops.workflow_snapshot_ops.list_workflow_snapshots(workflow_name: str, namespace: str = 'default', limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.workflow_snapshot.WorkflowSnapshotMeta]][source]

Retrieves the list of snapshots of the workflow.

Parameters
  • workflow_name – The workflow to be listed.

  • namespace – The namespace which contains the workflow.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The WorkflowSnapshotMeta list, return None if no workflow snapshots found.

ai_flow.ops.workflow_trigger_ops module

ai_flow.ops.workflow_trigger_ops.add_workflow_trigger(rule: ai_flow.model.rule.WorkflowRule, workflow_name: str, namespace: str = 'default')ai_flow.metadata.workflow_event_trigger.WorkflowEventTriggerMeta[source]

Creates a new workflow event trigger in metadata.

Parameters
  • rule – The rule that used to to judge whether start a new workflow execution

  • workflow_name – The name of the workflow to be registered trigger.

  • namespace – The namespace of the workflow.

Returns

The WorkflowEventTriggerMeta instance just added.

ai_flow.ops.workflow_trigger_ops.delete_workflow_trigger(trigger_id)[source]

Deletes the workflow trigger from metadata.

Parameters

trigger_id – The id of the workflow trigger.

Raises

AIFlowException if failed to delete the workflow trigger.

ai_flow.ops.workflow_trigger_ops.delete_workflow_triggers(workflow_name: str, namespace: str = 'default')[source]

Deletes all event triggers of the workflow.

Parameters
  • workflow_name – The name of the workflow.

  • namespace – The namespace which contains the workflow.

Raises

AIFlowException if failed to delete workflow triggers.

ai_flow.ops.workflow_trigger_ops.get_workflow_trigger(trigger_id: int)Optional[ai_flow.metadata.workflow_event_trigger.WorkflowEventTriggerMeta][source]

Retrieves the workflow trigger from metadata.

Parameters

trigger_id – The id of the trigger.

Returns

The WorkflowEventTriggerMeta instance, return None if no trigger found.

ai_flow.ops.workflow_trigger_ops.list_workflow_triggers(workflow_name: str, namespace: str = 'default', limit: Optional[int] = None, offset: Optional[int] = None)Optional[List[ai_flow.metadata.workflow_event_trigger.WorkflowEventTriggerMeta]][source]

Retrieves the list of triggers of the workflow.

Parameters
  • workflow_name – The workflow to be listed triggers.

  • namespace – The namespace which contains the workflow.

  • limit – The maximum records to be listed.

  • offset – The offset to start to list.

Returns

The WorkflowEventTriggerMeta list, return None if no workflow trigger found.

ai_flow.ops.workflow_trigger_ops.pause_workflow_trigger(trigger_id: int)[source]

Pauses the workflow trigger.

Parameters

trigger_id – The id of the workflow trigger.

Raises

AIFlowException if failed to pause the workflow trigger.

ai_flow.ops.workflow_trigger_ops.resume_workflow_trigger(trigger_id: int)[source]

Resumes the workflow trigger which is paused before.

Parameters

trigger_id – The id of the workflow trigger.

Raises

AIFlowException if failed to resume the workflow trigger.