mirror of https://github.com/apache/superset.git
Deprecate npm run backend-sync and related logic (#7211)
This commit is contained in:
parent
6c38cb1a09
commit
0c3e46f8ae
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -59,7 +59,6 @@ USER superset
|
|||
|
||||
RUN cd superset/assets \
|
||||
&& npm ci \
|
||||
&& npm run sync-backend \
|
||||
&& npm run build \
|
||||
&& rm -rf node_modules
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 cypress@3.1.5"
|
||||
|
|
|
@ -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();
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue