Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Flatland
neurips2020-flatland-baselines
Commits
56ee893a
Commit
56ee893a
authored
Aug 02, 2020
by
nilabha
Browse files
add changes to support render for eval
parent
3f321add
Pipeline
#5031
passed with stage
in 2 minutes and 31 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
envs/flatland/eval_configs/default_render.yaml
0 → 100644
View file @
56ee893a
evaluation_num_workers
:
2
# Evaluation wokers for the evaluation run.
evaluation_interval
:
50
# Episodes each time evaluation runs.
evaluation_num_episodes
:
50
# Override the env config for evaluation.
evaluation_config
:
explore
:
False
env_config
:
seed
:
100
render
:
human
\ No newline at end of file
envs/flatland/eval_configs/test_render_eval.yaml
0 → 100644
View file @
56ee893a
evaluation_num_workers
:
2
# Enable evaluation, once per training iteration.
evaluation_interval
:
1
# Run 1 episode each time evaluation runs.
evaluation_num_episodes
:
2
# Override the env config for evaluation.
evaluation_config
:
explore
:
False
env_config
:
seed
:
100
render
:
human
\ No newline at end of file
envs/flatland/utils/gym_env_wrappers.py
View file @
56ee893a
...
...
@@ -447,9 +447,10 @@ class FlatlandRenderWrapper(RailEnv,gym.Env):
show_debug
=
False
,
screen_height
=
600
,
# Adjust these parameters to fit your resolution
screen_width
=
800
)
# Adjust these parameters to fit your resolution
self
.
renderer
.
show
=
False
def
update_renderer
(
self
,
mode
=
'human'
):
image
=
self
.
renderer
.
render_env
(
show
=
Tru
e
,
show_observations
=
False
,
show_predictions
=
False
,
image
=
self
.
renderer
.
render_env
(
show
=
Fals
e
,
show_observations
=
False
,
show_predictions
=
False
,
return_image
=
True
)
return
image
[:,:,:
3
]
...
...
@@ -462,12 +463,12 @@ class FlatlandRenderWrapper(RailEnv,gym.Env):
super
().
close
()
if
self
.
renderer
:
try
:
self
.
renderer
.
close_window
()
self
.
renderer
=
None
if
self
.
renderer
.
show
:
self
.
renderer
.
close_window
()
except
Exception
as
e
:
# This is since the last step(Due to a stopping criteria) is skipped by rllib
# Due to this done is not true and the env does not close
# Finally the env is closed when RLLib exits but at that time there is no window
# and hence the error
print
(
"Could Not close window due to:"
,
e
)
self
.
renderer
=
None
train.py
View file @
56ee893a
...
...
@@ -192,6 +192,7 @@ def run(args, parser):
eval_configs
=
get_eval_config
(
exp
[
'config'
].
get
(
'env_config'
,
\
{}).
get
(
'eval_generator'
,
"default"
))
eval_seed
=
eval_configs
.
get
(
'evaluation_config'
,{}).
get
(
'env_config'
,{}).
get
(
'seed'
)
eval_render
=
eval_configs
.
get
(
'evaluation_config'
,{}).
get
(
'env_config'
,{}).
get
(
'render'
)
# add evaluation config to the current config
exp
[
'config'
]
=
merge_dicts
(
exp
[
'config'
],
eval_configs
)
...
...
@@ -201,6 +202,9 @@ def run(args, parser):
if
eval_seed
and
eval_env_config
:
# We override the env seed from the evaluation config
eval_env_config
[
'seed'
]
=
eval_seed
if
eval_render
and
eval_env_config
:
# We override the env render from the evaluation config
eval_env_config
[
'render'
]
=
eval_render
# Remove any wandb related configs
if
eval_env_config
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment