This is a practical guide for developers wanting to develop within Cogment Verse.
Check the code style using black
by running the following in the virtual environment in the root directory:
$ black --check --diff .
Fix the code style by running:
$ black .
Check the code quality using pylint
by running the following in the virtual environment in the root directory:
$ pylint --recursive=y .
-
Create the following python script
md_debug.py
import sys import pdb class ForkedPdb(pdb.Pdb): """A Pdb subclass that may be used from a forked multiprocessing child""" def interaction(self, *args, **kwargs): _stdin = sys.stdin try: sys.stdin = open('/dev/stdin') pdb.Pdb.interaction(self, *args, **kwargs) finally: sys.stdin = _stdin
-
Import the above script to the python file that you want to debug
from mp_debug import ForkedPdb
-
Set a breakpoint using the following command
python ForkedPdb().set_trace()
NOTE: The other commands are the same as the PDB debugger.
Cogment Verse includes a modular web app designed for human-in-the-loop learning developed with React.
To develop the web app, you'll need to install Node.JS v16 or above.
The host web app is included in the "core" cogment_verse package in /cogment_verse/web/web_app
.
Each environment provides its own web app plugin that defines how it is rendered and how the player can interact with it. Environment plugins are React components that leverages the @cogment/cogment_verse
SDK defined in /cogment_verse/web/web_app/src/shared
. Full documentation on how to develop your own environment plugin is a work in progress, in the meantime take a look at the built-in plugins e.g. in /environments/gym/web
.
When running a default instance of Cogment Verse, the prebuilt web app, located in /cogment_verse/web/web_app/dist
is used. e.g.
$ python -m main
⚠️ in this mode, any changes to the sources will be ignored
To trigger a rebuild before launching the webapp, the services.web.build
needs to be set to True
. e.g.
$ python -m main services.web.build=True
This perform to a full static build of the web app before launching the instance.
⚠️ only the host webapp is rebuilt in that way, changes to the environment plugins need to be rebuilt separately, usually by runningnpm run build
in their directory.
Run the test suite on the python codebase using pytest
by running the following in the virtual environment in the root directory:
$ python -m pytest
To only run functional tests
$ python -m pytest -m functional --durations=0 --no-header -v