# ManagedDriveFile

## class nominal.experimental.drives.ManagedDriveFile(path, size_bytes, state, download_availability, observed_at, rid, created_at, created_by_rid, current_revision_rid)

Bases: [`DriveFile`](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFile.md#nominal.experimental.drives.DriveFile "nominal.experimental.drives.file.DriveFile"), `HasRid`, `RefreshableMixin`[`LogicalFile`]

A file stored in a Nominal-backed drive, with a stable RID and a revision history.

### path

Drive-relative path, with no leading or trailing slash.

### size_bytes

### state

### download_availability

Whether the observed content can be downloaded.

### observed_at

When the backend last observed this file.

### rid: str

### created_at: IntegralNanosecondsUTC | None

### created_by_rid: str | None

### current_revision_rid: str | None

RID of the revision currently at this path, if the file has one.

### download(output_directory, *, part_size=DEFAULT_CHUNK_SIZE, num_retries=3)

Download this file’s current content into a directory.

The download uses this snapshot’s revision reference. Nominal resolves virtual
references and may fetch their content from the provider as it streams.

Parameters:
:   - **output_directory** ([*Path*](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)") *|* [*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)"))

      Directory to write into. The file is named after its path in
      the drive.
    - **part_size** ([*int*](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))

      Size in bytes of each ranged download request.
    - **num_retries** ([*int*](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)"))

      Retries per part.

Returns:
:   Path the file was written to.

Raises:
:   - [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – The file’s name would not stay inside `output_directory`, for
      example because it contains a backslash.
    - [**NotADirectoryError**](https://docs.python.org/3/builtins/exceptions.html#NotADirectoryError "(in Python v3.15)") – `output_directory` exists but is not a directory.
    - [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError "(in Python v3.15)") – `output_directory` does not exist.
    - [**FileExistsError**](https://docs.python.org/3/builtins/exceptions.html#FileExistsError "(in Python v3.15)") – A file already exists at the destination.
    - [**NominalFileStoreError**](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.NominalFileStoreError.md#nominal.experimental.drives.NominalFileStoreError "nominal.experimental.drives.NominalFileStoreError") – This managed file has no current revision.
    - [**NominalNotFoundError**](https://dev.nominal.io/python/ref/generated/nominal.exceptions.NominalNotFoundError.md#nominal.exceptions.NominalNotFoundError "nominal.exceptions.NominalNotFoundError") – This file’s bytes are no longer retained.
    - **requests.HTTPError** – A virtual file’s provider can no longer serve the observed
      content, or can’t be reached.

Return type:
:   [*Path*](https://docs.python.org/3/library/pathlib.html#pathlib.Path "(in Python v3.15)")

### move_to(destination)

Move this file, refreshing it in place.

Parameters:
:   **destination** ([*str*](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)") *|* [*ManagedDriveFile*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.ManagedDriveFile.md#nominal.experimental.drives.ManagedDriveFile "nominal.experimental.drives.file.ManagedDriveFile") *|* [*DriveFileRevision*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFileRevision.md#nominal.experimental.drives.DriveFileRevision "nominal.experimental.drives.file.DriveFileRevision"))

    Where to move the file. A path must be unoccupied; pass a file or
    revision to replace what is already there.

Returns:
:   This instance, updated.

Raises:
:   - [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – `destination` is a file or revision from a different drive.
    - [**NominalFileStoreError**](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.NominalFileStoreError.md#nominal.experimental.drives.NominalFileStoreError "nominal.experimental.drives.NominalFileStoreError") – The move was rejected — for example the path is occupied,
      or this file’s revision is no longer current.

Return type:
:   [*Self*](https://docs.python.org/3/library/typing.html#typing.Self "(in Python v3.15)")

> **Note**
>
> File changes are not automatically replayed after transport errors, which can leave
> the outcome unknown. See [Recover after a transport error](https://dev.nominal.io/python/guides/drives/overview.md#drive-change-retries) before retrying.

### refresh()

Return type:
:   [*Self*](https://docs.python.org/3/library/typing.html#typing.Self "(in Python v3.15)")

### remove()

Remove this file, refreshing it in place.

Removal is soft: the file’s revisions remain, and any of them can be restored.

Returns:
:   This instance, updated.

Raises:
:   [**NominalFileStoreError**](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.NominalFileStoreError.md#nominal.experimental.drives.NominalFileStoreError "nominal.experimental.drives.NominalFileStoreError") – The removal was rejected — for example this file’s revision
    is no longer current.

Return type:
:   [*Self*](https://docs.python.org/3/library/typing.html#typing.Self "(in Python v3.15)")

> **Note**
>
> File changes are not automatically replayed after transport errors, which can leave
> the outcome unknown. See [Recover after a transport error](https://dev.nominal.io/python/guides/drives/overview.md#drive-change-retries) before retrying.

### revisions()

List this file’s revision history, in the order the backend returns it.

Returns:
:   Every revision of this file, including removal markers.

Return type:
:   [*Sequence*](https://docs.python.org/3/library/typing.html#typing.Sequence "(in Python v3.15)")[[*DriveFileRevision*](https://dev.nominal.io/python/ref/generated/nominal.experimental.drives.DriveFileRevision.md#nominal.experimental.drives.DriveFileRevision "nominal.experimental.drives.file.DriveFileRevision")]
