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

Modify set_global_logger_level use of contextmanager #418

Merged
merged 2 commits into from May 13, 2021

Conversation

zhupr
Copy link
Collaborator

@zhupr zhupr commented May 12, 2021

Description

Motivation and Context

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
  2. Your own tests:

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

qlib/log.py Outdated
@@ -165,8 +165,16 @@ def filter(self, record):
return allow


@contextmanager
Copy link
Collaborator

Choose a reason for hiding this comment

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

@zhupr Please keep the previous set_global_logger_level function and create a new contextmanager.
I think they are both very useful.
Besides, please add detailed docstrings about the feature.

Thanks

qlib/log.py Outdated
@@ -166,7 +166,79 @@ def filter(self, record):


def set_global_logger_level(level: int):
Copy link
Collaborator

Choose a reason for hiding this comment

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

@zhupr You can add a parameter like return_orig_handler_level=False to control the return value to reuse this function in set_global_logger_level_contextmanager.

qlib/log.py Outdated


@contextmanager
def set_global_logger_level_contextmanager(level: int):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The function name is too long...
You can use a shorter name (e.g. use cm to replace contextmanger)

@Derek-Wds Derek-Wds added the enhancement New feature or request label May 13, 2021
@you-n-g you-n-g merged commit f15ca39 into microsoft:main May 13, 2021
qianyun210603 pushed a commit to qianyun210603/qlib that referenced this pull request Mar 23, 2023
Modify set_global_logger_level use of contextmanager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants