Loggers

Tracker

class causal_world.loggers.Tracker(task=None, file_path=None, world_params=None)[source]
__init__(task=None, file_path=None, world_params=None)[source]
Parameters
  • task – (causal_world.BaseTask) task to be tracked

  • file_path – (str) path of the tracker to be loaded.

  • world_params – (dict) causal world parameters.

add_episode_experience(time_steps)[source]
Parameters

time_steps – (int) time steps executed in the last episode.

Returns

add_invalid_intervention(interventions_info)[source]
Parameters

interventions_info – (dict) a dictionary about the interventions stats about the infeasibility of interventions.

Returns

do_intervention(task, interventions_dict)[source]
Parameters
  • task – (causal_world.BaseTask) the task after the intervention.

  • interventions_dict – (dict) the intervention that was just executed in the environment.

Returns

get_total_intervention_steps()[source]
Returns

(int) total interventions performed so far on a variable level.

get_total_interventions()[source]
Returns

(int) total interventions performed so far.

get_total_invalid_intervention_steps()[source]
Returns

(int) total invalid interventions performed so far.

get_total_invalid_out_of_bounds_intervention_steps()[source]
Returns

(int) total interventions performed so far where the the values where out of bounds and thus invalidates it.

get_total_invalid_robot_intervention_steps()[source]
Returns

(int) total invalid interventions performed so far where the robot reached an infeasible state.

get_total_invalid_stage_intervention_steps()[source]
Returns

(int) total invalid interventions performed so far where the stage reached an infeasible state.

get_total_invalid_task_generator_intervention_steps()[source]
Returns

(int) total invalid interventions performed so far where the task itself reached an infeasible state.

get_total_resets()[source]
Returns

(int) total resets performed so far.

get_total_time_steps()[source]
Returns

(int) total time steps since the beginning of the initialization of the environment.

load(file_path)[source]
Parameters

file_path – (str) file path to load the tracker.

Returns

save(file_path)[source]
Parameters

file_path – (str) file path to save the tracker in.

Returns

switch_task(task)[source]
Parameters

task – (causal_world.BaseTask) the task to switch to.

Returns

DataRecorder

class causal_world.loggers.DataRecorder(output_directory=None, rec_dumb_frequency=100)[source]
__init__(output_directory=None, rec_dumb_frequency=100)[source]

This class logs the full histories of a world across multiple episodes

Parameters
  • output_directory – (str) specifies the output directory to save the episodes in.

  • rec_dumb_frequency – (int) specifies the peridicity of saving the episodes.

append(robot_action, observation, reward, info, done, timestamp)[source]
Parameters
  • robot_action – (nd.array) action passed to step function.

  • observation – (nd.array) observations returned after stepping through the environment.

  • reward – (float) reward received from the environment.

  • info – (dict) dictionary specifying all the extra information after stepping through the environment.

  • done – (bool) true if the environment returns done.

  • timestamp – (float) time stamp with respect to the beginning of the episode.

Returns

clear_recorder()[source]

Clears the data recorder.

Returns

get_current_episode()[source]
Returns

(causal_world.loggers.Episode) current episode saved.

get_number_of_logged_episodes()[source]
Returns

(int) number of logged episodes.

new_episode(initial_full_state, task_name, task_params=None, world_params=None)[source]
Parameters
  • initial_full_state – (dict) dict specifying the full state variables of the environment.

  • task_name – (str) task generator name.

  • task_params – (dict) task generator parameters.

  • world_params – (dict) causal world parameters.

Returns

save()[source]

dumps the current episodes.

Returns

Episode

class causal_world.loggers.Episode(task_name, initial_full_state, task_params=None, world_params=None)[source]
__init__(task_name, initial_full_state, task_params=None, world_params=None)[source]

The structure in which the data from each episode will be logged.

Parameters
  • task_name – (str) task generator name

  • initial_full_state – (dict) dict specifying the full state variables of the environment.

  • task_params – (dict) task generator parameters.

  • world_params – (dict) causal world parameters.

append(robot_action, observation, reward, info, done, timestamp)[source]
Parameters
  • robot_action – (nd.array) action passed to step function.

  • observation – (nd.array) observations returned after stepping through the environment.

  • reward – (float) reward received from the environment.

  • info – (dict) dictionary specifying all the extra information after stepping through the environment.

  • done – (bool) true if the environment returns done.

  • timestamp – (float) time stamp with respect to the beginning of the episode.

Returns

DataLoader

class causal_world.loggers.DataLoader(episode_directory)[source]
__init__(episode_directory)[source]

This initializes a data loader that loads recorded episodes using a causal_world.loggers.DataRecorder object.

Parameters

episode_directory – (str) directory where it holds all the logged episodes.

get_episode(index)[source]
Parameters

index – (int) index of the episode requested.

Returns

(causal_world.loggers.Episode) corresponding episode requested.

get_episodes(indices)[source]
Parameters

indices – (list) list of indicies of the episodes.

Returns

(list) list of causal_world.loggers.Episode objects corresponding to the specified episode indicies.