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] Feature flag system via config #5960

Merged
merged 3 commits into from
Oct 1, 2018

Conversation

xtinec
Copy link
Contributor

@xtinec xtinec commented Sep 23, 2018

Adding a feature flag system that is driven by superset_config.py. This change includes:

  • Server side changes to specify a dedicated FEATURE_FLAG dictionary for listing feature flags. E.g.
FEATURE_FLAGS = { 'SCOPED_FILTER': true }
  • Pass the new feature flags to client via bootstrap-data
  • Client side changes to inject feature flags into the redux state tree for dashboard, explore view and SqlLab
  • Client side refactor/clean up so the feature flags can be properly tested. Also avoid modifying incoming bootstrap data when creating initial state for the redux state tree
  • Re-enable tests that were previously disabled for ExploreViewContainer

@mistercrunch @kristw @williaster

@codecov-io
Copy link

codecov-io commented Sep 24, 2018

Codecov Report

Merging #5960 into master will increase coverage by 1.19%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5960      +/-   ##
==========================================
+ Coverage   63.52%   64.72%   +1.19%     
==========================================
  Files         393      395       +2     
  Lines       23667    23678      +11     
  Branches     2638     2639       +1     
==========================================
+ Hits        15034    15325     +291     
+ Misses       8620     8340     -280     
  Partials       13       13
Impacted Files Coverage Δ
superset/views/base.py 68% <ø> (ø) ⬆️
...t/assets/src/dashboard/reducers/getInitialState.js 61.9% <ø> (+61.9%) ⬆️
superset/assets/src/SqlLab/getInitialState.js 100% <ø> (+42.85%) ⬆️
superset/assets/src/explore/App.jsx 0% <0%> (ø) ⬆️
superset/assets/src/explore/reducers/index.js 0% <0%> (ø) ⬆️
...ts/src/explore/components/ExploreViewContainer.jsx 54.1% <100%> (+54.1%) ⬆️
superset/assets/src/SqlLab/reducers.js 58.68% <100%> (+0.24%) ⬆️
superset/assets/src/featureFlags.js 100% <100%> (ø)
superset/assets/src/dashboard/reducers/index.js 100% <100%> (ø) ⬆️
superset/assets/src/SqlLab/components/App.jsx 90.38% <100%> (+0.38%) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 569f221...b5b812c. Read the comment docs.

}

// Feature flags are not altered throughout the life time of the app
export default function featureFlagsReducer(state = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think this is necessary if it's never modified?

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 think it feels odd to have a subtree of the redux state tree dangling without a reducer. This also leaves room for enriching the feature flag system in the future if we'd like (e.g. allowing toggling of a feature flag without restarting the server). Thoughts?

Copy link
Contributor

@kristw kristw Sep 25, 2018

Choose a reason for hiding this comment

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

Feature flag override would be interesting. Some dogfood apps has Chrome plugin that you can turn on/off experimental features. With that said I am OK with having empty reducer here for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good 👍

# Feature flags
# ---------------------------------------------------
# Feature flags that are on by default go here. Their
# values can be overridden by those in super_config.py
Copy link
Member

Choose a reason for hiding this comment

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

We'll need a place in the docs where we document every single feature flag as we add them. It doesn't have to be setup in this PR, but let's do it when we add in the first feature flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

// `isFeatureEnabled` function which takes a feature and returns whether it is enabled.
// Note that we assume the featureFlags subtree is at the root of the redux state tree.
export function isFeatureEnabledCreator(state) {
return feature => !!state.featureFlags[feature];
Copy link
Member

Choose a reason for hiding this comment

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

This makes it clear to me that feature flag can only be boolean, which seems reasonable given the name. It prevents having more complex data structures like vizTypeBlacklist = ['heatmap', 'sunburst'] . I'm not necessarily questioning this, just pointing it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

hopefully vis type lists will come from the plugin system not this!

@@ -0,0 +1,69 @@
import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

I think you didn't use git mv and git/github thinks you created a new file, let's keep the git history in place

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catching. Fixing it.

@@ -1,38 +0,0 @@
// this test must be commented out because ChartContainer is now importing files
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused as to why this was commented out to start with (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding a feature flag system that is driven by superset_config.py. This change includes:
- Server side changes to specify a dedicated FEATURE_FLAG dictionary for listing feature flags. E.g.
```
FEATURE_FLAGS = { 'SCOPED_FILTER': true }
```
- Pass the new feature flags to client via bootstrap-data
- Client side changes to inject feature flags into the redux state tree for dashboard, explore view and SqlLab
- Client side refactor/clean up so the feature flags can be properly tested. Also avoid modifying incoming bootstrap data when creating initial state for the redux state tree
- Re-enable tests that were previously disabled for ExploreViewContainer
…so we don't have to write ../../../src and such in tests). This will in a separate PR.
@xtinec
Copy link
Contributor Author

xtinec commented Sep 26, 2018

@mistercrunch @williaster does this look good to merge? 🙏

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

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

lgtm!

@betodealmeida betodealmeida merged commit 604524b into apache:master Oct 1, 2018
betodealmeida pushed a commit to lyft/incubator-superset that referenced this pull request Oct 12, 2018
* [feat] Feature flag system via config

Adding a feature flag system that is driven by superset_config.py. This change includes:
- Server side changes to specify a dedicated FEATURE_FLAG dictionary for listing feature flags. E.g.
```
FEATURE_FLAGS = { 'SCOPED_FILTER': true }
```
- Pass the new feature flags to client via bootstrap-data
- Client side changes to inject feature flags into the redux state tree for dashboard, explore view and SqlLab
- Client side refactor/clean up so the feature flags can be properly tested. Also avoid modifying incoming bootstrap data when creating initial state for the redux state tree
- Re-enable tests that were previously disabled for ExploreViewContainer

* Fix lint errors.

* Remove the partial attempt to get reference to src working in tests (so we don't have to write ../../../src and such in tests). This will in a separate PR.
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0 labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.28.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants