syllabus.tests package#

Submodules#

syllabus.tests.sync_test_curriculum module#

class syllabus.tests.sync_test_curriculum.SyncTestCurriculum(num_envs, num_episodes, *curriculum_args, **curriculum_kwargs)#

Bases: SequentialCurriculum

Base class and API for defining curricula to interface with Gym environments.

REQUIRES_CENTRAL_UPDATES = False#
REQUIRES_STEP_UPDATES = True#
get_stats()#
sample(k: int = 1) List | Any#

Choose the next k tasks from the list.

update_on_step(obs, rew, term, trunc, info) None#

Update the curriculum with the current step results from the environment.

update_task_progress(task: Any, progress: float) None#

Update the curriculum with a task and its success probability upon success or failure.

syllabus.tests.sync_test_env module#

class syllabus.tests.sync_test_env.SyncTestEnv(num_episodes, num_steps=100)#

Bases: TaskEnv

reset(new_task=None)#

Resets the environment to an initial internal state, returning an initial observation and info.

This method generates a new starting state often with some randomness to ensure that the agent explores the state space and learns a generalised policy about the environment. This randomness can be controlled with the seed parameter otherwise if the environment already has a random number generator and reset() is called with seed=None, the RNG is not reset.

Therefore, reset() should (in the typical use case) be called with a seed right after initialization and then never again.

For Custom environments, the first line of reset() should be super().reset(seed=seed) which implements the seeding correctly.

Changed in version v0.25: The return_info parameter was removed and now info is expected to be returned.

Parameters:
  • seed (optional int) – The seed that is used to initialize the environment’s PRNG (np_random). If the environment does not already have a PRNG and seed=None (the default option) is passed, a seed will be chosen from some source of entropy (e.g. timestamp or /dev/urandom). However, if the environment already has a PRNG and seed=None is passed, the PRNG will not be reset. If you pass an integer, the PRNG will be reset even if it already exists. Usually, you want to pass an integer right after the environment has been initialized and then never again. Please refer to the minimal example above to see this paradigm in action.

  • options (optional dict) – Additional information to specify how the environment is reset (optional, depending on the specific environment)

Returns:

Observation of the initial state. This will be an element of observation_space

(typically a numpy array) and is analogous to the observation returned by step().

info (dictionary): This dictionary contains auxiliary information complementing observation. It should be analogous to

the info returned by step().

Return type:

observation (ObsType)

step(action)#

Steps the environment with the given action. Unlike the typical Gym environment, this method should also add the {“task_completion”: self.task_completion()} key to the info dictionary to support curricula that rely on this metric.

syllabus.tests.utils module#

syllabus.tests.utils.create_cartpole_env(*args, type=None, env_args=(), env_kwargs={}, **kwargs)#
syllabus.tests.utils.create_minigrid_env(*args, type=None, env_args=(), env_kwargs={}, **kwargs)#
syllabus.tests.utils.create_nethack_env(*args, type=None, env_args=(), env_kwargs={}, **kwargs)#
syllabus.tests.utils.create_synctest_env(*args, type=None, env_args=(), env_kwargs={}, **kwargs)#
syllabus.tests.utils.evaluate_random_policy(make_env, num_episodes=100, seeds=None)#
syllabus.tests.utils.run_episode(env, new_task=None, curriculum=None)#

Run a single episode of the environment.

syllabus.tests.utils.run_episodes(env_fn, env_args, env_kwargs, curriculum=None, num_episodes=10)#

Run multiple episodes of the environment.

syllabus.tests.utils.run_episodes_queue(env_fn, env_args, env_kwargs, task_queue, update_queue, sync=True, num_episodes=10, update_on_step=True)#
syllabus.tests.utils.test_native_multiprocess(env_fn, env_args=(), env_kwargs={}, curriculum=None, num_envs=2, num_episodes=10, update_on_step=True)#
syllabus.tests.utils.test_ray_multiprocess(env_fn, env_args=(), env_kwargs={}, curriculum=None, num_envs=2, num_episodes=10, update_on_step=True)#
syllabus.tests.utils.test_single_process(env_fn, env_args=(), env_kwargs={}, curriculum=None, num_envs=2, num_episodes=10)#

Module contents#