Skip to content
Snippets Groups Projects
Commit 0de93b9a authored by adrian_egli2's avatar adrian_egli2
Browse files

Notebook is working (Flatland3)

parent 68c99627
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
## Load some (old) env files to check they work
This notebook just loads some old env files, renders them, and runs a few steps.
This is just a sanity check that these old envs will still load.
Many of them use deprecated data formats so it's just so that we can avoid deleting them for now, and so new participants are not confused by us shipping env files which don't work...
%% Cell type:code id: tags:
``` python
%load_ext autoreload
%autoreload 2
```
%% Cell type:code id: tags:
``` python
from IPython import display
display.display(display.HTML("<style>.container { width:95% !important; }</style>"))
```
%% Cell type:code id: tags:
``` python
import PIL
import glob
import pickle
import msgpack
import importlib_resources as ir
```
%% Cell type:code id: tags:
``` python
from flatland.envs.persistence import RailEnvPersister
```
%% Cell type:code id: tags:
``` python
from flatland.utils import env_edit_utils as eeu
from flatland.utils import jupyter_utils as ju
```
%% Cell type:code id: tags:
``` python
#lsDirs = [ "../env_data/railway", "../env_data/tests"]
lsPackages = [ "env_data.railway", "env_data.tests"]
lsPackages = [ "env_data.railway"]
```
%% Cell type:code id: tags:
``` python
ltPackRes = []
for sPack in lsPackages:
for sExt in ["mpk", "pkl"]:
#lsFiles += glob.glob(sDir + "/*" + sExt)
ltPackRes += [ (sPack, sRes) for sRes in ir.contents(sPack) if sRes.endswith(sExt) ]
ltPackRes
```
%% Cell type:code id: tags:
``` python
if False:
for sFile in lsFiles:
try:
with open(sFile, "rb") as fIn:
env_dict = pickle.load(fIn)
print("pickle:", sFile)
except ValueError as oErr:
try:
with open(sFile, "rb") as fIn:
env_dict = msgpack.load(fIn)
print("msgpack: ", sFile)
except ValueError as oErr:
print("msgpack failed: ", sFile)
```
%% Cell type:code id: tags:
``` python
for sPack, sRes in ltPackRes:
print("Loading: ", sPack, sRes)
env, env_dict = RailEnvPersister.load_new(sRes, load_from_package=sPack)
env.reset()
oCanvas = ju.EnvCanvas(env, ju.AlwaysForward(env))
oCanvas.show()
for iStep in range(10):
oCanvas.step()
oCanvas.render()
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment