Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pranjal_dhole
Flatland
Commits
45b62aed
Commit
45b62aed
authored
4 years ago
by
spmohanty
Browse files
Options
Downloads
Patches
Plain Diff
Pass controller inference time from client to server
parent
ae719489
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatland/evaluators/client.py
+6
-5
6 additions, 5 deletions
flatland/evaluators/client.py
flatland/evaluators/service.py
+6
-5
6 additions, 5 deletions
flatland/evaluators/service.py
with
12 additions
and
10 deletions
flatland/evaluators/client.py
+
6
−
5
View file @
45b62aed
...
...
@@ -253,15 +253,16 @@ class FlatlandRemoteClient(object):
def
env_step
(
self
,
action
,
render
=
False
):
"""
Respond with [observation, reward, done, info]
"""
"""
# We use the last_env_step_time as an approximate measure of the inference time
approximate_inference_time
=
time
.
time
()
-
self
.
last_env_step_time
self
.
update_running_stats
(
"
inference_time(approx)
"
,
approximate_inference_time
)
_request
=
{}
_request
[
'
type
'
]
=
messages
.
FLATLAND_RL
.
ENV_STEP
_request
[
'
payload
'
]
=
{}
_request
[
'
payload
'
][
'
action
'
]
=
action
# We use the last_env_step_time as an approximate measure of the inference time
approximate_inference_time
=
time
.
time
()
-
self
.
last_env_step_time
self
.
update_running_stats
(
"
inference_time(approx)
"
,
approximate_inference_time
)
_request
[
'
payload
'
][
'
inference_time
'
]
=
approximate_inference_time
# Relay the action in a non-blocking way to the server
# so that it can start doing an env.step on it in ~ parallel
...
...
This diff is collapsed.
Click to expand it.
flatland/evaluators/service.py
+
6
−
5
View file @
45b62aed
...
...
@@ -196,7 +196,6 @@ class FlatlandRemoteEvaluationService:
self
.
stats
[
max_key
]
=
scalar
self
.
stats
[
counter_key
]
=
1
def
get_env_filepaths
(
self
):
"""
Gathers a list of all available rail env files to be used
...
...
@@ -246,8 +245,9 @@ class FlatlandRemoteEvaluationService:
)
if
os
.
path
.
exists
(
metadata_file_path
):
self
.
evaluation_metadata_df
=
pd
.
read_csv
(
metadata_file_path
)
self
.
evaluation_metadata_df
[
"
filename
"
]
=
self
.
evaluation_metadata_df
[
"
test_id
"
]
+
\
"
/
"
+
self
.
evaluation_metadata_df
[
"
env_id
"
]
+
"
.pkl
"
self
.
evaluation_metadata_df
[
"
filename
"
]
=
\
self
.
evaluation_metadata_df
[
"
test_id
"
]
+
\
"
/
"
+
self
.
evaluation_metadata_df
[
"
env_id
"
]
+
"
.pkl
"
self
.
evaluation_metadata_df
=
self
.
evaluation_metadata_df
.
set_index
(
"
filename
"
)
# Add custom columns
...
...
@@ -458,7 +458,6 @@ class FlatlandRemoteEvaluationService:
malfunction_generator_and_process_data
=
malfunction_from_file
(
test_env_file_path
),
obs_builder_object
=
DummyObservationBuilder
())
if
self
.
begin_simulation
:
# If begin simulation has already been initialized
# atleast once
...
...
@@ -548,6 +547,9 @@ class FlatlandRemoteEvaluationService:
has done[
'
__all__
'
]==True
"
)
action
=
_payload
[
'
action
'
]
inference_time
=
_payload
[
'
inference_time
'
]
self
.
update_running_stats
(
"
controller_inference_time
"
,
inference_time
)
time_start
=
time
.
time
()
_observation
,
all_rewards
,
done
,
info
=
self
.
env
.
step
(
action
)
time_diff
=
time
.
time
()
-
time_start
...
...
@@ -625,7 +627,6 @@ class FlatlandRemoteEvaluationService:
self
.
stats
[
max_key
]))
print
(
"
=
"
*
100
)
# Register simulation time of the last episode
self
.
simulation_times
.
append
(
time
.
time
()
-
self
.
begin_simulation
)
# Compute the evaluation metadata for the last episode
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment