# orbit.actions.ExportFileManager

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/models/blob/v2.20.0/orbit/actions/export_saved_model.py#L61-L135) |

Utility class that manages a group of files with a shared base name.

    orbit.actions.ExportFileManager(
        base_name: str,
        max_to_keep: int = 5,
        next_id_fn: Optional[Callable[[], int]] = None,
        subdirectory: Optional[str] = None
    )

For actions like SavedModel exporting, there are potentially many different
file naming and cleanup strategies that may be desirable. This class provides
a basic interface allowing SavedModel export to be decoupled from these
details, and a default implementation that should work for many basic
scenarios. Users may subclass this class to alter behavior and define more
customized naming and cleanup strategies.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `base_name` | A shared base name for file names generated by this class. |
| `max_to_keep` | The maximum number of files matching `base_name` to keep after each call to `cleanup`. The most recent (as determined by file modification time) `max_to_keep` files are preserved; the rest are deleted. If \< 0, all files are preserved. |
| `next_id_fn` | An optional callable that returns integer IDs to append to base name (formatted as `'{base_name}-{id}'`). The order of integers is used to sort files to determine the oldest ones deleted by `clean_up`. If not supplied, a default ID based on an incrementing counter is used. One common alternative maybe be to use the current global step count, for instance passing `next_id_fn=global_step.numpy`. |
| `subdirectory` | An optional subdirectory to concat after the {base_name}-{id}. Then the file manager will manage {base_name}-{id}/{subdirectory} files. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `managed_files` | Returns all files managed by this instance, in sorted order. |

<br />

## Methods

### `clean_up`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/actions/export_saved_model.py#L119-L130)

    clean_up()

Cleans up old files matching `{base_name}-*`.

The most recent `max_to_keep` files are preserved.

### `next_name`

[View source](https://github.com/tensorflow/models/blob/v2.20.0/orbit/actions/export_saved_model.py#L132-L135)

    next_name() -> str

Returns a new file name based on `base_name` and `next_id_fn()`.