diff --git a/data/get_html_IO.py b/data/get_html_IO.py
index 8d966fd42..47a3b3afb 100644
--- a/data/get_html_IO.py
+++ b/data/get_html_IO.py
@@ -3,9 +3,9 @@
This script can be used to generate the html documentation code for I/O.
To run:
-1. Build BOPTEST test case
-2. Run BOPTEST test case on localhost:5000
-3. Run this script
+1. Build BOPTEST worker provision
+2. Run BOPTEST worker provision
+3. Run this script with test case as string input argument (i.e. "bestest_air")
Output:
"inputs_measurements_forecasts.html" html code documenting inputs, outputs and
@@ -15,10 +15,11 @@
# GENERAL PACKAGE IMPORT
# ----------------------
import requests
+import sys
# ----------------------
-def run():
+def run(test_case_name):
'''Run the script.
Parameters
@@ -33,20 +34,24 @@ def run():
# SETUP TEST CASE
# ---------------
- # Set URL for testcase
- url = 'http://127.0.0.1:5000'
+ # Set URL for test case
+ url = 'http://127.0.0.1:80'
+ # Deploy worker container and obtain test case ID
+ testid = requests.post("{0}/testcases/{1}/select".format(url, test_case_name)).json()["testid"]
# ---------------
-
+
# GET TEST INFORMATION
# --------------------
# Create single I/O file
# Inputs available
- inputs = requests.get('{0}/inputs'.format(url)).json()['payload']
+ print('\nGetting available inputs...')
+ inputs = requests.get('{0}/inputs/{1}'.format(url,testid)).json()['payload']
with open('inputs_measurements_forecasts.html', 'w') as f:
f.write('
Model IO\'s
\n')
f.write('Inputs
\n')
f.write('The model inputs are:\n')
f.write('\n')
+ print('\nWriting inputs to inputs_measurements_forecasts.html...')
for i in sorted(inputs.keys()):
if 'activate' not in i:
f.write('- \n
{0}
[{1}] [min={2}, max={3}]: {4}\n \n'.format(i,inputs[i]['Unit'],inputs[i]['Minimum'], inputs[i]['Maximum'], inputs[i]['Description']))
@@ -54,26 +59,39 @@ def run():
f.write('- \n
{0}
[1] [min=0, max=1]: Activation signal to overwrite input {1} where 1 activates, 0 deactivates (default value)\n \n'.format(i,i.replace('activate','')+'u'))
f.write('
\n')
# Measurements available
- measurements = requests.get('{0}/measurements'.format(url)).json()['payload']
+ print('\nGetting available measurements...')
+ measurements = requests.get('{0}/measurements/{1}'.format(url,testid)).json()['payload']
with open('inputs_measurements_forecasts.html', 'a') as f:
f.write('Outputs
\n')
f.write('The model outputs are:\n')
f.write('\n')
+ print('\nWriting measurements to inputs_measurements_forecasts.html...')
for i in sorted(measurements.keys()):
if 'activate' not in i:
f.write('- \n
{0}
[{1}] [min={2}, max={3}]: {4}\n \n'.format(i,measurements[i]['Unit'],measurements[i]['Minimum'], measurements[i]['Maximum'], measurements[i]['Description']))
f.write('
\n')
# Forecasts available
- forecast_points = requests.get('{0}/forecast_points'.format(url)).json()['payload']
+ print('\nGetting available forecasts...')
+ forecast_points = requests.get('{0}/forecast_points/{1}'.format(url,testid)).json()['payload']
with open('inputs_measurements_forecasts.html', 'a') as f:
f.write('Forecasts
\n')
f.write('The model forecasts are:\n')
f.write('\n')
+ print('\nWriting forecasts to inputs_measurements_forecasts.html...')
for i in sorted(forecast_points.keys()):
if 'activate' not in i:
f.write('- \n
{0}
[{1}]: {2}\n \n'.format(i,forecast_points[i]['Unit'],forecast_points[i]['Description']))
f.write('
\n')
# --------------------
-
+ # SHUT DOWN TEST CASE
+ # -------------------------------------------------------------------------
+ print('\nShutting down test case...')
+ res = requests.put("{0}/stop/{1}".format(url,testid))
+ if res.status_code == 200:
+ print('Done shutting down test case.')
+ else:
+ print('Error shutting down test case.')
+
if __name__ == "__main__":
- run()
+ test_case_name = sys.argv[1]
+ run(test_case_name)