Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed OVC logger. #27837

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tools/ovc/openvino/tools/ovc/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def convert_model(
list of paths, objects derived from BaseExtension class or lists of
objects.
:param verbose:
Print detailed information about conversion.
Print detailed information about conversion. The detailed information is logged via standard logging library.
The log level can be changed by setting the log level using logging library.
Example:
import logging
logging.getLogger().setLevel(logging.DEBUG)
:param share_weights:
Reuse weights allocated in the original model. If input model is in file,
then mmap is used to allocate weights directly from file. If input model is
Expand Down
8 changes: 5 additions & 3 deletions tools/ovc/openvino/tools/ovc/convert_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ def check_model_object(argv):


def driver(argv: argparse.Namespace, non_default_params: dict):
init_logger('ERROR', argv.verbose)

# Log dictionary with non-default cli parameters where complex classes are excluded.
log.debug(str(non_default_params))

Expand Down Expand Up @@ -433,7 +431,11 @@ def _convert(cli_parser: argparse.ArgumentParser, args, python_api_used):
telemetry.send_event('ovc', 'version', simplified_ie_version)
# Initialize logger with 'ERROR' as default level to be able to form nice messages
# before arg parser deliver log_level requested by user
init_logger('ERROR', False)
verbose = False
if "verbose" in args and args["verbose"] or "--verbose" in sys.argv:
verbose = True

init_logger('ERROR', verbose, python_api_used)
argv = None
# Minimize modifications among other places in case if multiple pieces are passed as input_model
if python_api_used:
Expand Down
2 changes: 2 additions & 0 deletions tools/ovc/openvino/tools/ovc/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ def get_convert_model_help_specifics():
{'action': 'version',
# FIXME: Why the following is not accessible from arg parser?
'version': 'OpenVINO Model Converter (ovc) {}'.format(VersionChecker().get_ie_version())},
'verbose':
{'description': 'Print detailed information about conversion.'}
}
5 changes: 4 additions & 1 deletion tools/ovc/openvino/tools/ovc/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ def filter(self, record: log.LogRecord):
return True # if regex wasn't set print all logs


def init_logger(lvl: str, verbose: bool):
def init_logger(lvl: str, verbose: bool, python_api_used: bool):
if verbose and python_api_used:
# We need to not override logger in case of verbose=True to allow user set a log level
popovaan marked this conversation as resolved.
Show resolved Hide resolved
return
global handler_num
log_exp = os.environ.get('MO_LOG_PATTERN')
if not verbose:
Expand Down
Loading