Skip to content
Snippets Groups Projects
Commit b304b574 authored by spmohanty's avatar spmohanty
Browse files

Addresses #220 - Implements a version match check between the client and the service

parent e09dc410
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ import msgpack_numpy as m ...@@ -10,6 +10,7 @@ import msgpack_numpy as m
import numpy as np import numpy as np
import redis import redis
import flatland
from flatland.envs.observations import TreeObsForRailEnv from flatland.envs.observations import TreeObsForRailEnv
from flatland.envs.predictions import ShortestPathPredictorForRailEnv from flatland.envs.predictions import ShortestPathPredictorForRailEnv
from flatland.envs.rail_env import RailEnv from flatland.envs.rail_env import RailEnv
...@@ -146,11 +147,13 @@ class FlatlandRemoteClient(object): ...@@ -146,11 +147,13 @@ class FlatlandRemoteClient(object):
""" """
_request = {} _request = {}
_request['type'] = messages.FLATLAND_RL.PING _request['type'] = messages.FLATLAND_RL.PING
_request['payload'] = {} _request['payload'] = {
"version" : flatland.__version__
}
_response = self._blocking_request(_request) _response = self._blocking_request(_request)
if _response['type'] != messages.FLATLAND_RL.PONG: if _response['type'] != messages.FLATLAND_RL.PONG:
raise Exception( raise Exception(
"Unable to perform handshake with the redis service. \ "Unable to perform handshake with the evaluation service. \
Expected PONG; received {}".format(json.dumps(_response))) Expected PONG; received {}".format(json.dumps(_response)))
else: else:
return True return True
......
...@@ -8,6 +8,7 @@ import shutil ...@@ -8,6 +8,7 @@ import shutil
import time import time
import traceback import traceback
import flatland
import crowdai_api import crowdai_api
import msgpack import msgpack
import msgpack_numpy as m import msgpack_numpy as m
...@@ -283,10 +284,26 @@ class FlatlandRemoteEvaluationService: ...@@ -283,10 +284,26 @@ class FlatlandRemoteEvaluationService:
""" """
Handles PING command from the client. Handles PING command from the client.
""" """
service_version = flatland.__version__
if "version" in command["payload"].keys():
client_version = command["payload"]["version"]
else:
# 2.1.4 -> when the version mismatch check was added
client_version = "2.1.4"
_command_response = {} _command_response = {}
_command_response['type'] = messages.FLATLAND_RL.PONG _command_response['type'] = messages.FLATLAND_RL.PONG
_command_response['payload'] = {} _command_response['payload'] = {}
if client_version != service_version:
_command_response['type'] = messages.FLATLAND_RL.ERROR
_command_response['payload']['message'] = \
"Client-Server Version Mismatch => " + \
"[ Client Version : {} ] ".format(client_version) + \
"[ Server Version : {} ] ".format(service_version)
self.send_response(_command_response, command)
raise Exception(_command_response['payload']['message'])
self.send_response(_command_response, command) self.send_response(_command_response, command)
def handle_env_create(self, command): def handle_env_create(self, command):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment