# garage.sampler.worker¶

Worker interface used in all Samplers.

class Worker(*, seed, max_episode_length, worker_number)[source]

Bases: abc.ABC

Worker class used in all Samplers.

update_agent(self, agent_update)[source]

Update the worker’s agent, using agent_update.

Parameters

agent_update (object) – An agent update. The exact type of this argument depends on the Worker implementation.

update_env(self, env_update)[source]

Update the worker’s env, using env_update.

Parameters

env_update (object) – An environment update. The exact type of this argument depends on the Worker implementation.

rollout(self)[source]

Sample a single episode of the agent in the environment.

Returns

Batch of sampled episodes. May be truncated if

max_episode_length is set.

Return type

EpisodeBatch

start_episode(self)[source]

Begin a new episode.

step_episode(self)[source]

Take a single time-step in the current episode.

Returns

True iff the episode is done, either due to the environment indicating termination of due to reaching max_episode_length.

collect_episode(self)[source]

Collect the current episode, clearing the internal buffer.

Returns

Batch of sampled episodes. May be truncated if the

episodes haven’t completed yet.

Return type

EpisodeBatch

shutdown(self)[source]

Shutdown the worker.