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

chore: bump celery and Flask #19168

Merged
merged 21 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ aiohttp==3.7.4.post0
# via slackclient
alembic==1.6.5
# via flask-migrate
amqp==2.6.1
amqp==5.1.0
# via kombu
apispec[yaml]==3.3.2
# via flask-appbuilder
Expand All @@ -33,17 +33,27 @@ brotli==1.0.9
# via flask-compress
cachelib==0.4.1
# via apache-superset
celery==4.4.7
celery==5.2.3
# via apache-superset
cffi==1.14.6
# via cryptography
chardet==4.0.0
# via aiohttp
click==7.1.2
click==8.0.4
# via
# apache-superset
# celery
# click-didyoumean
# click-plugins
# click-repl
# flask
# flask-appbuilder
click-didyoumean==0.3.0
# via celery
click-plugins==1.1.1
# via celery
click-repl==0.2.0
# via celery
colorama==0.4.4
# via
# apache-superset
Expand All @@ -64,7 +74,7 @@ dnspython==2.1.0
# via email-validator
email-validator==1.1.3
# via flask-appbuilder
flask==1.1.4
flask==2.0.3
Copy link
Member

Choose a reason for hiding this comment

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

Per the changelog the only breaking change which may impact us is pallets/flask#3555.

# via
# apache-superset
# flask-appbuilder
Expand All @@ -77,15 +87,15 @@ flask==1.1.4
# flask-openid
# flask-sqlalchemy
# flask-wtf
flask-appbuilder==3.4.3
flask-appbuilder==4.0.0rc1
# via apache-superset
flask-babel==1.0.0
# via flask-appbuilder
flask-caching==1.10.1
# via apache-superset
flask-compress==1.10.1
# via apache-superset
flask-jwt-extended==3.25.1
flask-jwt-extended==4.3.1
# via flask-appbuilder
flask-login==0.4.1
# via flask-appbuilder
Expand Down Expand Up @@ -123,18 +133,17 @@ idna==3.2
# yarl
isodate==0.6.0
# via apache-superset
itsdangerous==1.1.0
itsdangerous==2.1.1
# via
# apache-superset
# flask
# flask-wtf
jinja2==2.11.3
jinja2==3.0.3
# via
# flask
# flask-babel
jsonschema==3.2.0
# via flask-appbuilder
kombu==4.6.11
kombu==5.2.4
# via celery
korean-lunar-calendar==0.2.1
# via holidays
Expand Down Expand Up @@ -180,11 +189,13 @@ polyline==1.4.0
# via apache-superset
prison==0.2.1
# via flask-appbuilder
prompt-toolkit==3.0.28
# via click-repl
pyarrow==5.0.0
# via apache-superset
pycparser==2.20
# via cffi
pyjwt==1.7.1
pyjwt==2.2.0
# via
# apache-superset
# flask-appbuilder
Expand Down Expand Up @@ -215,7 +226,7 @@ python-geohash==0.8.5
# via apache-superset
python3-openid==3.2.0
# via flask-openid
pytz==2021.1
pytz==2021.3
# via
# babel
# celery
Expand All @@ -237,7 +248,7 @@ simplejson==3.17.3
six==1.16.0
# via
# bleach
# flask-jwt-extended
# click-repl
# flask-talisman
# holidays
# isodate
Expand Down Expand Up @@ -273,13 +284,16 @@ typing-extensions==3.10.0.0
# apache-superset
urllib3==1.26.6
# via selenium
vine==1.3.0
vine==5.0.0
# via
# amqp
# celery
# kombu
wcwidth==0.2.5
# via prompt-toolkit
webencodings==0.5.1
# via bleach
werkzeug==1.0.1
werkzeug==2.0.3
# via
# flask
# flask-jwt-extended
Expand Down
2 changes: 1 addition & 1 deletion requirements/integration.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ pip-compile-multi!=1.5.9
pre-commit
tox
py>=1.10.0
click==7.1.2
click
4 changes: 2 additions & 2 deletions requirements/integration.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SHA1:03eb2d96afe21f1bda1ab33b4cf84e670a1efe21
# SHA1:8e2dd1e795bcad7451376b3653eb03465e4f05d3
#
# This file is autogenerated by pip-compile-multi
# To update, run:
Expand All @@ -9,7 +9,7 @@ backports.entry-points-selectable==1.1.0
# via virtualenv
cfgv==3.3.0
# via pre-commit
click==7.1.2
click==8.0.4
# via
# -r requirements/integration.in
# pip-compile-multi
Expand Down
4 changes: 0 additions & 4 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ pexpect==4.8.0
# via ipython
pickleshare==0.7.5
# via ipython
prompt-toolkit==3.0.19
# via ipython
proto-plus==1.19.7
# via
# google-cloud-bigquery
Expand Down Expand Up @@ -178,8 +176,6 @@ trino==0.306
# via sqlalchemy-trino
typing-inspect==0.7.1
# via libcst
wcwidth==0.2.5
# via prompt-toolkit
websocket-client==1.2.0
# via docker

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,5 @@ fi

if [ $RUN_TESTS -eq 1 ]
then
pytest -x -s "${TEST_MODULE}"
pytest --durations=0 --maxfail=1 "${TEST_MODULE}"
fi
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ def get_git_sha() -> str:
"backoff>=1.8.0",
"bleach>=3.0.2, <4.0.0",
"cachelib>=0.4.1,<0.5",
"celery>=4.3.0, <5.0.0, !=4.4.1",
"click<8",
"celery>=5.2.2, <6.0.0",
"click>=8.0.3",
"colorama",
"croniter>=0.3.28",
"cron-descriptor",
"cryptography>=3.3.2",
"deprecation>=2.1.0, <2.2.0",
"flask>=1.1.0, <2.0.0",
"flask-appbuilder>=3.4.3, <4.0.0",
"flask>=2.0.0, <3.0.0",
"flask-appbuilder==4.0.0rc1",
"flask-caching>=1.10.0",
"flask-compress",
"flask-talisman",
Expand All @@ -90,7 +90,6 @@ def get_git_sha() -> str:
"gunicorn>=20.1.0",
"holidays==0.10.3", # PINNED! https://github.com/dr-prodigy/python-holidays/issues/406
"humanize",
"itsdangerous>=1.0.0, <2.0.0", # https://github.com/apache/superset/pull/14627
"isodate",
"markdown>=3.0",
"msgpack>=1.0.0, <1.1",
Expand All @@ -104,7 +103,7 @@ def get_git_sha() -> str:
"python-geohash",
"pyarrow>=5.0.0, <6.0",
"pyyaml>=5.4",
"PyJWT>=1.7.1, <2",
"PyJWT>=2.0.0, <2.3.0",
"redis",
"selenium>=3.141.0",
"simplejson>=3.15.0",
Expand Down
16 changes: 12 additions & 4 deletions superset/cli/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def export_dashboards(dashboard_file: Optional[str] = None) -> None:
from superset.dashboards.commands.export import ExportDashboardsCommand
from superset.models.dashboard import Dashboard

g.user = security_manager.find_user(username="admin")
g.user = security_manager.find_user( # pylint: disable=assigning-non-slot
username="admin"
)

dashboard_ids = [id_ for (id_,) in db.session.query(Dashboard.id).all()]
timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
Expand Down Expand Up @@ -96,7 +98,9 @@ def export_datasources(datasource_file: Optional[str] = None) -> None:
from superset.connectors.sqla.models import SqlaTable
from superset.datasets.commands.export import ExportDatasetsCommand

g.user = security_manager.find_user(username="admin")
g.user = security_manager.find_user( # pylint: disable=assigning-non-slot
username="admin"
)

dataset_ids = [id_ for (id_,) in db.session.query(SqlaTable.id).all()]
timestamp = datetime.now().strftime("%Y%m%dT%H%M%S")
Expand Down Expand Up @@ -135,7 +139,9 @@ def import_dashboards(path: str, username: Optional[str]) -> None:
)

if username is not None:
g.user = security_manager.find_user(username=username)
g.user = security_manager.find_user( # pylint: disable=assigning-non-slot
username=username
)
if is_zipfile(path):
with ZipFile(path) as bundle:
contents = get_contents_from_bundle(bundle)
Expand Down Expand Up @@ -299,7 +305,9 @@ def import_dashboards(path: str, recursive: bool, username: str) -> None:
elif path_object.exists() and recursive:
files.extend(path_object.rglob("*.json"))
if username is not None:
g.user = security_manager.find_user(username=username)
g.user = security_manager.find_user( # pylint: disable=assigning-non-slot
username=username
)
contents = {}
for path_ in files:
with open(path_) as file:
Expand Down
3 changes: 1 addition & 2 deletions superset/dashboards/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,11 @@ def export(self, **kwargs: Any) -> Response:
except DashboardNotFoundError:
return self.response_404()
buf.seek(0)

response = send_file(
buf,
mimetype="application/zip",
as_attachment=True,
attachment_filename=filename,
download_name=filename,
Copy link
Member Author

Choose a reason for hiding this comment

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

)
if token:
response.set_cookie(token, "done", max_age=600)
Expand Down
10 changes: 7 additions & 3 deletions superset/tasks/async_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@
def ensure_user_is_set(user_id: Optional[int]) -> None:
user_is_not_set = not (hasattr(g, "user") and g.user is not None)
if user_is_not_set and user_id is not None:
g.user = security_manager.get_user_by_id(user_id)
g.user = security_manager.get_user_by_id( # pylint: disable=assigning-non-slot
user_id
)
elif user_is_not_set:
g.user = security_manager.get_anonymous_user()
g.user = ( # pylint: disable=assigning-non-slot
security_manager.get_anonymous_user()
)


def set_form_data(form_data: Dict[str, Any]) -> None:
g.form_data = form_data
g.form_data = form_data # pylint: disable=assigning-non-slot


def _create_query_context_from_form(form_data: Dict[str, Any]) -> QueryContext:
Expand Down
16 changes: 6 additions & 10 deletions superset/utils/async_query_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ def validate_session(response: Response) -> Response:
session["async_user_id"] = user_id

sub = str(user_id) if user_id else None
token = self.generate_jwt({"channel": async_channel_id, "sub": sub})
token = jwt.encode(
{"channel": async_channel_id, "sub": sub},
self._jwt_secret,
algorithm="HS256",
)

response.set_cookie(
self._jwt_cookie_name,
Expand All @@ -146,21 +150,13 @@ def validate_session(response: Response) -> Response:

return response

def generate_jwt(self, data: Dict[str, Any]) -> str:
encoded_jwt = jwt.encode(data, self._jwt_secret, algorithm="HS256")
return encoded_jwt.decode("utf-8")

def parse_jwt(self, token: str) -> Dict[str, Any]:
data = jwt.decode(token, self._jwt_secret, algorithms=["HS256"])
return data

def parse_jwt_from_request(self, req: Request) -> Dict[str, Any]:
token = req.cookies.get(self._jwt_cookie_name)
if not token:
raise AsyncQueryTokenException("Token not preset")

try:
return self.parse_jwt(token)
return jwt.decode(token, self._jwt_secret, algorithms=["HS256"])
except Exception as ex:
logger.warning(ex)
raise AsyncQueryTokenException("Failed to parse token") from ex
Expand Down
2 changes: 1 addition & 1 deletion superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ def warm_up_cache( # pylint: disable=too-many-locals,no-self-use
force=True,
)

g.form_data = form_data
g.form_data = form_data # pylint: disable=assigning-non-slot
payload = obj.get_payload()
delattr(g, "form_data")
error = payload["errors"] or None
Expand Down
Loading