-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
Use config[]
not config.get()
#8454
Use config[]
not config.get()
#8454
Conversation
config[]
not config.get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@john-bodley can probably chime in here, too, but I think in general there are lots of good changes here, i.e. removing default settings that are scattered across the codebase that should be defined only in config.py
. Also the fact that you were able to find eight (!) missing config parameters by doing this change goes to show that this change makes the codebase more robust. Some small changes proposed, but apart from that LGTM.
relative_start: str = app.config["DEFAULT_RELATIVE_START_TIME"], | ||
relative_end: str = app.config["DEFAULT_RELATIVE_END_TIME"], |
There was a problem hiding this 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 example of why this change is good; no point in having secondary default values spread across the codebase, as these should only be defaulted in one place.
stats_logger = config.get("STATS_LOGGER") | ||
SQLLAB_TIMEOUT = config.get("SQLLAB_ASYNC_TIME_LIMIT_SEC", 600) | ||
stats_logger = config["STATS_LOGGER"] | ||
SQLLAB_TIMEOUT = config["SQLLAB_ASYNC_TIME_LIMIT_SEC"] | ||
SQLLAB_HARD_TIMEOUT = SQLLAB_TIMEOUT + 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope, but I wonder if SQLLAB_HARD_TIMEOUT
should be defined in config.py
, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think sql lab hard timeout needs to be definable in the config as well, the purpose for it is to provide a hard cutoff in celery if a soft timeout fails (or isn't implemented). The time between soft and hard timeout shouldn't be much, so I don't think allowing configuration gets much here. Happy to reconsider if you think there's a good reason to make it configurable though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not feeling especially opinionated on this one, but in general I have an aversion to hard coding parameters, especially in the context of distributed/async problems which are extra horrible to debug. So, at the risk of cluttering the config file, I would still vote for introducing the config parameter SQLLAB_HARD_TIMEOUT_ADDON
or similar with a concise comment that might save someone down the line a few hours of grief.
But: this ended up sounding much more dramatic than it probably is, so happy either way!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this. You mentioned there were a number of variables you had to set locally. Any reason they haven’t been added to config.py
?
+1 to @john-bodley's point, if switching from Also, in terms of typing, once we move to python 3.8, I think defining a Config type as a I think this is an awesome change overall though, thanks for taking it on! |
Thank you @villebro, @john-bodley, and @etr2460 for the feedback. The only reason the additional configuration wasn't added to |
09072af
to
a4b91f0
Compare
…/incubator-superset into wbarrett/config-not-config-get
It'd be nice if we could raise a |
@mistercrunch yes, throwing a custom configuration error would be a nice improvement. I'd like to attempt that in a separate PR once this guy goes through - it may take a little doing to separate out Superset config from Flask config or extend Flask's config object to provide that functionality. |
Codecov Report
@@ Coverage Diff @@
## master #8454 +/- ##
==========================================
- Coverage 66.58% 66.57% -0.02%
==========================================
Files 449 449
Lines 22525 22576 +51
Branches 2364 2367 +3
==========================================
+ Hits 14999 15030 +31
- Misses 7388 7408 +20
Partials 138 138
Continue to review full report at Codecov.
|
Hey there @villebro @etr2460 @john-bodley - I think this is ready for another look when you have time. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM apart from a few non-blocking comments.
stats_logger = config.get("STATS_LOGGER") | ||
SQLLAB_TIMEOUT = config.get("SQLLAB_ASYNC_TIME_LIMIT_SEC", 600) | ||
stats_logger = config["STATS_LOGGER"] | ||
SQLLAB_TIMEOUT = config["SQLLAB_ASYNC_TIME_LIMIT_SEC"] | ||
SQLLAB_HARD_TIMEOUT = SQLLAB_TIMEOUT + 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not feeling especially opinionated on this one, but in general I have an aversion to hard coding parameters, especially in the context of distributed/async problems which are extra horrible to debug. So, at the risk of cluttering the config file, I would still vote for introducing the config parameter SQLLAB_HARD_TIMEOUT_ADDON
or similar with a concise comment that might save someone down the line a few hours of grief.
But: this ended up sounding much more dramatic than it probably is, so happy either way!
Hi @john-bodley - I think you have the remaining review here. Please forgive the reminder :) |
CATEGORY
Choose one
SUMMARY
As pointed out here https://github.com/apache/incubator-superset/pull/8409/files#diff-6a3371457528722a734f3c51d9238c13R482 we no longer want to use the
config.get
format, but instead assume that all configuration options are set. This PR alters all existing usages ofconfig.get
to theconfig[]
syntax. Note that this will cause errors if those configuration options are not provided. In order to get the system running again, I had to set the following configuration options locally:I'm somewhat concerned about the effect of merging this in terms of stability, so I'm looking for feedback from the community, especially @villebro who clued me in to the preferred approach in the first place.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS
@villebro @mistercrunch @dpgaspar