Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.prefect.io/llms.txt

Use this file to discover all available pages before exploring further.

prefect.bundles

Functions

create_bundle_for_flow_run

create_bundle_for_flow_run(flow: Flow[Any, Any], flow_run: FlowRun, context: dict[str, Any] | None = None) -> BundleCreationResult
Creates a bundle for a flow run. Args:
  • flow: The flow to bundle.
  • flow_run: The flow run to bundle.
  • context: The context to use when running the flow.
Returns:
  • A BundleCreationResult containing:
    • bundle: The serialized bundle
    • zip_path: Path to sidecar zip file if include_files was specified, None otherwise. Caller is responsible for uploading this file and calling cleanup.

extract_flow_from_bundle

extract_flow_from_bundle(bundle: SerializedBundle) -> Flow[Any, Any]
Extracts a flow from a bundle.

execute_bundle_in_subprocess

execute_bundle_in_subprocess(bundle: SerializedBundle, env: dict[str, str | None] | None = None, cwd: Path | str | None = None) -> multiprocessing.context.SpawnProcess
Executes a bundle in a subprocess. Args:
  • bundle: The bundle to execute.
Returns:
  • A multiprocessing.context.SpawnProcess.

convert_step_to_command

convert_step_to_command(step: dict[str, Any], key: str, quiet: bool = False) -> list[str]
Converts a bundle upload or execution step to a command. Args:
  • step: The step to convert.
  • key: The key to use for the remote file when downloading or uploading.
  • quiet: Whether to suppress uv output from the command.
Returns:
  • A list of strings representing the command to run the step.

upload_bundle_to_storage

upload_bundle_to_storage(bundle: SerializedBundle, key: str, upload_command: list[str], zip_path: Path | None = None, upload_step: dict[str, Any] | None = None) -> None
Uploads a bundle to storage. Args:
  • bundle: The serialized bundle to upload.
  • key: The key to use for the remote file when uploading.
  • upload_command: The command to use to upload the bundle as a list of strings.
  • zip_path: Optional path to sidecar zip file. If provided, uploads alongside the bundle using the bundle’s files_key as the storage key.
  • upload_step: The upload step dict used to build the upload command. Required when uploading a sidecar zip so a separate command with the correct key can be constructed.

aupload_bundle_to_storage

aupload_bundle_to_storage(bundle: SerializedBundle, key: str, upload_command: list[str], zip_path: Path | None = None, upload_step: dict[str, Any] | None = None) -> None
Asynchronously uploads a bundle to storage. Args:
  • bundle: The serialized bundle to upload.
  • key: The key to use for the remote file when uploading.
  • upload_command: The command to use to upload the bundle as a list of strings.
  • zip_path: Optional path to sidecar zip file. If provided, uploads alongside the bundle using the bundle’s files_key as the storage key.
  • upload_step: The upload step dict used to build the upload command. Required when uploading a sidecar zip so a separate command with the correct key can be constructed.

Classes

BundleLauncherOverride

SerializedBundle

A serialized bundle is a serialized function, context, and flow run that can be easily transported for later execution. Attributes:
  • function: Serialized (base64-encoded, gzip-compressed, cloudpickled) flow function.
  • context: Serialized context for flow execution.
  • flow_run: Flow run metadata as a dict.
  • dependencies: Newline-separated list of pip dependencies.
  • files_key: Optional storage key for sidecar zip containing included files. Format: “files/.zip”. None when no files are included.

BundleCreationResult

Result of creating a bundle, including optional sidecar zip info. Attributes:
  • bundle: The serialized bundle.
  • zip_path: Path to sidecar zip file if include_files was specified. None when no files are included. Caller is responsible for uploading this file and calling cleanup.