<jupyter_start><jupyter_text>Load some (old) env files to check they workThis 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...<jupyter_code>%load_ext autoreload
%autoreload 2
from IPython import display
display.display(display.HTML("<style>.container { width:95% !important; }</style>"))
import PIL
import glob
import pickle
import msgpack
import importlib_resources as ir
from flatland.envs.persistence import RailEnvPersister
from flatland.utils import env_edit_utils as eeu
from flatland.utils import jupyter_utils as ju
#lsDirs = [ "../env_data/railway", "../env_data/tests"]
lsPackages = [ "env_data.railway", "env_data.tests"]
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
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)
            
        
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()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1004119464469619, 'fraction_numerical': 0.0025746652935118436, 'mean_word_length': 2.9897330595482545, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '631480', 'license': 'MIT', 'n_tokens_mistral': 626, 'n_tokens_neox': 606, 'n_words': 196, 'path': 'notebooks/test-saved-envs.ipynb', 'repo_name': 'nobodyczcz/flatland2020', 'size': '1942'}