From 15d2dae7b4e2f693d7a490942346f13d5fa443ad Mon Sep 17 00:00:00 2001 From: Honglin Date: Mon, 25 Dec 2023 17:07:18 +0800 Subject: [PATCH] [SDK/CLI] Fix circular import error for sdk/cli logger (#1585) # Description Please add an informative description that covers that changes made by the pull request and link all relevant issues. # All Promptflow Contribution checklist: - [ ] **The pull request does not introduce [breaking changes].** - [ ] **CHANGELOG is updated for new features, bug fixes or other significant changes.** - [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).** - [ ] **Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: [suggested workflow](../CONTRIBUTING.md#suggested-workflow).** ## General Guidelines and Best Practices - [ ] Title of the pull request is clear and informative. - [ ] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md). ### Testing Guidelines - [ ] Pull request includes test coverage for the included changes. --- src/promptflow/promptflow/_utils/logger_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/promptflow/promptflow/_utils/logger_utils.py b/src/promptflow/promptflow/_utils/logger_utils.py index 767f1affe79..2cd97a282f3 100644 --- a/src/promptflow/promptflow/_utils/logger_utils.py +++ b/src/promptflow/promptflow/_utils/logger_utils.py @@ -16,7 +16,6 @@ from typing import List, Optional from promptflow._constants import PF_LOGGING_LEVEL -from promptflow._sdk._constants import LOGGER_NAME from promptflow._utils.credential_scrubber import CredentialScrubber from promptflow._utils.exception_utils import ExceptionPresenter from promptflow.contracts.run_mode import RunMode @@ -370,4 +369,7 @@ def _add_handler(logger: logging.Logger, verbosity: int, target_stdout: bool = F def get_cli_sdk_logger(): """Get logger used by CLI SDK.""" # cli sdk logger default logging level is WARNING - return LoggerFactory.get_logger(LOGGER_NAME, verbosity=logging.WARNING) + # here the logger name "promptflow" is from promptflow._sdk._constants.LOGGER_NAME, + # to avoid circular import error, use plain string here instead of importing from _constants + # because this function is also called in _prepare_home_dir which is in _constants + return LoggerFactory.get_logger("promptflow", verbosity=logging.WARNING)