Skip to content

Commit

Permalink
vdk-core: remove redundant logs
Browse files Browse the repository at this point in the history
Why

As part of the run logs initiative, we should audit all log statements
and error messages in vdk-core and make sure there aren't any redundancies,
e.g. overly verbose messages or messages that don't add value.

What

Remove

MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE
MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION
MSG_CONSEQUENCE_TERMINATING_APP

where possible

Re-word log statements and exception messages that are too verbose

How was this tested?

CI

What kind of change is this?

Feature/non-breaking

Signed-off-by: Dilyan Marinov <[email protected]>
  • Loading branch information
Dilyan Marinov authored and DeltaMichael committed Oct 31, 2023
1 parent 6c4a89f commit 67523b5
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def _parse_log_level_module(log_level_module):
errors.VdkConfigurationError(
"Invalid logging configuration passed to LOG_LEVEL_MODULE.",
f"Error is: {e}. log_level_module was set to {log_level_module}.",
"Logging will not be initialized and exception is raised",
"Set correctly configuration to log_level_debug configuration in format 'module=level;module2=level2'",
)
)
Expand Down Expand Up @@ -148,7 +147,6 @@ def configure_loggers(
errors.VdkConfigurationError(
f"Provided configuration variable for {SYSLOG_SOCK_TYPE} has invalid value.",
f"VDK was run with {SYSLOG_SOCK_TYPE}={syslog_sock_type}, however {syslog_sock_type} is invalid value for this variable.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
f"Provide a valid value for {SYSLOG_SOCK_TYPE}."
f"Currently possible values are {list(SYSLOG_SOCK_TYPE_VALUES_DICT.keys())}",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def open_connection(self, dbtype: str) -> ManagedConnectionBase:
errors.VdkConfigurationError(
f"Provided configuration variable for {DB_DEFAULT_TYPE} has invalid value.",
f"VDK was run with {DB_DEFAULT_TYPE}={dbtype}, however {dbtype} is invalid value for this variable.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
f"Provide either valid value for {DB_DEFAULT_TYPE} or install database plugin that supports this type. "
f"Currently possible values are {list(self._connection_builders.keys())}",
)
Expand Down Expand Up @@ -125,7 +124,6 @@ def __create_connection(self, dbtype: str):
errors.VdkConfigurationError(
f"Could not create new connection of db type {dbtype}.",
f"VDK was run with {DB_DEFAULT_TYPE}={dbtype}, however no valid connection was created.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
f"Seems to be a bug in the plugin for dbtype {dbtype}. Make sure it's correctly installed. "
f"If upgraded recently consider reverting to previous version. Or use another db type. "
f"Currently possible values are {list(self._connection_builders.keys())}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def execute_query(self, query: str) -> List[List[Any]]:
[
"Fetching all results from query FAILED.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION,
]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ def execute(
[
"Executing query FAILED.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION,
]
)
)
Expand All @@ -142,8 +140,6 @@ def _decorate_operation(self, managed_operation: ManagedOperation, operation: st
[
"Decorating query FAILED.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION,
]
)
)
Expand All @@ -162,8 +158,6 @@ def _validate_operation(self, operation: str, parameters: Optional[Container]):
[
"Validating query FAILED.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION,
]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def __get_ingester(self, method: str) -> IngesterBase:
VdkConfigurationError(
"Provided method, {method}, has invalid value.",
"VDK was run with method={method}, however {method} is not part of the available ingestion mechanisms.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
f"Provide either valid value for method, or install ingestion plugin that supports this type. "
f"Currently possible values are {list(self._ingester_builders.keys())}",
)
Expand Down Expand Up @@ -177,7 +176,6 @@ def __initialize_ingester(self, method) -> IngesterBase:
VdkConfigurationError(
f"Could not create new ingester plugin of type {method}.",
f"VDK was run with method={method}, however no valid ingester plugin was created.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
f"Seems to be a bug in the plugin for method {method}. Make sure it's correctly installed. "
f"If upgraded recently consider reverting to previous version. Or use another method type.",
)
Expand Down Expand Up @@ -223,7 +221,6 @@ def __initialize_processor(self, method) -> Optional[IIngesterPlugin]:
f"VDK was run with method={method}, however "
"no valid ingestion processor plugin was "
"created.",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
"Seems to be a bug in the plugin for method"
f" {method}. Make sure it's correctly "
f"installed. If upgraded recently, consider"
Expand Down Expand Up @@ -257,9 +254,6 @@ def close(self):
f"On close some following ingest queues types reported errors: {list(errors_list.keys())}.",
f"There were errors while closing ingestion. Exceptions were: {errors_list}.",
"Some data was partially ingested or not ingested at all.",
"Follow the instructions in the error messages and log warnings. "
"Make sure to inspect any errors or warning logs generated"
"Re-try the job if necessary",
]

if any(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def __choose_from_default_type(self, properties_type: str):
errors.VdkConfigurationError(
f"properties default type was configured to be {properties_type} "
f"no such properties api implementation has been registered",
f"",
f"Check if the job has not been mis-configured - for example misspelling error. "
f"See config-help for help on configuration. Existing properties types are: {list(self.__properties_builders.keys())} "
f"Alternatively make sure the correct plugin has been installed "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __choose_from_default_type(self, secrets_type: str):
errors.VdkConfigurationError(
f"secrets default type was configured to be {secrets_type} "
"no such secrets api implementation has been registered",
"",
"Check if the job has not been mis-configured - for example misspelling error. "
f"See config-help for help on configuration. Existing secrets types are: {list(self.__secrets_builders.keys())} "
"Alternatively make sure the correct plugin has been installed "
Expand Down
18 changes: 8 additions & 10 deletions projects/vdk-core/src/vdk/internal/builtin_plugins/run/cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ def __validate_and_parse_args(arguments: str) -> Optional[Dict]:
[
"Failed to validate job arguments.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_TERMINATING_APP,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION,
]
)
)
Expand Down Expand Up @@ -104,14 +102,16 @@ def __warn_on_python_version_disparity(
log.warning(
f"""
{os.linesep + (' ' * 20) + ('*' * 80)}
What: Python version mismatch between local python and configure python.
Why: The Python version specified in the job's config.ini file is ({configured_python_version})
Python version mismatch between local python and configure python.
The Python version specified in the job's config.ini file is ({configured_python_version})
while the local python version used to execute the data job is ({local_py_version}).
Consequences: Developing a data job using one Python version and deploying
Developing a data job using one Python version and deploying
it with a different version can result in unexpected and
difficult-to-troubleshoot errors like module incompatibilities, or
unexpected behavior during execution.
Countermeasures: To resolve this issue, ensure that the Python version
To resolve this issue, ensure that the Python version
specified in the python_version property of the config.ini file matches
the Python version of your execution environment by either editing the
python_version property in config.ini, or switching local environment
Expand Down Expand Up @@ -165,10 +165,8 @@ def create_and_run_data_job(
[
"Failed executing job.",
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_TERMINATING_APP,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION
+ " Most likely a prerequisite or plugin of one of the key VDK components failed, see"
+ " logs for details and ensure the prerequisite for the failed component (details in stacktrace).",
" Most likely a prerequisite or plugin of one of the key VDK components failed, see"
+ " logs for details and ensure the prerequisite for the failed component.",
]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ def run_job(context: JobContext) -> ExecutionResult:
errors.UserCodeError(
"Data Job execution has failed.",
"Data Job has no steps.",
"Data job execution will not continue.",
"Please include at least 1 valid step in your Data Job. Also make sure you are passing the correct data job directory.",
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ def run(job_input)
[
"Failed loading job sources of %s" % filename,
errors.MSG_WHY_FROM_EXCEPTION(e),
errors.MSG_CONSEQUENCE_TERMINATING_APP,
errors.MSG_COUNTERMEASURE_FIX_PARENT_EXCEPTION
+ " Most likely importing a dependency or data job step failed, see"
+ " logs for details and fix the failed step (details in stacktrace).",
" Most likely importing a dependency or data job step failed, see"
+ " logs for details and fix the failed step.",
]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def get_template_directory(self, name: str) -> pathlib.Path:
errors.UserCodeError(
f"No registered template with name: {name}.",
"Template with that name has not been registered",
errors.MSG_CONSEQUENCE_DELEGATING_TO_CALLER__LIKELY_EXECUTION_FAILURE,
"Make sure you have not misspelled the name of the template "
"or the plugin(s) providing the template is installed. "
f"Current list of templated is: {list(self._registered_templates.keys())}",
Expand Down
2 changes: 2 additions & 0 deletions projects/vdk-core/src/vdk/internal/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"""
from __future__ import annotations

from logging import Logger

from vdk.internal.core.error_classifiers import *

# Due to the expansion of this file's responsibilities over time,
Expand Down
22 changes: 9 additions & 13 deletions projects/vdk-core/src/vdk/internal/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,15 @@ def load_plugin_with_hooks_impl(
f"Failed to register plugin {name}. Most likely the plugin name has been forbidden"
)
except Exception as e:
message = ErrorMessage(
summary=f"Failed to load plugin ",
what=f"Failed to load plugin with name '{name}' and module/class '{module_or_class_with_hook_impls}'",
why="Most likely a bug in the plugin",
consequences="The CLI tool will likely abort.",
countermeasures="Re-try again. "
"Revert to previous stable version of the plugin or CLI "
"plugin (pip install vdk-plugin-name==version) "
"Or see what plugins are installed (use `pip list` command) and if "
"there are not issues. "
"Or try to reinstall the app in a new clean environment ",
)
raise PluginException(message) from e
raise PluginException(
f"""Failed to load plugin
Failed to load plugin with name '{name}' and module/class '{module_or_class_with_hook_impls}'
Troubleshooting options:
1. Check what plugins are installed (use `pip list` command) and see if there are any issues.
2. Revert to previous stable version of the plugin or CLI plugin (pip install vdk-plugin-name==version)
3. Reinstall the app in a new clean environment
"""
) from e

def add_hook_specs(self, module_or_class_with_hookspecs: object):
self.__plugin_manager.add_hookspecs(module_or_class_with_hookspecs)
Expand Down

0 comments on commit 67523b5

Please sign in to comment.