Skip to content

Commit

Permalink
Merge pull request watertap-org#18 from dangunter/main
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
dangunter authored Jun 26, 2022
2 parents 92cf052 + 2177ae0 commit 049063f
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions backend/app/internal/flowsheet/flowsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,25 @@ def update(self, flowsheet_config):
return self.flowsheet_interface_json

def solve(self):
results = {'id': self.id}
output = self.flowsheet_interface.run_action(WorkflowActions.solve)
# If solve returns nothing, there was nothing to do - so use previous value
# XXX: It would be even more efficient to simply return an empty value
# XXX: to the front-end and let it use this same logic.
if output is None:
output = self._cached_output
output_dict = self.flowsheet_interface.run_action(WorkflowActions.solve)
if output_dict is None:
output_dict = self._cached_output
else:
self._cached_output = output
results['output'] = output
# self.flowsheet_interface._action_clear_was_run(WorkflowActions.solve)
results['input'] = self.flowsheet_interface.dict()
self.flowsheet_interface_json = self.flowsheet_interface.dict()
# save result for the future
self._cached_output = output_dict
input_dict = self.flowsheet_interface.dict()

self.flowsheet_interface_json = input_dict
self._save_flowsheet()

results = dict(input=input_dict, output=output_dict, id=self.id)
with open(self.solve_path, 'w') as f:
json.dump(results, f, indent=4)
return results

return results

def reset(self):
self.flowsheet_interface.clear_action(WorkflowActions.build)
Expand Down

0 comments on commit 049063f

Please sign in to comment.