Skip to content

Commit

Permalink
Ensure all objects sent to requests are json serializable using int.
Browse files Browse the repository at this point in the history
  • Loading branch information
javiarrobas committed Nov 10, 2023
1 parent 1a89349 commit 7f5b64f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions boptestGymEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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])
Expand Down

1 comment on commit 7f5b64f

@kirachid
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good evening Javiar
I hope you are well
please help me
i'm interested in the BOPTEST/project1 project especially bestest_hydronic_heat_pump
i have a problem to check that the module boptestGymEnv is correctly installed in your Python environment

Please sign in to comment.