Skip to content

Commit

Permalink
feat: add method to check progress of ongoing simulation (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenhagg authored Feb 2, 2021
1 parent 77d963f commit b8d1445
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions powersimdata/scenario/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ def launch_simulation(self, threads=None, extract_data=True):
return self._launch_on_server(threads, extract_data)
return self._launch_in_container(threads)

def check_progress(self):
"""Get the lastest information from the server container
:raises NotImplementedError: if not running in container mode
"""
mode = get_deployment_mode()
if mode != DeploymentMode.Container:
raise NotImplementedError("Operation only supported for container mode")

scenario_id = self._scenario_info["id"]
url = f"http://{server_setup.SERVER_ADDRESS}:5000/status/{scenario_id}"
resp = requests.get(url)
return resp.json()

def extract_simulation_output(self):
"""Extracts simulation outputs {PG, PF, LMP, CONGU, CONGL} on server.
Expand All @@ -249,6 +263,11 @@ def extract_simulation_output(self):
"""
self._update_scenario_status()
if self._scenario_status == "finished":
mode = get_deployment_mode()
if mode == DeploymentMode.Container:
print("WARNING: extraction not yet supported, please extract manually")
return

print("--> Extracting output data on server")
return self._run_script("extract_data.py")
else:
Expand Down

0 comments on commit b8d1445

Please sign in to comment.