unilab.envs.mdp.recorders.LifecycleCounterRecorder

class unilab.envs.mdp.recorders.LifecycleCounterRecorder[source]

Bases: RecorderTerm

Count recorder lifecycle calls without performing I/O.

Parameters:
  • cfg (RecorderTermCfg)

  • env (ManagerBasedRlEnv)

Methods

__init__(cfg, env)

close()

Called when the environment closes.

record_post_reset(env_ids)

Called after a reset completes with fresh observations computed.

record_post_step()

Called at the end of every env.step() with fresh observations.

record_pre_reset(env_ids)

Called in env.step() before terminated environments are reset.

reset(env_ids)

Resets the manager term.

Attributes

__init__(cfg, env)[source]
Parameters:
  • cfg (RecorderTermCfg)

  • env (ManagerBasedRlEnv)

record_pre_reset(env_ids)[source]

Called in env.step() before terminated environments are reset.

What is available:

  • obs_buf contains the observation from the end of the previous step (the input the agent used to choose the terminal action). It does not contain the post-action terminal observation (the state reached after applying the action), which is never computed for resetting environments.

  • action_manager.action contains the action applied during this step. This is the correct terminal action. It will be zeroed for these environments by _reset_idx immediately after this hook returns, so capture it here if you need it later.

  • reward_buf contains the reward for this terminal step.

  • reset_terminated and reset_time_outs reflect why each environment is resetting.

This is the right hook to record the terminal transition (obs_t, action_t, reward_t, done=True) for each resetting environment.

Parameters:

env_ids (ndarray) – Indices of environments that are about to be reset.

Return type:

None

record_post_reset(env_ids)[source]

Called after a reset completes with fresh observations computed.

Fires at the end of env.reset() (covering all environments on the initial call) and within env.step() for each batch of environments that terminates, after state has been overwritten and new observations computed.

At this point obs_buf[env_ids] holds the initial observation of the new episode and action_manager.action[env_ids] is zero (no action has been taken in the new episode yet).

Use this hook to initialize per-episode state or record the first observation of a new episode.

Parameters:

env_ids (ndarray) – Indices of environments that were reset.

Return type:

None

record_post_step()[source]

Called at the end of every env.step() with fresh observations.

At this point obs_buf holds the new observation for every environment and action_manager.action holds the action that was applied during this step. Exception: for environments that reset during this step, action_manager.action has been zeroed by _reset_idx and obs_buf holds the initial observation of the new episode rather than the post-action terminal observation. Use record_pre_reset to capture the terminal (obs, action) pair for those environments. Resetting environments are identified by self._env.reset_buf.

Return type:

None

__call__()

Returns the value of the term required by the manager.

close()

Called when the environment closes.

Release file handles, flush write buffers, or finalize output here.

Return type:

None

property name: str
property num_envs: int
reset(env_ids)

Resets the manager term.

Parameters:

env_ids (ndarray | slice | None)

Return type:

Any