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

feat: add argument to remove or preserve root logging handlers #5635

Merged
merged 11 commits into from
Feb 1, 2023

Conversation

Jake-00
Copy link
Contributor

@Jake-00 Jake-00 commented Jan 29, 2023

Goals:

Updates:

  1. To add new argument suppress_root_logging for class JinaLogger's constructor
  2. To add if statement which determines whether to remove or preserve root logging handlers
  • check and update documentation. See guide and ask the team.

@Jake-00
Copy link
Contributor Author

Jake-00 commented Jan 29, 2023

hi @JoanFM @girishc13 , plz take a glance at code when free

Copy link
Contributor

@girishc13 girishc13 left a comment

Choose a reason for hiding this comment

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

This is a good start but the value can only be used by users writing new Executors. It cannot be configured by the current entry points like Flow and Client. If you're up to the task, you can make a few more changes to add the same argument at least to the Flow and the Client parser.
You can refer to the the parsers package for adding the new argument and you can refer to the following lines where the argument will be used automatically:

jina/logging/logger.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 30, 2023

Codecov Report

Merging #5635 (7f5c1e3) into master (05cae91) will increase coverage by 3.10%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #5635      +/-   ##
==========================================
+ Coverage   85.19%   88.29%   +3.10%     
==========================================
  Files         130      131       +1     
  Lines       10218    10225       +7     
==========================================
+ Hits         8705     9028     +323     
+ Misses       1513     1197     -316     
Flag Coverage Δ
jina 88.29% <100.00%> (+3.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/logging/logger.py 92.48% <100.00%> (+0.05%) ⬆️
jina/parsers/__init__.py 98.09% <100.00%> (+0.03%) ⬆️
jina/parsers/flow.py 100.00% <100.00%> (ø)
jina/parsers/logging.py 100.00% <100.00%> (ø)
jina/jaml/__init__.py 95.00% <0.00%> (+0.35%) ⬆️
jina/parsers/helper.py 56.39% <0.00%> (+0.58%) ⬆️
jina/helper.py 80.74% <0.00%> (+0.71%) ⬆️
jina/serve/runtimes/worker/request_handling.py 95.39% <0.00%> (+0.83%) ⬆️
jina/clients/mixin.py 97.45% <0.00%> (+1.69%) ⬆️
jina/jaml/helper.py 83.94% <0.00%> (+2.18%) ⬆️
... and 13 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Jake-00
Copy link
Contributor Author

Jake-00 commented Jan 30, 2023

Hi @girishc13 . Thanks for your detailed instruction. There are two things which need to clarify:

  • As for Flow, to append argument in file jina\parsers\orchestrate\base.py is enough.
def mixin_essential_parser(parser, default_name=None):
    # leave out original lines, lines below is new
    gp.add_argument(
        '--suppress_root_logging',
        action='store_true',
        default=False,
        help='If set, then no root handlers will be suppressed from logging.',
    )
  • As for Client, adding modified mixin_essential_parser() in function set_client_cli_parser() of file jina\parsers\__init__.py is allowed.
def set_client_cli_parser(parser=None):
    # leave out original lines
    mixin_essential_parser(parser)  # new
    mixin_client_gateway_parser(parser)
    mixin_client_features_parser(parser)
    mixin_client_protocol_parser(parser)
    mixin_prefetch_parser(parser)

@girishc13
Copy link
Contributor

@Jake-00, the mixin_essential_parser cannot be added to the client parser because it contains irrelevant arguments to the client. My suggestion is to create a new file logging.py under the parsers package which has the following method:

def mixin_suppress_root_logging_parser(parser):
   parser.add_argument(
          '--suppress_root_logging',
          action='store_true',
          default=False,
          help='If set, then no root handlers will be suppressed from logging.',
      )

This method can now be individually added after the usages of mixin_essential_parser and also inside the set_client_cli_parser method independently.

@Jake-00
Copy link
Contributor Author

Jake-00 commented Jan 31, 2023

Hi @girishc13 , I choose to followe your suggestion and update code with new commit, plz check it out when free, thanks

@Jake-00 Jake-00 requested a review from girishc13 January 31, 2023 14:13
Copy link
Contributor

@girishc13 girishc13 left a comment

Choose a reason for hiding this comment

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

One minor change. Otherwise looks good.

jina/parsers/logging.py Outdated Show resolved Hide resolved
@Jake-00 Jake-00 requested a review from girishc13 January 31, 2023 15:31
@Jake-00
Copy link
Contributor Author

Jake-00 commented Jan 31, 2023

I just now append docstring for function mixin_suppress_root_logging_parser().

@Jake-00
Copy link
Contributor Author

Jake-00 commented Feb 1, 2023

hi @girishc13, should I add more test to improve test coverage rate? But I do not know why the updated code would affect schemas module.

@girishc13 girishc13 merged commit 02edb74 into jina-ai:master Feb 1, 2023
@JoanFM
Copy link
Member

JoanFM commented Feb 1, 2023

Thanks for this amazing contribution @Jake-00 !!!! Happy to have you as part of the community!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add argument to remove or preserve root logging handlers
3 participants