How to use TreeObsForRailEnv in remote client?

When I initialize a TreeObsForRailEnv and pass it as the obs_builder_obj for the remote client, I get the following error:

# Relevant code chunk
tree_observation = TreeObsForRailEnv(max_depth=2)
observation, info = remote_client.env_create(obs_builder_object=tree_observation)
# Error
Traceback (most recent call last):
  File "run.py", line 90, in <module>
    obs_builder_object=tree_observation
  File "/anaconda/envs/flatland-rl/lib/python3.6/site-packages/flatland/evaluators/client.py", line 200, in env_create
    _response = self._remote_request(_request)
  File "/anaconda/envs/flatland-rl/lib/python3.6/site-packages/flatland/evaluators/client.py", line 165, in _remote_request
    raise Exception(str(_response["payload"]))
Exception: {'type': 'FLATLAND_RL.ERROR', 'payload': "'current_episode_controller_inference_time_min'"}

Hey @seungjaeryanlee,

Itā€™s hard to say seeing only this part of the code. Could you point me to a (potentially private) repo with the full code?

I suspect this is a bug in the current pip version of Flatland which happens if a timeout occurs during the first timestep of an episode.

Are you maybe taking too long to do the first step after creating the env (timeout of 5min)? or to take the first step afterward (timeout of 5sec)?

helloļ¼Œhave you solved this problem? please give me some advice, thanks.

It is still not clear to me what this error is about, we could look more into it if we had a code sample or link to a gitlab issue where it occurs.

I stumbled over this thread getting the following error when trying to start

flatland-evaluator --tests ./scratch/test-envs

ERROR:
[ā€˜Test_0/Level_0.pklā€™, ā€˜Test_3/Level_0.pklā€™, ā€˜Test_3/Level_1.pklā€™, ā€˜Test_13/Level_1.pklā€™, ā€˜Test_1/Level_1.pklā€™, ā€˜Test_8/Level_1.pklā€™, ā€˜Test_6/Level_0.pklā€™, ā€˜Test_10/Level_0.pklā€™, ā€˜Test_2/Level_1.pklā€™, ā€˜Test_5/Level_0.pklā€™, ā€˜Test_4/Level_0.pklā€™, ā€˜Test_6/Level_1.pklā€™, ā€˜Test_9/Level_1.pklā€™, ā€˜Test_11/Level_0.pklā€™, ā€˜Test_7/Level_1.pklā€™, ā€˜Test_10/Level_1.pklā€™, ā€˜Test_0/Level_1.pklā€™, ā€˜Test_5/Level_1.pklā€™, ā€˜Test_8/Level_0.pklā€™, ā€˜Test_12/Level_0.pklā€™, ā€˜Test_1/Level_0.pklā€™, ā€˜Test_12/Level_1.pklā€™, ā€˜Test_11/Level_1.pklā€™, ā€˜Test_2/Level_0.pklā€™, ā€˜Test_9/Level_0.pklā€™, ā€˜Test_7/Level_0.pklā€™, ā€˜Test_13/Level_0.pklā€™, ā€˜Test_4/Level_1.pklā€™]
Listening at : flatland-rl::FLATLAND_RL_SERVICE_ID::commands
Evaluating : Test_0/Level_0.pkl
Evaluating : Test_3/Level_0.pkl
~/anaconda3/envs/flatland-rl-mw-cpu/lib/python3.7/site-packages/pandas/core/generic.py:5209: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
self[name] = value
Error : ā€˜current_episode_controller_inference_time_minā€™
Traceback (most recent call last):
File ā€œ~/anaconda3/envs/flatland-rl-mw-cpu/lib/python3.7/site-packages/flatland/evaluators/service.pyā€, line 865, in run
self.handle_env_create(command)
File ā€œ~/anaconda3/envs/flatland-rl-mw-cpu/lib/python3.7/site-packages/flatland/evaluators/service.pyā€, line 514, in handle_env_create
self.update_evaluation_metadata()
File ā€œ~/anaconda3/envs/flatland-rl-mw-cpu/lib/python3.7/site-packages/flatland/evaluators/service.pyā€, line 312, in update_evaluation_metadata
ā€œcurrent_episode_controller_inference_time_minā€
KeyError: ā€˜current_episode_controller_inference_time_minā€™

I solved this by calling

redis-cli FLUSHALL

I thought I share this, maybe this is helping someone.

2 Likes

The first thing you should understand is that SettingWithCopyWarning is a warning, and not an error. The real problem behind the warning is that it is generally difficult to predict whether a view or a copy is returned. In most cases, the warning was raised because you have chained two indexing operations together. The SettingWithCopyWarning was created to flag ā€œchained assignmentā€ operations. This is made easier to spot because you might be used [] (square brackets) twice, but the same would be true if you used other access methods such as .loc[] , .iloc[] and so on.

Moreover, you can change the behaviour of SettingWithCopyWarning warning using pd.options.mode.chained_assignment with three option ā€œNone/raiseā€/ā€œwarnā€.