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):
dTypes_in_value = list(set([type(i) for i in value]))
assert len(dTypes_in_value) == 1, \
'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])
pgV = "'{%s}'" % pgList
return pgV
......
......@@ -155,6 +155,9 @@ class JobConfig(object):
self.ID = ID
self.kwargs = user_opts
# input validation
self.validate_exec_configs()
# database connection
self.db_host = user_opts['db_host']
self.conn_database = get_conn_database(hostname=self.db_host)
......@@ -391,7 +394,6 @@ class JobConfig(object):
# validate #
############
self.validate_exec_configs()
GMSValidator(allow_unknown=True, schema=gms_schema_config_output).validate(self.to_dict())
@property
......@@ -619,20 +621,29 @@ class JobConfig(object):
def validate_exec_configs(self):
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
if not all([len(exec_lvl) == 3,
(np.array(exec_lvl) == np.array(np.array(exec_lvl, np.bool), np.int)).all()]):
raise ValueError('Execution mode must be provided as list of 3 elements containing only boolean '
'values. Got %s for %s.' % (exec_lvl, i))
if all([len(exec_lvl) == 3, (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 exec_lvl[1] == 0:
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)
exec_lvl[1] = 1
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 '
'values. Got %s for %s.' % (exec_lvl, i))
def to_dict(self):
opts_default = get_options(path_options_default)
......
......@@ -285,8 +285,10 @@ summary_testResults, summary_errors, summary_failures, summary_skipped, jobstatu
@unittest.SkipTest
class Test_in_normal_mode(unittest.TestCase):
def setUp(self):
# Testjob Landsat-8
self.PC = process_controller(26186740, **dict(is_test=False, parallelization_level='scenes', db_host='geoms',
# self.job_id = 26186740 # Testjob Landsat-8
self.job_id = 26186906 # Bug Input Validator
self.PC = process_controller(self.job_id, **dict(is_test=False, parallelization_level='scenes', db_host='geoms',
delete_old_output=True,))
def test(self):
......
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