# Prefect Tasks
Tasks for interacting with the Prefect API
# StartFlowRun
class
prefect.tasks.prefect.flow_run.StartFlowRun
(flow_name=None, project_name=None, parameters=None, run_config=None, wait=False, new_flow_context=None, run_name=None, scheduled_start_time=None, poll_interval=datetime.timedelta(seconds=10), create_link_artifact=True, **kwargs)[source]Task used to kick off a flow run using Prefect Core's server or Prefect Cloud. If multiple versions of the flow are found, this task will kick off the most recent unarchived version.
Args:
flow_name (str, optional)
: the name of the flow to schedule; this value may also be provided at run timeproject_name (str, optional)
: the name of the project in which the flow is located; this value may also be provided at runtime.parameters (dict, optional)
: the parameters to pass to the flow run being scheduled; this value may also be provided at run timerun_config (RunConfig, optional)
: a run-config to use for this flow run, overriding any existing flow settings.wait (bool, optional)
: whether to wait the triggered flow run's state; if True, this task will wait until the flow run is complete, and then reflect the corresponding state as the state of this task. Defaults toFalse
.new_flow_context (dict, optional)
: the optional run context for the new flow runrun_name (str, optional)
: name to be set for the flow runscheduled_start_time (datetime, optional)
: the time to schedule the execution for; if not provided, defaults to nowpoll_interval (timedelta)
: the time to wait between each check if the flow is finished. Has to be >= 3 seconds. Used only ifwait=True
. Defaults to 10 seconds.create_link_artifact (bool, optional)
: whether to create a link artifact to the child flow run page. Defaults toTrue
.**kwargs (dict, optional)
: additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.prefect.flow_run.StartFlowRun.run (flow_name=None, project_name=None, parameters=None, run_config=None, new_flow_context=None, run_name=None, idempotency_key=None, scheduled_start_time=None)[source] |
Run method for the task; responsible for scheduling the specified flow run.
|
# RenameFlowRun
class
prefect.tasks.prefect.flow_run_rename.RenameFlowRun
(flow_run_id=None, flow_run_name=None, **kwargs)[source]Task used to rename a running flow.
Args:
flow_run_id (str, optional)
: The ID of the flow run to rename.flow_run_name (str, optional)
: The new flow run name.**kwargs (dict, optional)
: additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.prefect.flow_run_rename.RenameFlowRun.run (flow_run_id, flow_run_name)[source] |
Args:
|
# CancelFlowRun
Task to cancel a flow run. If flow_run_id
is not provided, flow_run_id
from prefect.context
will be used by default
Args:
flow_run_id (str, optional)
: The ID of the flow run to cancel**kwargs (dict, optional)
: additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.prefect.flow_run_cancel.CancelFlowRun.run (flow_run_id=None)[source] |
Args:
|
# create_flow_run
prefect.tasks.prefect.flow_run.create_flow_run
(flow_id=None, flow_name=None, project_name="", parameters=None, context=None, labels=None, run_name=None, run_config=None, scheduled_start_time=None, idempotency_key=None)[source]Task to create a flow run in the Prefect backend.
The flow to run must be registered and an agent must be available to deploy the flow run.
Args:
flow_id
: The flow or flow group uuid to lookup the flow to runflow_name
: The flow name to lookup the flow to runproject_name
: The project name to lookup the flow to run. For use withflow_name
if you have flows with the same name in multiple projectsparameters
: An optional dictionary of parameters to pass to the flow runcontext
: An optional dictionary of context variables to pass to the flow runlabels
: An optional iterable of labels to set on the flow run; if not provided, the default set of labels for the flow will be usedrun_name
: An optional name for the flow run; if not provided, the name will be generated as "{current_run_name}-{flow_name}"run_config
: An optional run config to use for the flow run; will override any existing run config settingsscheduled_start_time
: An optional time in the future to schedule flow run execution for. If not provided, the flow run will be scheduled to start nowidempotency_key
: a unique idempotency key for scheduling the flow run. Duplicate flow runs with the same idempotency key will only create a single flow run. This is useful for ensuring that only one run is created if this task is retried. If not provided, defaults to the active task run id and its map index.
methods: |
---|
prefect.tasks.prefect.flow_run.create_flow_run (flow_id=None, flow_name=None, project_name="", parameters=None, context=None, labels=None, run_name=None, run_config=None, scheduled_start_time=None, idempotency_key=None)[source] |
Task to create a flow run in the Prefect backend.
|
# get_task_run_result
prefect.tasks.prefect.flow_run.get_task_run_result
(flow_run_id, task_slug, map_index=-1, poll_time=5)[source]Task to get the result of a task from a flow run.
Will wait for the flow run to finish entirely or dynamic task run results will not be properly populated.
Results are loaded from the Result
location of the task which may not be accessible from where this task is executed. You will need to ensure results can be accessed.
Args:
flow_run_id
: The flow run the task run belongs totask_slug
: The 'slug' of the task run you want to get the result ofmap_index
: If the task is mapped, the index you would like to access. By default, if given a mapped task, all of the child results will be loaded.poll_time
: The amount of time to wait while polling to check if the sub-flow has finished
methods: |
---|
prefect.tasks.prefect.flow_run.get_task_run_result (flow_run_id, task_slug, map_index=-1, poll_time=5)[source] |
Task to get the result of a task from a flow run.
|
# wait_for_flow_run
prefect.tasks.prefect.flow_run.wait_for_flow_run
(flow_run_id, stream_states=True, stream_logs=False, raise_final_state=False, max_duration=datetime.timedelta(seconds=43200))[source]Task to wait for a flow run to finish executing, streaming state and log information
Args:
flow_run_id
: The flow run id to wait forstream_states
: Stream information about the flow run state changesstream_logs
: Stream flow run logs; ifstream_state
isFalse
this will be ignoredraise_final_state
: If set, the state of this task will be set to the final state of the child flow run on completion.max_duration
: Duration to wait for flow run to complete. Defaults to 12 hours.
methods: |
---|
prefect.tasks.prefect.flow_run.wait_for_flow_run (flow_run_id, stream_states=True, stream_logs=False, raise_final_state=False, max_duration=datetime.timedelta(seconds=43200))[source] |
Task to wait for a flow run to finish executing, streaming state and log information
|
This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC