From 7bda56dad88e623488e6610352ce50b747ffccaf Mon Sep 17 00:00:00 2001 From: u214892 <u214892@sbb.ch> Date: Fri, 20 Sep 2019 09:26:16 +0200 Subject: [PATCH] #163 not running in c --- benchmarks/run_all_examples.py | 11 ++++++++--- examples/simple_example_3.py | 7 ++----- examples/simple_example_city_railway_generator.py | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/benchmarks/run_all_examples.py b/benchmarks/run_all_examples.py index 91bbc048..d2ace3c3 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 6df6d4af..61ca2384 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 3ccc12a8..ce96932c 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 -- GitLab