njayaram2 commented on a change in pull request #430: Add generate mst table
utility.
URL: https://github.com/apache/madlib/pull/430#discussion_r312184863
##########
File path:
src/ports/postgres/modules/deep_learning/madlib_keras_validator.py_in
##########
@@ -309,3 +311,72 @@ class FitInputValidator:
self.validation_table, self.independent_varname,
input_shape, 2)
+
+
+class GenerateMstInputValidator():
+ def __init__(self,
+ model_selection_table,
+ model_arch_table,
+ model_arch_id_list,
+ compile_params_list,
+ fit_params_list
+ ):
+ self.model_arch_table = model_arch_table
+ self.model_selection_table = model_selection_table
+ self.model_arch_id_list = model_arch_id_list
+ self.compile_params_list = compile_params_list
+ self.fit_params_list = fit_params_list
+ self.module_name = 'madlib_keras_generate_mst_table'
+ self._validate_input_args()
+
+ def _validate_input_args(self):
+ self._valid_input_output_tables()
+ self._valid_model_arch_ids()
+ self._valid_compile_and_fit_params()
+
+ def _valid_model_arch_ids(self):
+ model_arch_id_str = \
+ '(' + \
+ ','.join([str(x) for x in self.model_arch_id_list]) + \
+ ')'
+ query = """
+ SELECT count(model_id)
+ FROM {self.model_arch_table}
+ WHERE model_id IN {model_arch_id_str}
+ """.format(**locals())
+ res = int(plpy.execute(query)[0]['count'])
+ _assert(
+ res == len(self.model_arch_id_list),
+ "{0}: One or more model_id of {1} not found in table {2}".format(
+ self.module_name,
+ model_arch_id_str,
+ self.model_arch_table
+ )
+ )
+ def _valid_compile_and_fit_params(self):
+ for fit_params in self.fit_params_list:
+ try:
+ res = parse_and_validate_fit_params(fit_params)
+ except Exception as e:
+ plpy.error(
+ """Fit param check failed for: {} \n
+ {}
+ """.format(fit_params, str(e)))
+ for compile_params in self.compile_params_list:
+ try:
+ res = parse_and_validate_compile_params(compile_params)
+ except Exception as e:
+ plpy.error(
+ """Compile param check failed for: {} \n
+ {}
+ """.format(compile_params, str(e)))
+
+
+ def _valid_input_output_tables(self):
+ input_tbl_valid(self.model_arch_table, self.module_name)
+ output_tbl_valid(self.model_selection_table, self.module_name)
+
+
+
+
+
Review comment:
Keeping one empty line at the end of the file should suffice.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services