Skip to content

Commit 88ab67e

Browse files
authored
Revert "Hot Fix: ASHP defaults updating from REopt.jl"
1 parent 4b08836 commit 88ab67e

File tree

3 files changed

+1
-79
lines changed

3 files changed

+1
-79
lines changed

reoptjl/src/process_results.py

-12
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ def update_inputs_in_database(inputs_to_update: dict, run_uuid: str) -> None:
141141
else:
142142
ExistingChillerInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["ExistingChiller"])
143143
if inputs_to_update["ASHPSpaceHeater"]:
144-
prune_update_fields(ASHPSpaceHeaterInputs, inputs_to_update["ASHPSpaceHeater"])
145144
ASHPSpaceHeaterInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["ASHPSpaceHeater"])
146145
if inputs_to_update["ASHPWaterHeater"]:
147-
prune_update_fields(ASHPWaterHeaterInputs, inputs_to_update["ASHPWaterHeater"])
148146
ASHPWaterHeaterInputs.objects.filter(meta__run_uuid=run_uuid).update(**inputs_to_update["ASHPWaterHeater"])
149147
except Exception as e:
150148
exc_type, exc_value, exc_traceback = sys.exc_info()
@@ -154,13 +152,3 @@ def update_inputs_in_database(inputs_to_update: dict, run_uuid: str) -> None:
154152
tb.format_tb(exc_traceback)
155153
)
156154
log.debug(debug_msg)
157-
158-
def prune_update_fields(model_obj, dict_to_update):
159-
"""
160-
REopt.jl may return more fields than the API has to update, so prune those extra ones before updating the model/db object
161-
"""
162-
field_names = [field.name for field in model_obj._meta.get_fields()]
163-
dict_to_update_keys = list(dict_to_update.keys())
164-
for key in dict_to_update_keys:
165-
if key not in field_names:
166-
del dict_to_update[key]

reoptjl/test/posts/ashp_defaults_update.json

-51
This file was deleted.

reoptjl/test/test_job_endpoint.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,4 @@ def test_centralghp(self):
311311
resp = self.api_client.get(f'/v3/job/{run_uuid}/results')
312312
r = json.loads(resp.content)
313313

314-
self.assertAlmostEqual(r["outputs"]["Financial"]["lifecycle_capital_costs"], 1046066.8, delta=1000)
315-
316-
def test_ashp_defaults_update_from_julia(self):
317-
# Test that the inputs_with_defaults_set_in_julia feature worked for ASHPSpaceHeater
318-
post_file = os.path.join('reoptjl', 'test', 'posts', 'ashp_defaults_update.json')
319-
post = json.load(open(post_file, 'r'))
320-
resp = self.api_client.post('/stable/job/', format='json', data=post)
321-
self.assertHttpCreated(resp)
322-
r = json.loads(resp.content)
323-
run_uuid = r.get('run_uuid')
324-
325-
resp = self.api_client.get(f'/stable/job/{run_uuid}/results')
326-
r = json.loads(resp.content)
327-
328-
self.assertEquals(r["inputs"]["ASHPSpaceHeater"]["om_cost_per_ton"], 0.0)
329-
self.assertEquals(r["inputs"]["ASHPSpaceHeater"]["sizing_factor"], 1.1)
314+
self.assertAlmostEqual(r["outputs"]["Financial"]["lifecycle_capital_costs"], 1046066.8, delta=1000)

0 commit comments

Comments
 (0)