diff --git a/benchmarks/run_all_examples.py b/benchmarks/run_all_examples.py index 91bbc048e94d329878601d2b7d751b2d37fbf3a0..d2ace3c3b29a6f3e25d902b00f922e53bb0447a9 100644 --- a/benchmarks/run_all_examples.py +++ b/benchmarks/run_all_examples.py @@ -8,6 +8,8 @@ from importlib_resources import path from benchmarks.benchmark_utils import swap_attr +print("run_all_examples.py") + for entry in [entry for entry in importlib_resources.contents('examples') if not pkg_resources.resource_isdir('examples', entry) and entry.endswith(".py") @@ -24,8 +26,11 @@ for entry in [entry for entry in importlib_resources.contents('examples') if print("Running {}".format(entry)) print("*****************************************************************") with swap_attr(sys, "stdin", StringIO("q")): - runpy.run_path(file_in, run_name="__main__", init_globals={ - 'argv': ['--sleep-for-animation=False'] - }) + try: + runpy.run_path(file_in, run_name="__main__", init_globals={ + 'argv': ['--sleep-for-animation=False'] + }) + except Exception as e: + print(e) print("runpy done.") print("Done with {}".format(entry)) diff --git a/examples/simple_example_3.py b/examples/simple_example_3.py index 6df6d4af3076b3d9659aadbd55296b667dc7d6db..61ca23840d6c59e75d75d5a15fa9fb8118f45b95 100644 --- a/examples/simple_example_3.py +++ b/examples/simple_example_3.py @@ -37,9 +37,7 @@ for step in range(100): i = 0 while i < len(cmds): if cmds[i] == 'q': - import sys - - sys.exit() + break elif cmds[i] == 's': obs, all_rewards, done, _ = env.step(action_dict) action_dict = {} @@ -50,5 +48,4 @@ for step in range(100): action_dict[agent_id] = action i = i + 1 i += 1 - - env_renderer.render_env(show=True, frames=True) + env_renderer.render_env(show=True, frames=True) diff --git a/examples/simple_example_city_railway_generator.py b/examples/simple_example_city_railway_generator.py index 3ccc12a8b73a716d5ff44ffcb399cd913873cedf..ce96932ccf49c9d71a97431bd0bdabd4cdeaf576 100644 --- a/examples/simple_example_city_railway_generator.py +++ b/examples/simple_example_city_railway_generator.py @@ -11,7 +11,7 @@ from flatland.utils.rendertools import RenderTool, AgentRenderVariant os.mkdir("./../render_output/") -for itrials in np.arange(1, 1000, 1): +for itrials in np.arange(1, 15, 1): print(itrials, "generate new city") # init seed