orbit.actions.JSONPersistedValue
Stay organized with collections
Save and categorize content based on your preferences.
Represents a value that is persisted via a file-based backing store.
orbit.actions.JSONPersistedValue(
initial_value: Any, filename: str, write_value: bool = True
)
The value must be JSON-serializable. Each time the value is updated, it will
be written to the backing file. It is only read from the file at
initialization.
Args |
initial_value
|
The initial value to use if no backing file exists or was
given. This must be a JSON-serializable value (possibly nested
combination of lists, dicts, and primitive values).
|
filename
|
The path to use for persistent storage of the value. This may be
None , in which case the value is not stable across preemptions.
|
write_value
|
If True , new values will be written to filename on calls
to write() . If False , filename is only read once to restore any
persisted value, and new values will not be written to it. This can be
useful in certain multi-client settings to avoid race conditions or
excessive file writes. If filename is None , this parameter has no
effect.
|
Methods
read
View source
read()
Returns the value.
write
View source
write(
value
)
Writes the value, updating the backing store if one was provided.
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.JSONPersistedValue\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/new_best_metric.py#L167-L222) |\n\nRepresents a value that is persisted via a file-based backing store. \n\n orbit.actions.JSONPersistedValue(\n initial_value: Any, filename: str, write_value: bool = True\n )\n\nThe value must be JSON-serializable. Each time the value is updated, it will\nbe written to the backing file. It is only read from the file at\ninitialization.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `initial_value` | The initial value to use if no backing file exists or was given. This must be a JSON-serializable value (possibly nested combination of lists, dicts, and primitive values). |\n| `filename` | The path to use for persistent storage of the value. This may be `None`, in which case the value is not stable across preemptions. |\n| `write_value` | If `True`, new values will be written to `filename` on calls to `write()`. If `False`, `filename` is only read once to restore any persisted value, and new values will not be written to it. This can be useful in certain multi-client settings to avoid race conditions or excessive file writes. If `filename` is `None`, this parameter has no effect. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `read`\n\n[View source](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/new_best_metric.py#L209-L211) \n\n read()\n\nReturns the value.\n\n### `write`\n\n[View source](https://github.com/tensorflow/models/blob/v2.19.1/orbit/actions/new_best_metric.py#L213-L222) \n\n write(\n value\n )\n\nWrites the value, updating the backing store if one was provided."]]