Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tf_agents.environments.parallel_py_environment.ProcessPyEnvironment

View source on GitHub

Step a single env in a separate process for lock free paralellism.

tf_agents.environments.parallel_py_environment.ProcessPyEnvironment(
    env_constructor, flatten=False
)

Args:

  • env_constructor: Callable that creates and returns a Python environment.
  • flatten: Boolean, whether to assume flattened actions and time_steps during communication to avoid overhead.

Methods

action_spec

View source

action_spec()

call

View source

call(
    name, *args, **kwargs
)

Asynchronously call a method of the external environment.

Args:

  • name: Name of the method to call.
  • *args: Positional arguments to forward to the method.
  • **kwargs: Keyword arguments to forward to the method.

Returns:

Promise object that blocks and provides the return value when called.

close

View source

close()

Send a close message to the external process and join it.

observation_spec

View source

observation_spec()

reset

View source

reset(
    blocking=True
)

Reset the environment.

Args:

  • blocking: Whether to wait for the result.

Returns:

New observation when blocking, otherwise callable that returns the new observation.

start

View source

start(
    wait_to_start=True
)

Start the process.

Args:

  • wait_to_start: Whether the call should wait for an env initialization.

step

View source

step(
    action, blocking=True
)

Step the environment.

Args:

  • action: The action to apply to the environment.
  • blocking: Whether to wait for the result.

Returns:

time step when blocking, otherwise callable that returns the time step.

time_step_spec

View source

time_step_spec()

wait_start

View source

wait_start()

Wait for the started process to finish initialization.