Commit e96b0657 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸

added more testcases

parent b584e777
{
"setting": {
"forecastMethod": "NEMO",
"outletType": "POINT",
"forwardCalculation": "false",
"start": "STARTDATE",
"end": "ENDDATE",
"calculationType": "Oil classes",
"substance": "Medium oils (100-1000 cSt)",
"fresh": "false",
"winddrag": "0.00",
"outletPoints": "1",
"depth": "0",
"instantaneous": "true",
"amount": "100",
"amountUnit": "m3",
"duration": "24",
"durationUnit": "hours",
"uncertainty": "false",
"calculationMode": "Normal"
},
"coordinate": [
{
"latitude": 58.335270633241244,
"longitude": 11.390247344970703
}
],
"starthour": 3,
"startdaysadjustment": 0,
"timeperiod": 12,
"maxperiod" : 47,
"domain" : "BF_NEMO"
}
\ No newline at end of file
......@@ -25,7 +25,9 @@
"longitude": 11.390247344970703
}
],
"timeperiod": 3,
"starthour": 3,
"startdaysadjustment": 1,
"timeperiod": 12,
"maxperiod" : 47,
"domain" : "BF_NEMO"
......
{
"setting": {
"start": "STARTDATE",
"end": "ENDDATE",
"calculationMode": "Normal",
"outletType": "MULTIPOINT",
"forecastMethod": "NEMO",
"forwardCalculation": "true",
"amount": "100.0",
"amountUnit": "m3",
"calculationType": "Floating object \/ Algae",
"substance": "Floating object, file",
"fresh": "false",
"instantaneous": "true",
"outletPoints": "1",
"uncertainty": "false",
"winddrag": "1",
"depth": "0",
"duration": "",
"durationUnit": ""
},
"coordinate": [
{
"latitude": 56.41390137600676,
"longitude": 18.0615234375
}
],
"starthour": 0,
"startdaysadjustment": -2,
"timeperiod": 12,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
}
\ No newline at end of file
......@@ -25,6 +25,8 @@
"longitude": 18.0615234375
}
],
"starthour": 0,
"startdaysadjustment": 0,
"timeperiod": 3,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
......
{
"setting": {
"start": "STARTDATE",
"end": "ENDDATE",
"calculationMode": "Normal",
"outletType": "MULTIPOINT",
"forecastMethod": "NEMO",
"forwardCalculation": "true",
"amount": "100.0",
"amountUnit": "m3",
"calculationType": "Floating object \/ Algae",
"substance": "Floating object, file",
"fresh": "false",
"instantaneous": "true",
"outletPoints": "1",
"uncertainty": "false",
"winddrag": "20",
"depth": "0",
"duration": "",
"durationUnit": ""
},
"coordinate": [
{
"latitude": 55.09802,
"longitude": 14.63379
}
],
"starthour": 0,
"startdaysadjustment": 0,
"timeperiod": 12,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
}
\ No newline at end of file
{
"setting": {
"start": "STARTDATE",
"end": "ENDDATE",
"calculationMode": "Normal",
"outletType": "MULTIPOINT",
"forecastMethod": "NEMO",
"forwardCalculation": "false",
"amount": "100.0",
"amountUnit": "m3",
"calculationType": "Floating object \/ Algae",
"substance": "Floating object, file",
"fresh": "false",
"instantaneous": "true",
"outletPoints": "1",
"uncertainty": "false",
"winddrag": "2",
"depth": "0",
"duration": "",
"durationUnit": ""
},
"coordinate": [
{
"latitude": 56.41390137600676,
"longitude": 18.0615234375
}
],
"starthour": 0,
"startdaysadjustment": 2,
"timeperiod": 12,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
}
\ No newline at end of file
{
"setting": {
"forecastMethod": "NEMO",
"outletType": "AREA",
"forwardCalculation": "false",
"start": "STARTDATE",
"end": "ENDDATE",
"calculationType": "Oil classes",
"substance": "Medium oils (100-1000 cSt)",
"fresh": "false",
"winddrag": "0.00",
"outletPoints": "3",
"depth": "0",
"instantaneous": "true",
"amount": "100",
"amountUnit": "m3",
"duration": "24",
"durationUnit": "hours",
"uncertainty": "false",
"calculationMode": "Normal"
},
"coordinate": [
{
"latitude": 60.356127978060933,
"longitude": 26.961650443838113
},
{
"latitude": 60.348048724559071,
"longitude": 26.934164170849897
},
{
"latitude": 60.357731733846322,
"longitude": 26.935840154054311
},
{
"latitude": 60.362457652517769,
"longitude": 26.958385167216541
}
],
"starthour": 3,
"startdaysadjustment": 0,
"timeperiod": 12,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
}
\ No newline at end of file
......@@ -37,6 +37,8 @@
"longitude": 26.958385167216541
}
],
"starthour": 0,
"startdaysadjustment": 1,
"timeperiod": 3,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
......
{
"setting": {
"forecastMethod": "NEMO",
"outletType": "POINT",
"forwardCalculation": "false",
"start": "STARTDATE",
"end": "ENDDATE",
"calculationType": "Oil classes",
"substance": "Medium oils (100-1000 cSt)",
"fresh": "false",
"winddrag": "0.00",
"outletPoints": "1",
"depth": "0",
"instantaneous": "true",
"amount": "100",
"amountUnit": "m3",
"duration": "24",
"durationUnit": "hours",
"uncertainty": "false",
"calculationMode": "Normal"
},
"coordinate": [
{
"latitude": 55.09802,
"longitude": 14.63379
}
],
"starthour": 0,
"startdaysadjustment": 1,
"timeperiod": 12,
"maxperiod" : 200,
"domain" : "HELCOM_NEMO"
}
\ No newline at end of file
{
"setting": {
"forecastMethod": "NEMO",
"outletType": "POINT",
"forwardCalculation": "false",
"start": "STARTDATE",
"end": "ENDDATE",
"calculationType": "Oil classes",
"substance": "Medium oils (100-1000 cSt)",
"fresh": "false",
"winddrag": "0.00",
"outletPoints": "1",
"depth": "0",
"instantaneous": "true",
"amount": "100",
"amountUnit": "m3",
"duration": "24",
"durationUnit": "hours",
"uncertainty": "false",
"calculationMode": "Normal"
},
"coordinate": [
{
"latitude": 59.08009382655441,
"longitude": 13.6724853515625
}
],
"starthour": 8,
"startdaysadjustment": 0,
"timeperiod": 12,
"maxperiod" : 59,
"domain" : "VN_NEMO"
}
\ No newline at end of file
......@@ -25,6 +25,8 @@
"longitude": 13.6724853515625
}
],
"starthour": 0,
"startdaysadjustment": 0,
"timeperiod": 3,
"maxperiod" : 59,
"domain" : "VN_NEMO"
......
......@@ -34,16 +34,26 @@ class Runner(object):
rDomain = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "domain"]), data=None, json = {"domain": domain}, auth=HTTPBasicAuth(self.usr, self.pwd))
# setting
setting = jdata['setting']
setting['start'] = datetime.utcnow().strftime("%Y-%m-%d %H:%M")+':00'
end = datetime.utcnow()
end += timedelta(hours=jdata['timeperiod'])
if (output == 'run'):
start = datetime.utcnow().replace(minute=0, second=0)
else:
start = datetime.utcnow().replace(hour=0,minute=0, second=0)
start += timedelta(hours=jdata['starthour'])+timedelta(days=jdata['startdaysadjustment'])
end = start
if (timeperiod):
if (timeperiod > jdata['maxperiod']):
timeperiod = jdata['maxperiod']
end = datetime.utcnow()
end += timedelta(hours=timeperiod)
setting['end'] = end.strftime("%Y-%m-%d %H:%M")+':00'
rSetting = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "setting"]), data=None, json = jdata['setting'], auth=HTTPBasicAuth(self.usr, self.pwd))
else:
end += timedelta(hours=jdata['timeperiod'])
if (setting['forwardCalculation'] == 'true'):
setting['start'] = start.strftime("%Y-%m-%d %H:%M")+':00'
setting['end'] = end.strftime("%Y-%m-%d %H:%M")+':00'
else:
setting['start'] = end.strftime("%Y-%m-%d %H:%M")+':00'
setting['end'] = start.strftime("%Y-%m-%d %H:%M")+':00'
rSetting = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "setting"]), data=None, json = setting, auth=HTTPBasicAuth(self.usr, self.pwd))
#print(rSetting.content)
# coordinates
rCoords = requests.post('/'.join([self.url, "workarea", "v2", wid, "op", "coordinates"]), data=None, json = {"coordinate": jdata['coordinate']}, auth=HTTPBasicAuth(self.usr, self.pwd))
# run
......@@ -52,7 +62,7 @@ class Runner(object):
status = "";
start = time()
end = time()
while ((status != 'COMPLETE') and (end-start < timeout)):
while ((status != 'COMPLETE') and (status != 'ERROR') and (end-start < timeout)):
sleep(3)
try:
status = json.loads(requests.get('/'.join([self.url, "runner", "v2", wid, "progress"])).content)['status']
......@@ -85,7 +95,7 @@ class Model(Runner):
self.name,suffix = inputfile.split('.')
with open('input/'+inputfile) as file:
self.jdata = json.load(file)
def __call__(self, timeperiod = None, output = 'run', timeout = 30):
def __call__(self, timeperiod = None, output = 'run', timeout = 60):
super(Model, self).__call__(self.jdata, self.name, timeperiod, output, timeout)
def clean(self):
super(Model,self).clean();
......
No preview for this file type
......@@ -11,12 +11,15 @@ def main(method):
mlist = Models()()
if method == 'all':
for m in mlist:
m(24, 'validate', 300);
m(None, 'validate', 300);
sleep(3)
elif method == 'long':
for m in mlist:
m(200, 'validate', 300);
sleep(3)
elif method == 'one':
mlist[selected](None, 'validate', 300);
sleep(3)
else:
raise ValueError('Validation method is not defined. Try using python validate.py all')
sys.exit(0)
......@@ -30,5 +33,7 @@ if __name__ == "__main__":
method = ''
if (len(sys.argv) > 1):
method = sys.argv[1]
if (len(sys.argv) > 2):
selected = int(sys.argv[2])
main(method)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment