Commit 7d79a122 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Fixed validate_exec_configs.


Former-commit-id: ca7b25ee
parent bc587df1
...@@ -98,7 +98,7 @@ def get_postgreSQL_value(value): ...@@ -98,7 +98,7 @@ def get_postgreSQL_value(value):
dTypes_in_value = list(set([type(i) for i in value])) dTypes_in_value = list(set([type(i) for i in value]))
assert len(dTypes_in_value) == 1, \ assert len(dTypes_in_value) == 1, \
'Mixed data types in postgreSQL matching expressions are not supported. Got %s.' % dTypes_in_value 'Mixed data types in postgreSQL matching expressions are not supported. Got %s.' % dTypes_in_value
assert dTypes_in_value[0] in [int, str, float, np.int64] assert dTypes_in_value[0] in [int, str, float, np.int64, bool]
pgList = ",".join(["'%s'" % i if isinstance(value[0], str) else "%s" % i for i in value]) pgList = ",".join(["'%s'" % i if isinstance(value[0], str) else "%s" % i for i in value])
pgV = "'{%s}'" % pgList pgV = "'{%s}'" % pgList
return pgV return pgV
......
...@@ -155,6 +155,9 @@ class JobConfig(object): ...@@ -155,6 +155,9 @@ class JobConfig(object):
self.ID = ID self.ID = ID
self.kwargs = user_opts self.kwargs = user_opts
# input validation
self.validate_exec_configs()
# database connection # database connection
self.db_host = user_opts['db_host'] self.db_host = user_opts['db_host']
self.conn_database = get_conn_database(hostname=self.db_host) self.conn_database = get_conn_database(hostname=self.db_host)
...@@ -391,7 +394,6 @@ class JobConfig(object): ...@@ -391,7 +394,6 @@ class JobConfig(object):
# validate # # validate #
############ ############
self.validate_exec_configs()
GMSValidator(allow_unknown=True, schema=gms_schema_config_output).validate(self.to_dict()) GMSValidator(allow_unknown=True, schema=gms_schema_config_output).validate(self.to_dict())
@property @property
...@@ -619,21 +621,30 @@ class JobConfig(object): ...@@ -619,21 +621,30 @@ class JobConfig(object):
def validate_exec_configs(self): def validate_exec_configs(self):
for i in ['L1AP', 'L1BP', 'L1CP', 'L2AP', 'L2BP', 'L2CP']: for i in ['L1AP', 'L1BP', 'L1CP', 'L2AP', 'L2BP', 'L2CP']:
exec_lvl = getattr(self, 'exec_%s' % i) try:
exec_lvl = self.kwargs['exec_%s' % i]
except KeyError:
continue
if exec_lvl is None:
continue
# check input format # check input format
if not all([len(exec_lvl) == 3, if all([len(exec_lvl) == 3, (np.array(exec_lvl) == np.array(np.array(exec_lvl, np.bool), np.int)).all()]):
(np.array(exec_lvl) == np.array(np.array(exec_lvl, np.bool), np.int)).all()]): execute, write, delete = exec_lvl
# written output cannot be turned off in execution mode 'Python'
if self.exec_mode == 'Python' and execute and not write:
warnings.warn("If job.exec_mode is set to 'Python' the output writer for %s has to be enabled "
"because any operations on GMS_obj.arr read the intermediate results from disk. "
"Turning it on.." % i)
write = True
self.kwargs['exec_%s' % i] = [execute, write, delete]
else:
raise ValueError('Execution mode must be provided as list of 3 elements containing only boolean ' raise ValueError('Execution mode must be provided as list of 3 elements containing only boolean '
'values. Got %s for %s.' % (exec_lvl, i)) 'values. Got %s for %s.' % (exec_lvl, i))
# written output cannot be turned off in execution mode 'Python'
if self.exec_mode == 'Python' and exec_lvl[1] == 0:
warnings.warn("If job.exec_mode is set to 'Python' the output writer for %s has to be enabled "
"because any operations on GMS_obj.arr read the intermediate results from disk. "
"Turning it on.." % i)
exec_lvl[1] = 1
def to_dict(self): def to_dict(self):
opts_default = get_options(path_options_default) opts_default = get_options(path_options_default)
......
...@@ -285,9 +285,11 @@ summary_testResults, summary_errors, summary_failures, summary_skipped, jobstatu ...@@ -285,9 +285,11 @@ summary_testResults, summary_errors, summary_failures, summary_skipped, jobstatu
@unittest.SkipTest @unittest.SkipTest
class Test_in_normal_mode(unittest.TestCase): class Test_in_normal_mode(unittest.TestCase):
def setUp(self): def setUp(self):
# Testjob Landsat-8 # self.job_id = 26186740 # Testjob Landsat-8
self.PC = process_controller(26186740, **dict(is_test=False, parallelization_level='scenes', db_host='geoms', self.job_id = 26186906 # Bug Input Validator
delete_old_output=True,))
self.PC = process_controller(self.job_id, **dict(is_test=False, parallelization_level='scenes', db_host='geoms',
delete_old_output=True,))
def test(self): def test(self):
self.PC.run_all_processors() self.PC.run_all_processors()
......
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