orbit.actions.ExportFileManager
Stay organized with collections
Save and categorize content based on your preferences.
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.
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.
|
Attributes |
managed_files
|
Returns all files managed by this instance, in sorted order.
|
Methods
clean_up
View source
clean_up()
Cleans up old files matching {base_name}-*
.
The most recent max_to_keep
files are preserved.
next_name
View source
next_name() -> str
Returns a new file name based on base_name
and next_id_fn()
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2025-04-18 UTC.
[null,null,["Last updated 2025-04-18 UTC."],[],[],null,["# orbit.actions.ExportFileManager\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/export_saved_model.py#L61-L135) |\n\nUtility class that manages a group of files with a shared base name. \n\n orbit.actions.ExportFileManager(\n base_name: str,\n max_to_keep: int = 5,\n next_id_fn: Optional[Callable[[], int]] = None,\n subdirectory: Optional[str] = None\n )\n\nFor actions like SavedModel exporting, there are potentially many different\nfile naming and cleanup strategies that may be desirable. This class provides\na basic interface allowing SavedModel export to be decoupled from these\ndetails, and a default implementation that should work for many basic\nscenarios. Users may subclass this class to alter behavior and define more\ncustomized naming and cleanup strategies.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `base_name` | A shared base name for file names generated by this class. |\n| `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 \\\u003c 0, all files are preserved. |\n| `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`. |\n| `subdirectory` | An optional subdirectory to concat after the {base_name}-{id}. Then the file manager will manage {base_name}-{id}/{subdirectory} files. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------|--------------------------------------------------------------|\n| `managed_files` | Returns all files managed by this instance, in sorted order. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `clean_up`\n\n[View source](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/export_saved_model.py#L119-L130) \n\n clean_up()\n\nCleans up old files matching `{base_name}-*`.\n\nThe most recent `max_to_keep` files are preserved.\n\n### `next_name`\n\n[View source](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/export_saved_model.py#L132-L135) \n\n next_name() -\u003e str\n\nReturns a new file name based on `base_name` and `next_id_fn()`."]]