This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 0c3e46f Deprecate npm run backend-sync and related logic (#7211)
0c3e46f is described below
commit 0c3e46f8ae810d049de9744071c05a7350d4026e
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Wed Apr 10 08:46:05 2019 -0700
Deprecate npm run backend-sync and related logic (#7211)
---
CONTRIBUTING.md | 3 -
UPDATING.md | 1 +
contrib/docker/Dockerfile | 1 -
contrib/docker/docker-entrypoint.sh | 2 +-
superset/__init__.py | 3 -
superset/assets/package.json | 1 -
superset/assets/src/syncBackend.js | 43 ------------
superset/legacy.py | 76 ----------------------
...7c195a_rewriting_url_from_shortner_with_new_.py | 2 -
.../db0c65b146bd_update_slice_model_json.py | 2 -
superset/views/core.py | 6 +-
11 files changed, 3 insertions(+), 137 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5db5e98..7500592 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -385,9 +385,6 @@ npm run dev
# Compile the Javascript and CSS in production/optimized mode for official
releases
npm run prod
-
-# Copy a conf file from the frontend to the backend
-npm run sync-backend
```
#### Updating NPM packages
diff --git a/UPDATING.md b/UPDATING.md
index 27ea571..bec2d42 100644
--- a/UPDATING.md
+++ b/UPDATING.md
@@ -23,6 +23,7 @@ assists people when migrating to a new version.
## Superset 0.32.0
+* `npm run backend-sync` is deprecated and no longer needed, will fail if
called
* [5445](https://github.com/apache/incubator-superset/pull/5445) : a change
which prevents encoding of empty string from form data in the datanbase.
This involves a non-schema changing migration which does potentially impact
diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile
index da3a9b1..2949f16 100644
--- a/contrib/docker/Dockerfile
+++ b/contrib/docker/Dockerfile
@@ -59,7 +59,6 @@ USER superset
RUN cd superset/assets \
&& npm ci \
- && npm run sync-backend \
&& npm run build \
&& rm -rf node_modules
diff --git a/contrib/docker/docker-entrypoint.sh
b/contrib/docker/docker-entrypoint.sh
index 24bdb97..474a583 100755
--- a/contrib/docker/docker-entrypoint.sh
+++ b/contrib/docker/docker-entrypoint.sh
@@ -22,7 +22,7 @@ if [ "$#" -ne 0 ]; then
elif [ "$SUPERSET_ENV" = "development" ]; then
celery worker --app=superset.sql_lab:celery_app --pool=gevent -Ofair &
# needed by superset runserver
- (cd superset/assets/ && npm ci && npm run sync-backend)
+ (cd superset/assets/ && npm ci)
(cd superset/assets/ && npm run dev) &
FLASK_ENV=development FLASK_APP=superset:app flask run -p 8088
--with-threads --reload --debugger --host=0.0.0.0
elif [ "$SUPERSET_ENV" = "production" ]; then
diff --git a/superset/__init__.py b/superset/__init__.py
index 69ad1f5..7d0df26 100644
--- a/superset/__init__.py
+++ b/superset/__init__.py
@@ -45,9 +45,6 @@ CONFIG_MODULE = os.environ.get('SUPERSET_CONFIG',
'superset.config')
if not os.path.exists(config.DATA_DIR):
os.makedirs(config.DATA_DIR)
-with open(APP_DIR + '/static/assets/backendSync.json', 'r', encoding='utf-8')
as f:
- frontend_config = json.load(f)
-
app = Flask(__name__)
app.config.from_object(CONFIG_MODULE)
conf = app.config
diff --git a/superset/assets/package.json b/superset/assets/package.json
index 4a294cf..23eac66 100644
--- a/superset/assets/package.json
+++ b/superset/assets/package.json
@@ -17,7 +17,6 @@
"build": "NODE_ENV=production webpack --mode=production --colors
--progress",
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx . && tslint -c
tslint.json ./{src,spec}/**/*.ts{,x}",
"lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx . &&
tslint -c tslint.json --fix ./{src,spec}/**/*.ts{,x}",
- "sync-backend": "babel-node --preset=@babel/preset-env src/syncBackend.js",
"cypress": "cypress",
"cypress-debug": "cypress open --config watchForFileChanges=true",
"install-cypress": "npm install [email protected]"
diff --git a/superset/assets/src/syncBackend.js
b/superset/assets/src/syncBackend.js
deleted file mode 100644
index ae61bf3..0000000
--- a/superset/assets/src/syncBackend.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/* eslint no-console: 0 */
-import fs from 'fs';
-import path from 'path';
-import { controls } from './explore/controls';
-
-function exportFile(fileLocation, content) {
- fs.writeFile(fileLocation, content, function (err) {
- if (err) {
- console.log(`File ${fileLocation} was not saved... :(`);
- } else {
- console.log(`File ${fileLocation} was saved!`);
- }
- });
-}
-
-function main() {
- const APP_DIR = path.resolve(__dirname, './');
- const dir = APP_DIR + '/../dist/';
- if (!fs.existsSync(dir)) {
- fs.mkdirSync(dir);
- }
- const blob = { controls };
- exportFile(APP_DIR + '/../backendSync.json', JSON.stringify(blob, null, 2));
-}
-main();
diff --git a/superset/legacy.py b/superset/legacy.py
index c066cb6..955a486 100644
--- a/superset/legacy.py
+++ b/superset/legacy.py
@@ -16,82 +16,6 @@
# under the License.
# pylint: disable=C,R,W
"""Code related with dealing with legacy / change management"""
-import re
-
-from superset import frontend_config
-
-FORM_DATA_KEY_WHITELIST = list(frontend_config.get('controls').keys()) +
['slice_id']
-
-
-def cast_filter_data(form_data):
- """Used by cast_form_data to parse the filters"""
- flts = []
- having_flts = []
- fd = form_data
- filter_pattern = re.compile(r"""((?:[^,"']|"[^"]*"|'[^']*')+)""")
- for i in range(0, 10):
- for prefix in ['flt', 'having']:
- col_str = '{}_col_{}'.format(prefix, i)
- op_str = '{}_op_{}'.format(prefix, i)
- val_str = '{}_eq_{}'.format(prefix, i)
- if col_str in fd and op_str in fd and val_str in fd \
- and len(fd[val_str]) > 0:
- f = {}
- f['col'] = fd[col_str]
- f['op'] = fd[op_str]
- if prefix == 'flt':
- # transfer old strings in filter value to list
- splitted = filter_pattern.split(fd[val_str])[1::2]
- values = [types.replace("'", '').strip() for types in
splitted]
- f['val'] = values
- flts.append(f)
- if prefix == 'having':
- f['val'] = fd[val_str]
- having_flts.append(f)
- if col_str in fd:
- del fd[col_str]
- if op_str in fd:
- del fd[op_str]
- if val_str in fd:
- del fd[val_str]
- fd['filters'] = flts
- fd['having_filters'] = having_flts
- return fd
-
-
-def cast_form_data(form_data):
- """Translates old to new form_data"""
- d = {}
- fields = frontend_config.get('controls', {})
- for k, v in form_data.items():
- field_config = fields.get(k, {})
- ft = field_config.get('type')
- if ft == 'CheckboxControl':
- # bug in some urls with dups on bools
- if isinstance(v, list):
- v = 'y' in v
- else:
- v = True if v in ('true', 'y') or v is True else False
- elif v and ft == 'TextControl' and field_config.get('isInt'):
- v = int(v) if v != '' else None
- elif v and ft == 'TextControl' and field_config.get('isFloat'):
- v = float(v) if v != '' else None
- elif v and ft == 'SelectControl':
- if field_config.get('multi'):
- if type(form_data).__name__ == 'ImmutableMultiDict':
- v = form_data.getlist(k)
- elif not isinstance(v, list):
- v = [v]
- if d.get('slice_id'):
- d['slice_id'] = int(d['slice_id'])
-
- d[k] = v
- if 'filters' not in d:
- d = cast_filter_data(d)
- for k in list(d.keys()):
- if k not in FORM_DATA_KEY_WHITELIST:
- del d[k]
- return d
def update_time_range(form_data):
diff --git
a/superset/migrations/versions/a99f2f7c195a_rewriting_url_from_shortner_with_new_.py
b/superset/migrations/versions/a99f2f7c195a_rewriting_url_from_shortner_with_new_.py
index 4cc432f..05e7de8 100644
---
a/superset/migrations/versions/a99f2f7c195a_rewriting_url_from_shortner_with_new_.py
+++
b/superset/migrations/versions/a99f2f7c195a_rewriting_url_from_shortner_with_new_.py
@@ -30,7 +30,6 @@ from alembic import op
import json
import sqlalchemy as sa
from superset import db
-from superset.legacy import cast_form_data
from sqlalchemy.ext.declarative import declarative_base
from urllib import parse
@@ -72,7 +71,6 @@ def upgrade():
d = parse_querystring(url.url.split('?')[1])
split = url.url.split('/')
d['datasource'] = split[5] + '__' + split[4]
- d = cast_form_data(d)
newurl = '/'.join(split[:-1]) + '/?form_data=' +
parse.quote_plus(json.dumps(d))
url.url = newurl
session.merge(url)
diff --git
a/superset/migrations/versions/db0c65b146bd_update_slice_model_json.py
b/superset/migrations/versions/db0c65b146bd_update_slice_model_json.py
index 642f5b5..760945f 100644
--- a/superset/migrations/versions/db0c65b146bd_update_slice_model_json.py
+++ b/superset/migrations/versions/db0c65b146bd_update_slice_model_json.py
@@ -32,7 +32,6 @@ from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, Text
from superset import db
-from superset.legacy import cast_form_data
Base = declarative_base()
@@ -55,7 +54,6 @@ def upgrade():
for i, slc in enumerate(slices):
try:
d = json.loads(slc.params or '{}')
- d = cast_form_data(d)
slc.params = json.dumps(d, indent=2, sort_keys=True)
session.merge(slc)
session.commit()
diff --git a/superset/views/core.py b/superset/views/core.py
index d52bebe..793cee2 100755
--- a/superset/views/core.py
+++ b/superset/views/core.py
@@ -51,7 +51,7 @@ from superset.connectors.sqla.models import
AnnotationDatasource, SqlaTable
from superset.exceptions import SupersetException
from superset.forms import CsvToDatabaseForm
from superset.jinja_context import get_template_processor
-from superset.legacy import cast_form_data, update_time_range
+from superset.legacy import update_time_range
import superset.models.core as models
from superset.models.sql_lab import Query
from superset.models.user_attributes import UserAttribute
@@ -1058,10 +1058,6 @@ class Superset(BaseSupersetView):
url_form_data.update(form_data)
form_data = url_form_data
- if request.args.get('viz_type'):
- # Converting old URLs
- form_data = cast_form_data(form_data)
-
form_data = {
k: v
for k, v in form_data.items()