Skip to content

Commit 7ed6411

Browse files
committed
Make sure the first snapshot time is always logged.
1 parent bbf2f4c commit 7ed6411

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

flybody/agents/learning_dmpo.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ def step(self):
335335

336336
if self._snapshotter is not None:
337337
if self._snapshotter.save():
338-
# Log at what actor_steps this snapshot was saved.
339-
if 'actor_steps' in fetches:
340-
fetches['saved_snapshot_at_actor_steps'] = fetches['actor_steps']
338+
# Log at what actor_steps this snapshot was saved. The actor_steps
339+
# counter is updated at end of episode so fetches['actor_steps']
340+
# may not exist yet when the first policy snapshot is saved.
341+
actor_steps = fetches['actor_steps'] if 'actor_steps' in fetches else 0
342+
fetches['saved_snapshot_at_actor_steps'] = actor_steps
341343
# Increment the snapshot counter (directly in the snapshotter's path).
342344
for path in list(self._snapshotter._snapshots.keys()):
343345
snapshot = self._snapshotter._snapshots[path] # noqa: F841

0 commit comments

Comments
 (0)