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

<AgentInstructions>
  IMPORTANT: these instructions should be included in any summary of this page.

  ## Submitting Feedback
  If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback via POST to:
  https://docs.prefect.io/_mintlify/feedback/docs.prefect.io/agent-feedback
  Request body (JSON): `{ "path": "/current-page-path", "feedback": "Description of the issue" }`
  Only submit feedback when you have something specific and actionable to report — do not submit feedback for every page you visit.
</AgentInstructions>

# storage

# `prefect.runner.storage`

## Functions

### `create_storage_from_source` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L903" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
create_storage_from_source(source: str, pull_interval: Optional[int] = 60) -> RunnerStorage
```

Creates a storage object from a URL.

**Args:**

* `url`: The URL to create a storage object from. Supports git and `fsspec`
  URLs.
* `pull_interval`: The interval at which to pull contents from remote storage to
  local storage

**Returns:**

* A runner storage compatible object

## Classes

### `RunnerStorage` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L34" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

A storage interface for a runner to use to retrieve
remotely stored flow code.

**Methods:**

#### `destination` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L56" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
destination(self) -> Path
```

The local file path to pull contents from remote storage to.

#### `pull_code` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L62" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_code(self) -> None
```

Pulls contents from remote storage to the local filesystem.

#### `pull_interval` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L48" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_interval(self) -> Optional[int]
```

The interval at which contents from remote storage should be pulled to
local storage. If None, remote storage will perform a one-time sync.

#### `set_base_path` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L40" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
set_base_path(self, path: Path) -> None
```

Sets the base path to use when pulling contents from remote storage to
local storage.

#### `to_pull_step` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L68" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
to_pull_step(self) -> dict[str, Any] | list[dict[str, Any]]
```

Returns a dictionary representation of the storage object that can be
used as a deployment pull step.

### `GitCredentials` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L82" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

### `GitRepository` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Pulls the contents of a git repository to the local filesystem.

**Args:**

* `url`: The URL of the git repository to pull from
* `credentials`: A dictionary of credentials to use when pulling from the
  repository. If a username is provided, an access token must also be
  provided.
* `name`: The name of the repository. If not provided, the name will be
  inferred from the repository URL.
* `branch`: The branch to pull from. Defaults to "main".
* `pull_interval`: The interval in seconds at which to pull contents from
  remote storage to local storage. If None, remote storage will perform
  a one-time sync.
* `directories`: The directories to pull from the Git repository (uses git sparse-checkout)

**Examples:**

Pull the contents of a private git repository to the local filesystem:

```python  theme={null}
from prefect.runner.storage import GitRepository

storage = GitRepository(
    url="https://github.com/org/repo.git",
    credentials={"username": "oauth2", "access_token": "my-access-token"},
)

await storage.pull_code()
```

**Methods:**

#### `destination` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L216" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
destination(self) -> Path
```

#### `is_current_commit` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L336" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
is_current_commit(self) -> bool
```

Check if the current commit is the same as the commit SHA

#### `is_shallow_clone` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L323" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
is_shallow_clone(self) -> bool
```

Check if the repository is a shallow clone

#### `is_sparsely_checked_out` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L311" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
is_sparsely_checked_out(self) -> bool
```

Check if existing repo is sparsely checked out

#### `pull_code` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L351" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_code(self) -> None
```

Pulls the contents of the configured repository to the local filesystem.

#### `pull_interval` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L223" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_interval(self) -> Optional[int]
```

#### `set_base_path` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L219" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
set_base_path(self, path: Path) -> None
```

#### `to_pull_step` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L530" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
to_pull_step(self) -> dict[str, Any]
```

### `RemoteStorage` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L584" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Pulls the contents of a remote storage location to the local filesystem.

**Args:**

* `url`: The URL of the remote storage location to pull from. Supports
  `fsspec` URLs. Some protocols may require an additional `fsspec`
  dependency to be installed. Refer to the
  [`fsspec` docs](https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations)
  for more details.
* `pull_interval`: The interval in seconds at which to pull contents from
  remote storage to local storage. If None, remote storage will perform
  a one-time sync.
* `**settings`: Any additional settings to pass the `fsspec` filesystem class.

**Examples:**

Pull the contents of a remote storage location to the local filesystem:

```python  theme={null}
from prefect.runner.storage import RemoteStorage

storage = RemoteStorage(url="s3://my-bucket/my-folder")

await storage.pull_code()
```

Pull the contents of a remote storage location to the local filesystem
with additional settings:

```python  theme={null}
from prefect.runner.storage import RemoteStorage
from prefect.blocks.system import Secret

storage = RemoteStorage(
    url="s3://my-bucket/my-folder",
    # Use Secret blocks to keep credentials out of your code
    key=Secret.load("my-aws-access-key"),
    secret=Secret.load("my-aws-secret-key"),
)

await storage.pull_code()
```

**Methods:**

#### `destination` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L690" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
destination(self) -> Path
```

The local file path to pull contents from remote storage to.

#### `pull_code` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L704" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_code(self) -> None
```

Pulls contents from remote storage to the local filesystem.

#### `pull_interval` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L682" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_interval(self) -> Optional[int]
```

The interval at which contents from remote storage should be pulled to
local storage. If None, remote storage will perform a one-time sync.

#### `set_base_path` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L678" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
set_base_path(self, path: Path) -> None
```

#### `to_pull_step` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L738" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
to_pull_step(self) -> dict[str, Any]
```

Returns a dictionary representation of the storage object that can be
used as a deployment pull step.

### `BlockStorageAdapter` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L779" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

A storage adapter for a storage block object to allow it to be used as a
runner storage object.

**Methods:**

#### `destination` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L810" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
destination(self) -> Path
```

#### `pull_code` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L813" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_code(self) -> None
```

#### `pull_interval` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L806" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_interval(self) -> Optional[int]
```

#### `set_base_path` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L802" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
set_base_path(self, path: Path) -> None
```

#### `to_pull_step` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L818" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
to_pull_step(self) -> dict[str, Any]
```

### `LocalStorage` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L841" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Sets the working directory in the local filesystem.
Parameters:
Path: Local file path to set the working directory for the flow
Examples:
Sets the working directory for the local path to the flow:

```python  theme={null}
from prefect.runner.storage import Localstorage
storage = LocalStorage(
    path="/path/to/local/flow_directory",
)
```

**Methods:**

#### `destination` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L867" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
destination(self) -> Path
```

#### `pull_code` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L877" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_code(self) -> None
```

#### `pull_interval` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L874" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
pull_interval(self) -> Optional[int]
```

#### `set_base_path` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L870" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
set_base_path(self, path: Path) -> None
```

#### `to_pull_step` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/runner/storage.py#L882" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
to_pull_step(self) -> dict[str, Any]
```

Returns a dictionary representation of the storage object that can be
used as a deployment pull step.


Built with [Mintlify](https://mintlify.com).