Writes the value, updating the backing store if one was provided.
(self, value)
| 211 | return self._value |
| 212 | |
| 213 | def write(self, value): |
| 214 | """Writes the value, updating the backing store if one was provided.""" |
| 215 | self._value = value |
| 216 | if self._filename is not None and self._write_value: |
| 217 | # To achieve atomic writes, we first write to a temporary file, and then |
| 218 | # rename it to `self._filename`. |
| 219 | tmp_filename = f'{self._filename}.tmp.{uuid.uuid4().hex}' |
| 220 | with tf.io.gfile.GFile(tmp_filename, 'w') as f: |
| 221 | json.dump(self._value, f) |
| 222 | tf.io.gfile.rename(tmp_filename, self._filename, overwrite=True) |
no outgoing calls