From 88eb1d68f2fd0b02d67c399c3cda9970d8818d6f Mon Sep 17 00:00:00 2001 From: yongchand Date: Sat, 9 Oct 2021 02:55:43 +0900 Subject: [PATCH 1/4] feat(config): Add none force-refresh option for auto refresh --- .../src/dashboard/components/Header/index.jsx | 25 +++++++++++++------ superset/config.py | 2 ++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index 27dc4e7842c71..3bcbec921240a 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -292,17 +292,28 @@ class Header extends React.PureComponent { }); this.props.addWarningToast( t( - `This dashboard is currently force refreshing; the next force refresh will be in %s.`, + `This dashboard is currently auto refreshing; the next auto refresh will be in %s.`, intervalMessage, ), ); + + if (isFeatureEnabled(FeatureFlag.DASHBOARD_FORCE_AUTO_REFRESH)) { + // force-refresh while auto-refresh in dashboard + return fetchCharts( + affectedCharts, + true, + interval * 0.2, + dashboardInfo.id, + ); + } else { + return fetchCharts( + affectedCharts, + false, + interval * 0.2, + dashboardInfo.id, + ); + } - return fetchCharts( - affectedCharts, - true, - interval * 0.2, - dashboardInfo.id, - ); }; this.refreshTimer = setPeriodicRunner({ diff --git a/superset/config.py b/superset/config.py index 7f504582c5920..b4596ebca4ba1 100644 --- a/superset/config.py +++ b/superset/config.py @@ -406,6 +406,8 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: # This could cause the server to run out of memory or compute. "ALLOW_FULL_CSV_EXPORT": False, "UX_BETA": False, + # Force refresh while auto-refresh in dashboard + "DASHBOARD_FORCE_AUTO_REFRESH": True, } # Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars. From a6a77ef65246ec940d986257a513ab4663615128 Mon Sep 17 00:00:00 2001 From: yongchand Date: Tue, 12 Oct 2021 00:25:26 +0900 Subject: [PATCH 2/4] use general config --- .../src/dashboard/components/Header/index.jsx | 19 ++++++++----------- superset/config.py | 6 +++--- superset/views/base.py | 1 + 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index 3bcbec921240a..d2da8010e18c5 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -296,24 +296,21 @@ class Header extends React.PureComponent { intervalMessage, ), ); - - if (isFeatureEnabled(FeatureFlag.DASHBOARD_FORCE_AUTO_REFRESH)) { + if (dashboardInfo.common.conf.DASHBOARD_AUTO_REFRESH_MODE === 'fetch') { // force-refresh while auto-refresh in dashboard - return fetchCharts( - affectedCharts, - true, - interval * 0.2, - dashboardInfo.id, - ); - } else { return fetchCharts( affectedCharts, false, interval * 0.2, dashboardInfo.id, ); - } - + } + return fetchCharts( + affectedCharts, + true, + interval * 0.2, + dashboardInfo.id, + ); }; this.refreshTimer = setPeriodicRunner({ diff --git a/superset/config.py b/superset/config.py index b4596ebca4ba1..9cfb686291dd0 100644 --- a/superset/config.py +++ b/superset/config.py @@ -30,7 +30,7 @@ import sys from collections import OrderedDict from datetime import date, timedelta -from typing import Any, Callable, Dict, List, Optional, Type, TYPE_CHECKING, Union +from typing import Any, Callable, Dict, List, Optional, Type, TYPE_CHECKING, Union, Literal from cachelib.base import BaseCache from celery.schedules import crontab @@ -406,8 +406,6 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: # This could cause the server to run out of memory or compute. "ALLOW_FULL_CSV_EXPORT": False, "UX_BETA": False, - # Force refresh while auto-refresh in dashboard - "DASHBOARD_FORCE_AUTO_REFRESH": True, } # Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars. @@ -694,6 +692,8 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]: SQLLAB_SAVE_WARNING_MESSAGE = None SQLLAB_SCHEDULE_WARNING_MESSAGE = None +# Force refresh while auto-refresh in dashboard +DASHBOARD_AUTO_REFRESH_MODE: Literal["fetch", "force"] = "force" # Default celery config is to use SQLA as a broker, in a production setting # you'll want to use a proper broker as specified here: diff --git a/superset/views/base.py b/superset/views/base.py index 0550bb64814dc..72edf2036be07 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -99,6 +99,7 @@ "SQLALCHEMY_DOCS_URL", "SQLALCHEMY_DISPLAY_TEXT", "GLOBAL_ASYNC_QUERIES_WEBSOCKET_URL", + "DASHBOARD_AUTO_REFRESH_MODE", ) logger = logging.getLogger(__name__) From 0149a83230c489846344d35a6fbf55a65172ef96 Mon Sep 17 00:00:00 2001 From: yongchand Date: Wed, 13 Oct 2021 00:33:01 +0900 Subject: [PATCH 3/4] fix lint issues --- .../src/dashboard/components/Header/index.jsx | 2 +- superset/config.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx index d2da8010e18c5..c7c9d1aaa5f89 100644 --- a/superset-frontend/src/dashboard/components/Header/index.jsx +++ b/superset-frontend/src/dashboard/components/Header/index.jsx @@ -304,7 +304,7 @@ class Header extends React.PureComponent { interval * 0.2, dashboardInfo.id, ); - } + } return fetchCharts( affectedCharts, true, diff --git a/superset/config.py b/superset/config.py index 9cfb686291dd0..26acbd80f8c71 100644 --- a/superset/config.py +++ b/superset/config.py @@ -30,7 +30,17 @@ import sys from collections import OrderedDict from datetime import date, timedelta -from typing import Any, Callable, Dict, List, Optional, Type, TYPE_CHECKING, Union, Literal +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Type, + TYPE_CHECKING, + Union, + Literal, +) from cachelib.base import BaseCache from celery.schedules import crontab From 38c1a97234f12b9f027cdaffea314eb7bd5a7a59 Mon Sep 17 00:00:00 2001 From: yongchand Date: Wed, 13 Oct 2021 22:30:22 +0900 Subject: [PATCH 4/4] last lint fix --- superset/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/config.py b/superset/config.py index 26acbd80f8c71..838bbd4cccf80 100644 --- a/superset/config.py +++ b/superset/config.py @@ -35,11 +35,11 @@ Callable, Dict, List, + Literal, Optional, Type, TYPE_CHECKING, Union, - Literal, ) from cachelib.base import BaseCache