Skip to content

Commit

Permalink
Introduce a lobby + fix multiuser joining + instruction for deploying…
Browse files Browse the repository at this point in the history
… using a tunnelling system (#109)

* Fix missing constructor parameters

* Introduce a trial lobby

* Fix copyright notices

* Adding documentation for ngrok based tunnel

* Take into account review
  • Loading branch information
cloderic committed Jan 24, 2023
1 parent cb749c5 commit a2311bf
Show file tree
Hide file tree
Showing 88 changed files with 30,231 additions and 14,513 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ node_modules/
# Run outputs generated by Hydra
outputs
multirun

# Local ngrok configuration
ngrok.yaml
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Cogment verse includes environments from:
- [Development Setup](/docs/development_setup.md)
- [Debug](#debug)
- [Environment development](/docs/environment.md)
- Deploy 🚧
- [Tunnel unsing ngrok](/docs/deployment/tunnel_using_ngrok.md)
- [Changelog](/CHANGELOG.md)
- [Contributors guide](/CONTRIBUTING.md)
- [Community code of conduct](/CODE_OF_CONDUCT.md)
Expand All @@ -47,23 +49,24 @@ Cogment verse includes environments from:
- `python3-opencv`, which is required on ubuntu systems, it can be installed using `apt-get install python3-opencv`

4. Create and activate a virtual environment by runnning

```console
$ python -m venv .venv
$ source .venv/bin/activate
```

6. Install the python dependencies by running
5. Install the python dependencies by running
```console
$ pip install -r requirements.txt
```
7. In another terminal, launch a mlflow server on port 3000 by running
6. In another terminal, launch a mlflow server on port 3000 by running
```console
$ source .venv/bin/activate
$ python -m simple_mlflow
```
8. Start the default Cogment Verse run using `python -m main`
9. Open Chrome (other web browser might work but haven't tested) and navigate to http://localhost:8080/
10. Play the game!
7. Start the default Cogment Verse run using `python -m main`
8. Open Chrome (other web browser might work but haven't tested) and navigate to http://localhost:8080/
9. Play the game!

That's the basic setup for Cogment Verse, you are now ready to train AI agents.

Expand Down Expand Up @@ -110,16 +113,16 @@ Here are a few examples:
## Isaac gym

If you want to use Isaac Gym, use python3.8 (not python3.9)

1. download the zip file from [NVIDIA webpage](https://developer.nvidia.com/isaac-gym)
, unzip and copy the `isaacgym` folder to this repo.
, unzip and copy the `isaacgym` folder to this repo.
2. clone [IsaacGymEnvs](https://github.com/NVIDIA-Omniverse/IsaacGymEnvs) and copy the
folder inside the `isaacgym` folder
folder inside the `isaacgym` folder
3. comment out line-32 in `isaacgym/IsaacGymEnvs/isaacgymenvs/__init__.py`
4. (Assuming you already installed requirements.txt), run `pip install -r isaac_requirements.txt`.
5. nvidia-smi` to check that you have NVIDIA drivers and proper cuda installations.
6. (Assuming you already have mlflow running in a different terminal), Run `python -m main services/environment=ant`


## List of publications and submissions using Cogment and/or Cogment Verse

- Analyzing and Overcoming Degradation in Warm-Start Off-Policy Reinforcement Learning [code](https://github.com/benwex93/cogment-verse)
Expand Down
2 changes: 1 addition & 1 deletion actors/simple_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
dtype=torch.float,
version_number=0,
):
super().__init__()
super().__init__(model_id=model_id, version_number=version_number)
self._dtype = dtype
self._environment_implementation = environment_implementation
self._num_input = num_input
Expand Down
8 changes: 4 additions & 4 deletions cogment_verse/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def __init__(self, cfg, work_dir=".cogment_verse"):
if service_type not in [service_type.value for service_type in ServiceType]:
raise RuntimeError(f"Unknown service type [{service_type}]")
if service_type == ServiceType.ORCHESTRATOR.value:
for orchestrator_service_cfg in services_cfg.values():
self.services_process.append(
create_orchestrator_service(work_dir, orchestrator_service_cfg, self.services_directory)
)
orchestrator_service_cfg = services_cfg
self.services_process.append(
create_orchestrator_service(work_dir, orchestrator_service_cfg, self.services_directory)
)
elif service_type == ServiceType.TRIAL_DATASTORE.value:
trial_datastore_service_cfg = services_cfg
self.services_process.append(
Expand Down
3 changes: 2 additions & 1 deletion cogment_verse/processes/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
def create_orchestrator_service(work_dir, orchestrator_cfg, services_directory):
port = orchestrator_cfg.port
web_port = orchestrator_cfg.web_port
web_endpoint = orchestrator_cfg.web_endpoint
services_directory.add(
service_type=ServiceType.ORCHESTRATOR,
service_endpoint=f"grpc://localhost:{port}",
)
services_directory.add(
service_type=ServiceType.ORCHESTRATOR_WEB_ENDPOINT,
service_endpoint=f"http://localhost:{web_port}",
service_endpoint=web_endpoint,
)
return CogmentCliProcess(
name="orchestrator",
Expand Down
23 changes: 12 additions & 11 deletions cogment_verse/processes/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

log = logging.getLogger(__name__)

WEB_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../web/components"))
WEB_SOURCES_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../web/web_app"))

WEB_BUILD_DIR = os.path.abspath(os.path.join(WEB_SOURCES_DIR, "build"))


def on_cra_log(_name, log_line):
Expand All @@ -37,9 +39,9 @@ def on_awaiting_cra_ready():
class NpmProcess(PopenProcess):
def __init__(self, name, specs_filename, services_directory, web_cfg):
log.info("Installing web components dependencies using `npm install`...")
npm_command(["install", "--no-audit"], WEB_DIR)
npm_command(["install", "--no-audit"], WEB_SOURCES_DIR)

generate(specs_filename, WEB_DIR, web_cfg.get("force_rebuild", False))
generate(specs_filename, WEB_SOURCES_DIR, web_cfg.get("force_rebuild", False))

super().__init__(
name=name,
Expand All @@ -54,23 +56,22 @@ def __init__(self, name, specs_filename, services_directory, web_cfg):

class WebProcess(CogmentVerseProcess):
def __init__(self, name, specs_filename, services_directory, web_cfg):
served_dir = os.path.abspath(os.path.join(WEB_DIR, "build"))
# TODO find a better way to detect a rebuild is needed
if not os.path.isdir(served_dir) or web_cfg.get("build", False):
log.info("Installing web components dependencies using `npm install`...")
npm_command(["install", "--no-audit"], WEB_DIR)
if not os.path.isdir(WEB_BUILD_DIR) or web_cfg.get("build", False):
log.info("Installing web app dependencies using `npm install`...")
npm_command(["install", "--no-audit"], WEB_SOURCES_DIR)

generate(specs_filename, WEB_DIR, True)
generate(specs_filename, WEB_SOURCES_DIR, True)

log.info("Building the web components `npm run build`...")
npm_command(["run", "build"], WEB_DIR)
log.info("Building the web app `npm run build`...")
npm_command(["run", "build"], WEB_SOURCES_DIR)

super().__init__(
name=name,
target=server_main,
port=web_cfg.port,
orchestrator_web_endpoint=services_directory.get(ServiceType.ORCHESTRATOR_WEB_ENDPOINT),
served_dir=served_dir,
served_dir=WEB_BUILD_DIR,
)


Expand Down
1 change: 0 additions & 1 deletion cogment_verse/web/components/build/index.html

This file was deleted.

3 changes: 0 additions & 3 deletions cogment_verse/web/components/build/robots.txt

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a2311bf

Please sign in to comment.