def test_write_load(self): conf = record.Record() conf.x = 1 with tempfile.NamedTemporaryFile() as f: conf.write_to_file(f.name) logging.info('Writing record: %r', conf) new = record.load_from_file(f.name) logging.info('Loaded record: %r', new) self.assertEqual(1, new.x)
def _read_task_run_trace(self, task_run_id): """Looks for an existing trace for a given task run. Args: task_run_id: ID of the task run to search for. Returns: The task output record persisted for the specified task run, or None if no trace is found for the specified task run. """ if self._ignore_saved_output_trace: return None trace_file_path = self._get_trace_file_path(task_run_id) if os.path.exists(trace_file_path): return record.load_from_file(trace_file_path) else: return None