Skip to content

Commit 5c0766d

Browse files
author
weilixu
committed
update model
1 parent 593118b commit 5c0766d

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

0 Bytes
Binary file not shown.
426 Bytes
Binary file not shown.

BuildSimHubAPI/helpers/simulationJob.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ def run_simulation(self, simulationType = "regular", agent=1):
8989
else:
9090
return resp_json['error_msg']
9191

92-
93-
def create_model(self, file_dir, comment = "Upload through Python API", simulationType ="", agent = 0):
92+
def create_run_model(self, file_dir, comment = "Upload through Python API", simulationType ="regular", agent = 1):
9493
url = SimulationJob.BASE_URL + 'CreateModel_API'
9594
payload = {
9695
'user_api_key': self._userKey,
@@ -99,6 +98,28 @@ def create_model(self, file_dir, comment = "Upload through Python API", simulati
9998
'simulation_type': simulationType,
10099
'agents' : agent
101100
}
101+
files = {
102+
'file': open(file_dir, 'rb')
103+
}
104+
105+
r= requests.post(url, data=payload, files = files)
106+
resp_json = r.json()
107+
108+
if(resp_json['status'] == 'success'):
109+
self._trackToken = resp_json['tracking']
110+
return resp_json['status']
111+
else:
112+
return resp_json['error_msg']
113+
114+
def create_model(self, file_dir, comment = "Upload through Python API"):
115+
url = SimulationJob.BASE_URL + 'CreateModel_API'
116+
payload = {
117+
'user_api_key': self._userKey,
118+
'folder_api_key': self._modelKey,
119+
'comment': comment,
120+
'simulation_type': '',
121+
'agents' : 1
122+
}
102123

103124
files={
104125
'file': open(file_dir, 'rb')

test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
#2. define the absolute directory of your energy model
1010
file_dir = "/Users/weilixu/Desktop/5ZoneAirCooled.idf"
1111
#3. this is optional
12-
comment = "new upload 2"
13-
#4. simulation Type. this is optional
14-
st = bsh.get_simulation_type()
15-
st.set_regular()
1612

1713
newSj = bsh.new_simulation_job(model_key)
1814
#5. start the API call
1915
# note if fast simulation, call increaseAgents to increase the agent numbers
20-
response = newSj.create_model(file_dir, comment, st.type, st.agent)
16+
response = newSj.create_run_model(file_dir)
2117
if(response == 'success'):
2218
while newSj.track_simulation():
2319
print (newSj.trackStatus)

0 commit comments

Comments
 (0)