Modify error info
This commit is contained in:
parent
e54c810c54
commit
cbcaf9b156
|
@ -63,7 +63,7 @@ class ExceptionThread(threading.Thread):
|
||||||
self.exception = e
|
self.exception = e
|
||||||
self.exc_traceback = ''.join(traceback.format_exception(*sys.exc_info()))
|
self.exc_traceback = ''.join(traceback.format_exception(*sys.exc_info()))
|
||||||
|
|
||||||
def check_filename(path):
|
def check_filename(path, arg_name=""):
|
||||||
"""
|
"""
|
||||||
check the filename in the path.
|
check the filename in the path.
|
||||||
|
|
||||||
|
@ -77,8 +77,12 @@ def check_filename(path):
|
||||||
Returns:
|
Returns:
|
||||||
Bool, whether filename is valid.
|
Bool, whether filename is valid.
|
||||||
"""
|
"""
|
||||||
|
if arg_name == "":
|
||||||
|
arg_name = "File path"
|
||||||
|
else:
|
||||||
|
arg_name = "'{}'".format(arg_name)
|
||||||
if not path:
|
if not path:
|
||||||
raise ParamValueError('File path is not allowed None or empty!')
|
raise ParamValueError('{} is not allowed None or empty!'.format(arg_name))
|
||||||
if not isinstance(path, str):
|
if not isinstance(path, str):
|
||||||
raise ParamValueError("File path: {} is not string.".format(path))
|
raise ParamValueError("File path: {} is not string.".format(path))
|
||||||
if path.endswith("/"):
|
if path.endswith("/"):
|
||||||
|
@ -113,7 +117,7 @@ def populate_data(raw, blob, columns, blob_fields, schema):
|
||||||
MRMUnsupportedSchemaError: If schema is invalid.
|
MRMUnsupportedSchemaError: If schema is invalid.
|
||||||
"""
|
"""
|
||||||
if raw:
|
if raw:
|
||||||
# remove dummy fileds
|
# remove dummy fields
|
||||||
raw = {k: v for k, v in raw.items() if k in schema}
|
raw = {k: v for k, v in raw.items() if k in schema}
|
||||||
else:
|
else:
|
||||||
raw = {}
|
raw = {}
|
||||||
|
|
|
@ -136,6 +136,9 @@ class TFRecordToMR:
|
||||||
else:
|
else:
|
||||||
if len(val.shape) != 1:
|
if len(val.shape) != 1:
|
||||||
raise ValueError("Parameter len(feature_dict[{}].shape) should be 1.")
|
raise ValueError("Parameter len(feature_dict[{}].shape) should be 1.")
|
||||||
|
if not isinstance(val.shape[0], int):
|
||||||
|
raise ValueError("Invalid parameter feature_dict, value and type mismatch, " +
|
||||||
|
"please check item of feature_dict[\"{}\"].".format(key))
|
||||||
if val.shape[0] < 1:
|
if val.shape[0] < 1:
|
||||||
raise ValueError("Parameter feature_dict[{}].shape[0] should > 0".format(key))
|
raise ValueError("Parameter feature_dict[{}].shape[0] should > 0".format(key))
|
||||||
if val.dtype == self.tf.string:
|
if val.dtype == self.tf.string:
|
||||||
|
@ -149,11 +152,11 @@ class TFRecordToMR:
|
||||||
"""Validation check for inputs of init method"""
|
"""Validation check for inputs of init method"""
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
raise ValueError("Parameter source must be string.")
|
raise ValueError("Parameter source must be string.")
|
||||||
check_filename(source)
|
check_filename(source, "source")
|
||||||
|
|
||||||
if not isinstance(destination, str):
|
if not isinstance(destination, str):
|
||||||
raise ValueError("Parameter destination must be string.")
|
raise ValueError("Parameter destination must be string.")
|
||||||
check_filename(destination)
|
check_filename(destination, "destination")
|
||||||
|
|
||||||
if feature_dict is None or not isinstance(feature_dict, dict):
|
if feature_dict is None or not isinstance(feature_dict, dict):
|
||||||
raise ValueError("Parameter feature_dict is None or not dict.")
|
raise ValueError("Parameter feature_dict is None or not dict.")
|
||||||
|
|
Loading…
Reference in New Issue