Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 2.83 KB

environment.md

File metadata and controls

53 lines (35 loc) · 2.83 KB

Environment development

This is a practical guide for developers wanting to develop new environments, or integrate existing third-party environments, within cogment verse.

At the moment, all environment implementations are provided by a single service with multiple endpoints. This is likely to change in the future and the documentation below will need to be updated to reflect any changes in the architecture.

Method 1: Add a new endpoint to the existing environment service

Step 1 - Update dependencies

If your environment has any additional dependencies, you will need to update the Dockerfile (for system dependencies) and pyproject.toml (for python dependencies) files to reflect this. Additional details can be found here.

Step 2 - Write an adapter for your environment

The environment service expects a gym-like API provided by the BaseEnv class. Existing third-party environments can be integrated using a small amount of glue code, see for example

Step 3 - Register your environment

Edit the EnvironmentAdapter in the following locations

  • Add your environment constructor to the list of ENVIRONMENT_CONSTRUCTORS
  • Add the names of the provided environments to self._environments in the EnvironmentAdapter constructor
  • Add the names of the environment endpoints to COGMENT_VERSE_ENVIRONMENT_ENDPOINTS in (/.env).

Step 4 - Add unit tests for your environment

The MockEnvironmentSession class allows you to create and interact with your environment using the same API that is exposed to other services. For examples of how to test environments, see test_atari and test_procgen. The tests can be run via the command

cogment run test_environment

Step 5 - Add a run configuration to train using your environment

Edit run_params to create a run configuration using one of the new environment endpoints that you have registered. The environment endpoint is determined by the environment_implementation field of the run configuration.

Method 2: Develop your own environment service

Todo!