8000 Fix logging via toml by orsinium · Pull Request #2593 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix logging via toml #2593

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

Merged
merged 4 commits into from
Dec 12, 2018
Merged

Fix logging via toml #2593

merged 4 commits into from
Dec 12, 2018

Conversation

orsinium
Copy link
Contributor

Description

Wrap AttributeError when try to configure logging via config section. Cfg file doesn't support inheritance enough for logging configuring, so we can skip logging configuring via config section when cfg-based config used.

Motivation and Context

Fix #2592

Have you tested this? If so, how?

Test included. Failed before fix, success after

@@ -40,7 +40,7 @@ def _section(cls, opts):
"""Get logging settings from config file section "logging"."""
try:
logging_config = cls.config['logging']
except (TypeError, KeyError, NoSectionError):
except (TypeError, KeyError, NoSectionError, AttributeError):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want the attribute error to allow logging_config = cls.config.options('logging') like @riga suggested? Or is the best course of action to just return False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't configure logging via section in cfg. It have to be False for LuigiConfigParser.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For section based logging configuring we need dicts in dists, but cfg format doesn't support it as opposite to toml, yaml, json and other good formats.

Copy link
Contributor

Choose a reason for hiding this comment

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

For section based logging configuring we need dicts in dists, but cfg format doesn't support it as opposite to toml, yaml, json and other good formats.

Is there a difference between Python 2 and 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's particular point of cfg format as is. There can be mistake only if cfg-based config has logging section, but there is no reason to do it.

Copy link
Contributor
@riga riga Nov 30, 2018

Choose a reason for hiding this comment

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

Then I maybe just don't get why this block exists at all:

configured = cls._section(opts)
if configured:
logger = logging.getLogger('luigi')
logger.info('logging configured via config section')
return True

configured will always be False in 2.7, and True or False in 3.X, depending on whether the logging section exists. That's what I meant with my previous comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's True for toml-based config with logging section for any Python version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also it will be true for YAML or JSON based configs in future. I hope, we will add it.

Copy link
Member

Choose a reason for hiding this comment

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

I would also prefer not to catch AttributeError but handle this case explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed it

@honnix
Copy link
Member
honnix commented Dec 12, 2018

As I commented #2592 (comment), 2.8.0 didn't have this issue before the bug was introduced in later PR. However we just release 2.8.1 yesterday that that became a broken version. Any progress on this PR?

@orsinium
Copy link
Contributor Author

I've added explicit check for LuigiConfigParser.

@honnix
Copy link
Member
honnix commented Dec 12, 2018

LGTM. @dlstadther @Tarrasch any thought? I wasn't following the original PR.

@honnix
Copy link
Member
honnix commented Dec 12, 2018

@dlstadther please merge and release a hotfix, thanks!

@dlstadther dlstadther merged commit 97e3be7 into spotify:master Dec 12, 2018
@dlstadther
Copy link
Collaborator

@honnix Done

@honnix
Copy link
Member
honnix commented Dec 12, 2018

Awesome. Thanks!

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.

AttributeError during logging setup with Python 2.7
4 participants
0