Colab Notebook including submission and working ttyrec recording

Hello, is it possible to extend the Colab notebook with the code to do a dummy submission (train, eval, submit)?

And I am looking for a way to see the ttyrec2 files to visually inspect the agent. I save them now to my Google drive and try to watch them on my pc, but the files are empty or garbled. Somehow it is not working, I was hoping a virtual environment (pyvirtualdisplay, piglet, ffmpeg) would do the trick but no luck so far. Maybe you have a solution already?

Hi @charel_van_hoof

We’ll try to provide a full colab notebook example with train eval and submit sometime in the future, but you can follow these high level instructions and try for now.

  1. Installation -> NLE should install colab, you might need to install latest cmake with pip install -U cmake
  2. Training -> I’m not sure if the polybeast trainer works on colab, but you can any RL library you want, keep in mind that the observations are complex so will need some preprocessing, you can read the polybeast baseline of how it preprocesses.
  3. Eval -> This should work as is if your RL library works on colab.
  4. Submit -> You’ll need to add your credentials to git on colab. Take care to manage your keys and not accidentally leak it in case you’re sharing he notebooks.

As for the visualization python -m nle.scripts.ttyplay2 SAVEDIR/<your_rollout>.<pid>.<episode>.bz2 -s 0.01 will replay the episode on your terminal, you can change the speed with the -s flag.

If you’d like to record the episodes and play with a player, check out asciinema -

1 Like

Many thanks for the quick reply, looking forward to the extended Colab!
To get ttyrec2 files for visual inspection, what should I add to the code below (that I run in a Google colab cell) to get the ttyrec2 file?
env = gym.make(‘NetHackChallenge-v0’, savedir=’/tmp/replays’)
obs = env.reset()
actionlist = [0,1,2,3,4,5,6,7,61, 17]
while True:
action = random.sample(actionlist, 1)[0] # select random actions form a list
obs, rew, done, info = env.step(action) # execute the action and get the results
if done:
Should I render the screen to a virtual monitor? Or first close the gym environment? After the above code I get either an empty or scrambled ttyrec file. Reading your post, it should be something simple I am missing?
Many thanks in advance

Hi @charel_van_hoof, the rollout files that follow the name format - <your_rollout>...bz2 will be saved in the location you used for savedir when you did gym.make.

Hi Dipam,

Thanks for the response, appreciated it!
I solved part of the problem, the missing part of the above code is to close the session in order to get a non-empty bz2 file. So env.close() needed to be added at the end to get a file in the location used for savedir when created gym.make.
To view them, running !python -m nle.scripts.ttyplay2 SAVEDIR/<your_rollout>.<pid>.<episode>.bz2 -s 0.01 does not render well in a colab cell.
I try to see the file on a windows PC, I tried termrec – tty recorder/player but that could not show the file properly, I guess because it is expecting ttyrec is ttyrec2?

Any help most welcome.

Hi @charel_van_hoof, could you try once with git bash on Windows. I’ll try to check but I think nle is currently not support on windows. But just the ttyplay2 script might work.

I get all kind of errors, unfortunately

This is a file of a random agent created on Google colab, could you check if it is a valid ttyrec2 file? (So my search basically has become a windows or online viewer):

Asciinema looks good, are you suggesting I can play ttyrec2 files in asciinema (needs .play files) or is there a way to generate .play file formats by nle/gym?

Hi all. Just vis a vis the original question/colab notebooks there is now a separate Baselines notebook, available on colab, and in the Notebooks section of the Competition Pages


Thank you, I see the notebook let you run a kind of local test submission, not an actual submission. I was kind of hoping on a Colab that let you actually do a submission. But reading the instructions on how to submit ( it looks like I need to create a private repository including the Colab on your Gitlab. Any chance you have an example of a default repository with a Colab setup?