# Local Agent


# LocalAgent

class

prefect.agent.local.agent.LocalAgent

(agent_config_id=None, name=None, labels=None, env_vars=None, import_paths=None, show_flow_logs=False, hostname_label=True, max_polls=None, agent_address=None, no_cloud_logs=None)[source]

Agent which deploys flow runs locally as subprocesses. There are a range of kwarg options to control information which may be provided to these subprocesses.

Optional import paths may be specified to append dependency modules to the PATH:

prefect agent local start --import-path "/usr/local/my_module" --import-path "~/other_module"

# Now the local scripts/packages my_module and other_module will be importable in
# the flow's subprocess

Environment variables may be set on the agent to be provided to each flow run's subprocess:

prefect agent local start --env MY_SECRET_KEY=secret --env OTHER_VAR=$OTHER_VAR

Args:

  • agent_config_id (str, optional): An optional agent configuration ID that can be used to set configuration based on an agent from a backend API. If set all configuration values will be pulled from backend agent configuration.
  • name (str, optional): An optional name to give this agent. Can also be set through the environment variable PREFECT__CLOUD__AGENT__NAME. Defaults to "agent"
  • labels (List[str], optional): a list of labels, which are arbitrary string identifiers used by Prefect Agents when polling for work
  • env_vars (dict, optional): a dictionary of environment variables and values that will be set on each flow run that this agent submits for execution
  • max_polls (int, optional): maximum number of times the agent will poll Prefect Cloud for flow runs; defaults to infinite
  • agent_address (str, optional): Address to serve internal api at. Currently this is just health checks for use by an orchestration layer. Leave blank for no api server (default).
  • no_cloud_logs (bool, optional): Disable logging to a Prefect backend for this agent and all deployed flow runs
  • import_paths (List[str], optional): system paths which will be provided to each Flow's runtime environment; useful for Flows which import from locally hosted scripts or packages
  • show_flow_logs (bool, optional): a boolean specifying whether the agent should re-route Flow run logs to stdout; defaults to False
  • hostname_label (boolean, optional): a boolean specifying whether this agent should auto-label itself with the hostname of the machine it is running on. Useful for flows which are stored on the local filesystem.

methods:                                                                                                                                                       

prefect.agent.agent.Agent.start

()[source]

The main entrypoint to the agent process. Sets up the agent then continuously polls for work to submit.

This is the only method that should need to be called externally.



This documentation was auto-generated from commit bd9182e
on July 31, 2024 at 18:02 UTC