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') # 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') # 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') # -------------------- - + # 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)