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

Fix error with LuigiTomlParser usage in S3Client #3076

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

junhl
Copy link

@junhl junhl commented Apr 19, 2021

Description

My attempt to address issue of toml usage error in S3Client from #2996

I'm providing two solutions to choose from, one to fill lacking functions into LuigiTomlParser and another to change the usage into more generic one. While I prefer the second one, when the reviewers prefer one over another, I'll add tests for it.

LuigiConfigParser is built on top of Python's ConfigParser, which is MutableMapping at the end.
LuigiTomlParser is using toml (the module), and it does not provide a comparable class but rather provide load/dump via decoder/encoder.
They work a bit differently. A touch to BaseParser may be needed on a long term because there may be other issues due to differences in their functionalities (not being addressed in this PR).

Motivation and Context

Resolves error on S3Client when attempting to use toml. It would give this before:

defaults = dict(configuration.get_config().defaults())
AttributeError: 'LuigiTomlParser' object has no attribute 'defaults'

Have you tested this? If so, how?

I ran my jobs with this code and it works for me.

I'm happy to add tests when one solution is preferred over another by the reviewers.

@junhl junhl requested review from dlstadther, Tarrasch and a team as code owners April 19, 2021 04:18
@@ -61,6 +61,23 @@ def read(self, config_paths):

return self.data

def defaults(self):
Copy link
Author

@junhl junhl Apr 19, 2021

Choose a reason for hiding this comment

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

solution 1: fill lacking functions to LuigiTomlParser. This is just dummy function so it's not my preferred one.
(will add tests if preferred by reviewers)

try:
config = dict(configuration.get_config().items('s3'))
config = dict(luigi_config['s3'])
Copy link
Author

@junhl junhl Apr 19, 2021

Choose a reason for hiding this comment

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

solution 2: change usage to generic one to use existing __getitem__ and only take defaults when it's meaningful (ex. LuigiConfigParser) instead of creating dummy function. (my pref. Will add tests if reviewers also think so)

@junhl junhl changed the title Fix bug to allow LuigiTomlParser usage in S3Client Fix error with LuigiTomlParser usage in S3Client Apr 21, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If closed, you may revisit when your time allows and reopen! Thank you for your contributions.

@stale stale bot added the wontfix label Jan 9, 2022
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.

None yet

1 participant