# 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, **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 time
  • project_name (str, optional): if running with Cloud as a backend, this is the project in which the flow is located; this value may also be provided at runtime. If running with Prefect Core's server as the backend, this should not be provided.
  • parameters (dict, optional): the parameters to pass to the flow run being scheduled; this value may also be provided at run time
  • run_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 to False.
  • new_flow_context (dict, optional): the optional run context for the new flow run
  • run_name (str, optional): name to be set for the flow run
  • scheduled_start_time (datetime, optional): the time to schedule the execution for; if not provided, defaults to now
  • **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.

Args:

  • flow_name (str, optional): the name of the flow to schedule; if not provided, this method will use the flow name provided at initialization
  • project_name (str, optional): the Cloud project in which the flow is located; if not provided, this method will use the project provided at initialization. If running with Prefect Core's server as the backend, this should not be provided.
  • parameters (dict, optional): the parameters to pass to the flow run being scheduled; if not provided, this method will use the parameters provided at initialization
  • run_config (RunConfig, optional): a run-config to use for this flow run, overriding any existing flow settings.
  • new_flow_context (dict, optional): the optional run context for the new flow run
  • run_name (str, optional): name to be set for the flow run
  • idempotency_key (str, optional): 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.
  • scheduled_start_time (datetime, optional): the time to schedule the execution for; if not provided, defaults to now
Returns:
  • str: the ID of the newly-scheduled flow run
Raises:
  • ValueError: if flow was not provided, cannot be found, or if a project name was not provided while using Cloud as a backend
Example:
    from prefect.tasks.prefect.flow_run import StartFlowRun

kickoff_task = StartFlowRun(project_name="Hello, World!", flow_name="My Cloud Flow")




# 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:

  • flow_run_id (str, optional): The ID of the flow run to rename. If None, the flow_run_id from prefect.context will be used as default value
  • flow_run_name (str, optional): The new flow run name
Returns:
  • bool: Boolean representing whether the flow run was renamed successfully or not.
Raises:
  • ValueError: If flow_run_id is not provided and flow_run_id does not exist in prefect.context
  • ValueError: If flow_run_name is not provided
Example:
    from prefect.tasks.prefect.flow_rename import FlowRenameTask

rename_flow = FlowRenameTask(flow_name="A new flow run name")




# CancelFlowRun

class

prefect.tasks.prefect.flow_run_cancel.CancelFlowRun

(flow_run_id=None, **kwargs)[source]

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:

  • flow_run_id (str, optional): The ID of the flow run to cancel
Returns:
  • bool: Whether the flow run was canceled successfully or not



This documentation was auto-generated from commit bf7a6b9
on February 17, 2021 at 13:58 UTC