From 7f5b64fa7a2e8b3fafee6c969b15214af666a3a1 Mon Sep 17 00:00:00 2001 From: Javier Arroyo Date: Fri, 10 Nov 2023 18:09:14 +0100 Subject: [PATCH] Ensure all objects sent to requests are json serializable using int. --- boptestGymEnv.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/boptestGymEnv.py b/boptestGymEnv.py index b7800a4..5b67306 100644 --- a/boptestGymEnv.py +++ b/boptestGymEnv.py @@ -471,11 +471,11 @@ def find_start_time(): # Initialize the building simulation res = requests.put('{0}/initialize'.format(self.url), - json={'start_time':self.start_time, - 'warmup_period':self.warmup_period}).json()['payload'] + json={'start_time':int(self.start_time), + 'warmup_period':int(self.warmup_period)}).json()['payload'] # Set simulation step - requests.put('{0}/step'.format(self.url), json={'step':self.step_period}) + requests.put('{0}/step'.format(self.url), json={'step':int(self.step_period)}) # Set BOPTEST scenario requests.put('{0}/scenario'.format(self.url), json=self.scenario) @@ -718,8 +718,8 @@ def get_observations(self, res): for var in self.regressive_vars: res_var = requests.put('{0}/results'.format(self.url), json={'point_names':[var], - 'start_time':regr_index[-1], - 'final_time':regr_index[0]}).json()['payload'] + 'start_time':int(regr_index[-1]), + 'final_time':int(regr_index[0])}).json()['payload'] # fill_value='extrapolate' is needed for the very few cases when # res_var['time'] is not returned to be exactly between # regr_index[-1] and regr_index[0] but shorter. In these cases @@ -734,8 +734,8 @@ def get_observations(self, res): if self.is_predictive: predictions = requests.put('{0}/forecast'.format(self.url), json={'point_names': self.predictive_vars, - 'horizon': self.predictive_period, - 'interval': self.step_period}).json()['payload'] + 'horizon': int(self.predictive_period), + 'interval': int(self.step_period)}).json()['payload'] for var in self.predictive_vars: for i in range(self.pred_n): observations.append(predictions[var][i])