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

Add possibility to select logging level. #2786

Closed
wants to merge 10 commits into from

Conversation

nick863
Copy link
Contributor

@nick863 nick863 commented Apr 13, 2024

Description

This PR address the issue from the work item 3096911. Essentially, we want to control the logging verbosity. I have made the changes in the logging and added unit test.
To better test changes I have also added mypy configuration to pyproject.toml and fixed all the encountered 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.
  • Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: 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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copy link

github-actions bot commented Apr 13, 2024

promptflow-core test result

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

promptflow SDK CLI Azure E2E Test Result nirovins/change_logging_mechanism

  4 files    4 suites   5m 1s ⏱️
231 tests 202 ✅  29 💤 0 ❌
924 runs  808 ✅ 116 💤 0 ❌

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

SDK CLI Global Config Test Result nirovins/change_logging_mechanism

4 tests   4 ✅  1m 13s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

promptflow-evals test result

12 files  12 suites   2m 13s ⏱️
 3 tests  2 ✅  1 💤 0 ❌
36 runs  24 ✅ 12 💤 0 ❌

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

Executor Unit Test Result nirovins/change_logging_mechanism

779 tests   779 ✅  3m 42s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

Executor E2E Test Result nirovins/change_logging_mechanism

238 tests   232 ✅  5m 9s ⏱️
  1 suites    5 💤
  1 files      1 ❌

For more details on these failures, see this check.

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 13, 2024

SDK CLI Test Result nirovins/change_logging_mechanism

    4 files      4 suites   1h 5m 22s ⏱️
  661 tests   637 ✅ 23 💤 1 ❌
2 644 runs  2 551 ✅ 92 💤 1 ❌

For more details on these failures, see this check.

Results for commit 06f8926.

♻️ This comment has been updated with latest results.

ninghu
ninghu previously approved these changes Apr 15, 2024
nagkumar91
nagkumar91 previously approved these changes Apr 16, 2024
ninghu
ninghu previously approved these changes Apr 16, 2024
@@ -145,6 +146,7 @@ def __init__(
**kwargs,
):
self.variant = kwargs.pop("variant", None) or {}
self._log_level = kwargs.pop("log_level", None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this setting should not be in Flow obj as it's changes static loggers which is not part of flow

@@ -30,7 +33,7 @@ def __init__(self, project_scope: dict, credential: Optional[TokenCredential] =
# Load the flow as function
current_dir = Path(__file__).resolve().parent
flow_dir = current_dir / "flow"
self._flow = load_flow(source=flow_dir)
self._flow = load_flow(source=flow_dir, log_level=log_level)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we directly set the logger here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just give user some doc that they can change logging behavior by setting some env variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main problem here is that all the log records, the task are not coming from flow itself, it is from invoker/executor infrastructure.
We are using two mechanisms of getting loggers. If user will set the PF_LOGGING_LEVEL, the flow executor logs will ignore it, because the environment variable will have to be set before importing promptflow, as the logger is initialized during import (see the logger_utils.py).

flow_logger = get_logger("execution.flow")

Another problem is that we initialize the "flowinvoker" logger on flow invoker level, using different mechanism, which will respect PF_LOGGING_LEVEL (the code is given before this PR):

self.logger = kwargs.get("logger", LoggerFactory.get_logger("flowinvoker"))

So that the logger created/set on the flow level will not have the effect. All

Copy link

github-actions bot commented May 2, 2024

Hi, thank you for your interest in helping to improve the prompt flow experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment.

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue/pull request label May 2, 2024
Copy link

github-actions bot commented May 9, 2024

Hi, thank you for your contribution. Since there has not been recent engagement, we are going to close this out. Feel free to reopen if you'd like to continue working on these changes. Please be sure to remove the no-recent-activity label; otherwise, this is likely to be closed again with the next cleanup pass.

@github-actions github-actions bot closed this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants