Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #17 from sogno-platform/feature/better-powerflow-test
Browse files Browse the repository at this point in the history
Update powerflow test script
  • Loading branch information
wquentind authored Nov 9, 2023
2 parents 1ce3903 + 25f613a commit d65ce1e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions test/powerflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ class FileInfo:
url: str


def transfer_to_fileservice(url):
resp = requests.get(url)
resp.raise_for_status()
file_data = resp.content
def transfer_to_fileservice(url: str):
if url.startswith('http'):
resp = requests.get(url)
resp.raise_for_status()
file_data = resp.content
else:
with open(url, 'rb') as file:
file_data = file.read()
resp = requests.post(f'{FILESERVICE_URL}/files/', data=file_data)
resp.raise_for_status()
info = FileInfo(**resp.json()["data"])
Expand Down Expand Up @@ -50,11 +54,13 @@ def start_powerflow(input_data):
},
"system_frequency": 50.0, # Hz
},
"symmetric": True,
"error_tolerance": 1e-8,
"max_iterations": 20,
"calculation_method": "newton_raphson",
# "output_component_types": [],
"calculation_args": {
"symmetric": True,
"error_tolerance": 1e-8,
"max_iterations": 20,
"calculation_method": "newton_raphson",
# "output_component_types": [],
}
}
resp = requests.post(f"{PGM_URL}/api/pgm_powerflow", json=powerflow_args)
resp.raise_for_status()
Expand Down

0 comments on commit d65ce1e

Please sign in to comment.