Skip to content

Instantly share code, notes, and snippets.

@discordianfish
Last active March 6, 2023 13:21
Show Gist options
  • Save discordianfish/8722740bdfe7dc145ccf54512bd60cc7 to your computer and use it in GitHub Desktop.
Save discordianfish/8722740bdfe7dc145ccf54512bd60cc7 to your computer and use it in GitHub Desktop.
DIAMBRA Engine Troubleshooting

Run DIAMBRA Engine without CLI

Agents connect via network using gRPC to DIAMBRA Engine running in a Docker container. The diambra CLI's run command starts the DIAMBRA Engine in a Docker container and sets up the environment to make it easy to connect to the Engine. For troubleshooting it might be useful to run the Engine manually, using hostnetworking.

Creating the ~/.diambra and ~/.diambra/credentials is only needed when you never ran the diambra cli before. Otherwise this step can be skipped.

Start Engine

Linux/MacOS:

mkdir ~/.diambra
touch ~/.diambra/credentials

docker run -d --rm --name engine \
  -v $HOME/.diambra/credentials:/tmp/.diambra/credentials \
  -v /path/to/roms:/opt/diambraArena/roms \
  --net=host docker.io/diambra/engine:latest

Windows (cmd):

mkdir %userprofile%/.diambra
echo > %userprofile%/.diambra/credentials
 
docker run --rm -ti --name engine ^
  -v %userprofile%/.diambra/credentials:/tmp/.diambra/credentials ^
  -v %userprofile%/.diambra/roms:/opt/diambraArena/roms ^
  --net=host docker.io/diambra/engine:latest

Windows (PowerShell):

mkdir $Env:userprofile/.diambra
echo "" > $Env:userprofile/.diambra/credentials
 
docker run --rm -ti --name engine `
  -v $Env:userprofile/.diambra/credentials:/tmp/.diambra/credentials `
  -v $Env:userprofile/.diambra/roms:/opt/diambraArena/roms `
  --net=host docker.io/diambra/engine:latest

Connect to Engine

Now in a new terminal, connect to the engine by specifying DIAMBRA_ENVS:

DIAMBRA_ENVS=localhost:50051 python ./agent.py

You can download a sample agent

Debug Engine connections within Docker (Desktop)

Since Docker for Windows/Mac involves running a separate VM requiring indirections in the networking layer that might cause issues, it can be helpful to connect to engine from a docker container.

Run Engine and spawn a shell:

$ diambra run <SHELLL>

Use e.g bash for on Linux/Mac or cmd.exe on Windows

Get engine container name:

$ docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED         STATUS         PORTS                        NAMES
85cb47546d01   diambra/engine:latest   "/bin/diambraEngineS…"   4 seconds ago   Up 4 seconds   127.0.0.1:49157->50051/tcp   clever_proskuriakova

Test grpc connection from linked container:

$ docker run --rm --link 85cb47546d01:engine fullstorydev/grpcurl -plaintext engine:50051 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
interface.EnvServer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment