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

improved validation3

parent cd4e04b0
......@@ -28,8 +28,7 @@
}],
"geometryp": {
"releasetime": [1507636800000, 1507645600000],
"upperdepth": [3.0],
"lowerdepth": [3.0]
"upperdepth": [3.0]
}
},
"geometry": {
......
......@@ -13,7 +13,6 @@
"horizontalsimulation": "false"
},
"geometryp": {
"radius": 100,
"upperdepth": [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],
"lowerdepth": [4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0]
}
......
......@@ -14,8 +14,7 @@
},
"geometryp": {
"releasetime": [1507554000000, 1507556000000, 1507558000000, 1507564000000, 1507568000000, 1507574000000, 1507578000000, 1507584000000],
"upperdepth": [0.0,2.0,3.0,4.0,1.0,0.0,0.0,0.0],
"lowerdepth": [0.0,2.0,3.0,4.0,1.0,0.0,0.0,0.0]
"upperdepth": [0.0,2.0,3.0,4.0,1.0,0.0,0.0,0.0]
}
},
"geometry": {
......
cd31423c-ecc9-4c2c-86e4-42ce4f2df433 9999 Error in ShiftLoad_HD: Not enough forcing availa
\ No newline at end of file
......@@ -8,9 +8,13 @@ import errno
from os import makedirs, walk
from requests.auth import HTTPBasicAuth
from time import time, strftime, sleep
import calendar
from datetime import datetime, timedelta
from ConfigParser import SafeConfigParser
# Calls the padmws to create and run the simulation for the given input json
# writes result in output folder
class Runner(object):
def __init__(self):
settings = SafeConfigParser()
......@@ -28,13 +32,6 @@ class Runner(object):
self.timeperiod = timeperiod
self.timeout = timeout
def onError(self, error, errarea):
raise ValueError(error, errarea)
def clean(self):
requests.get('/'.join([self.url, "status", "clean"]), data=None, json = None, auth=HTTPBasicAuth(self.usr, self.pwd))
def run(self):
wid = self.createWorkarea()
self.createDomain(wid, self.jdata['domain'])
......@@ -56,7 +53,10 @@ class Runner(object):
self.runModel(wid, self.folder, self.name, self.timeout)
def validate3(self):
wid = self.createInput(self.jdata);
wid = self.createInput(self.jdata, self.timeperiod);
print wid
def test(self):
wid = self.createWorkarea()
......@@ -104,16 +104,41 @@ class Runner(object):
def createInput(self, jdata):
# create
# "startDate": 1507554000000,
# "stopDate": 1507726800000,
# "starttxt" : "201709150845",
# "stoptxt" : "201709160845",
# "starthour": 3,
# "startdaysadjustment": 0,
def createInput(self, jdata, timeperiod):
# create
simulation = jdata['features'][0]['properties']['simulation']
# Handeling start and end dates
# In priority
# Group 1 (low): starthour, startdayadjustment, maxperiod, timeperiod (maxperiod > timeperiod)
# Group 2 : starttxt, endtxt
# Group 3 (high) : startDate, endDate
start = datetime.utcnow().replace(hour=0,minute=0, second=0)
if 'starthour' in simulation and 'startdaysadjustment' in simulation:
start += timedelta(hours=simulation['starthour'])+timedelta(days=simulation['startdaysadjustment'])
end = start
if 'maxperiod' in simulation:
maxperiod = simulation['maxperiod']
delta = timedelta(hours=maxperiod)
if (timeperiod) and (timeperiod < maxperiod):
delta = timedelta(hours=timeperiod)
end += delta
else:
if 'timeperiod' in simulation:
end += timedelta(hours=simulation['timeperiod'])
if 'starttxt' in simulation and 'stoptxt' in simulation:
start = datetime.strptime(simulation['starttxt'],'%Y%m%d%H%M')
end = datetime.strptime(simulation['stoptxt'],'%Y%m%d%H%M')
if 'startDate' in simulation and 'stopDate' in simulation:
start = datetime.utcfromtimestamp(int(simulation['startDate'])/1000)
end = datetime.utcfromtimestamp(int(simulation['stopDate'])/1000)
simulation['startDate'] = long(calendar.timegm(start.timetuple())*1000)
simulation['stopDate'] = long(calendar.timegm(end.timetuple())*1000)
jdata['features'][0]['properties']['simulation'] = simulation
rCreate = requests.post('/'.join([self.url, "workarea", "v2", "create"]), data=None, json = jdata, auth=HTTPBasicAuth(self.usr, self.pwd))
if (rCreate.status_code == 401): self.onError("No access", "workarea")
wid = rCreate.headers['Location'].split('/')[-1]
......@@ -200,6 +225,14 @@ class Runner(object):
statisticsfile.write(datetime.utcnow().strftime("%Y%m%d%H%M")+' '+wid+' '+name+'\n')
return 1
def onError(self, error, errarea):
raise ValueError(error, errarea)
def clean(self):
requests.get('/'.join([self.url, "status", "clean"]), data=None, json = None, auth=HTTPBasicAuth(self.usr, self.pwd))
# Model reads its input json file given the folder and executes the runner method
class Model(Runner):
def __init__(self, inputfile):
super(Model, self).__init__()
......@@ -225,6 +258,7 @@ class Model(Runner):
def clean(self):
super(Model,self).clean();
# Container. Reads on input json filename given a input folder
class Models(object):
def __init__(self, input = 'run'):
......
No preview for this file type
......@@ -9,25 +9,25 @@ from os import walk
def main(method):
try:
mlist = Models("validate3")()
mlist = Models('validate3')()
if method == 'all':
for m in mlist:
m(None, 'validate', 300);
m(None, 300);
sleep(3)
elif method == 'long':
for m in mlist:
m(200, 'validate', 300);
m(200, 300);
sleep(3)
elif method == 'select':
mlist[selected-1](None, 'validate', 300);
mlist[selected-1](None, 300);
else:
raise ValueError('Validation method is not defined. Try using python validate.py all')
raise ValueError('Validation method is not defined. Try using python validate3.py select <number>')
sys.exit(0)
except Exception as error:
print error
sys.exit(1)
'''
To run in terminal call with python validate.py all
To run in terminal call with python validate3.py select <number>
'''
if __name__ == "__main__":
method = ''
......
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