Skip to content

Commit a259664

Browse files
committed
global: prepare for future Flask upgrades
Prepare for future Flask breaking changes, in particular: - rename some parameters of `send_file`, as they will be removed in Flask 2.2 - fix how the Flask app is detected in our custom scripts, as `with_appcontext` will change behaviour in Flask 2.2
1 parent d60f9d1 commit a259664

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

reana_workflow_controller/rest/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from typing import Dict, List, Optional, Union
2929
from uuid import UUID
3030

31-
from flask import jsonify, request, send_file, send_from_directory
31+
from flask import jsonify, request, send_file
3232
from git import Repo
3333
from kubernetes.client.rest import ApiException
3434
from reana_commons import workspace
@@ -562,7 +562,7 @@ def _send_zipped_dir_or_files(workflow_name, dir_path=None, file_paths=None):
562562
memory_file.seek(0)
563563
return send_file(
564564
memory_file,
565-
attachment_filename=filename,
565+
download_name=filename,
566566
as_attachment=True,
567567
mimetype="application/zip",
568568
)
@@ -580,7 +580,7 @@ def _send_single_file(workspace_path: str, relative_file_path: str):
580580
workspace.open_file(workspace_path, relative_file_path, mode="rb"),
581581
mimetype=response_mime_type,
582582
as_attachment=response_mime_type == default_response_mime_type,
583-
attachment_filename=relative_file_path,
583+
download_name=relative_file_path,
584584
),
585585
200,
586586
)

scripts/generate_openapi_spec.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
from apispec import APISpec
1717
from apispec_webframeworks.flask import FlaskPlugin
1818
from flask import current_app
19-
from flask.cli import with_appcontext
2019
from reana_commons.utils import copy_openapi_specs
2120
from swagger_spec_validator.validator20 import validate_json
2221

2322
from reana_workflow_controller.version import __version__
23+
from reana_workflow_controller.app import app
2424

2525
# Import your marshmallow schemas here
2626
# from example_package.schemas import Example_schema,
@@ -44,7 +44,6 @@
4444
"E.g. --publish.",
4545
count=True,
4646
)
47-
@with_appcontext
4847
def build_openapi_spec(publish):
4948
"""Creates an OpenAPI definition of Flask application,
5049
check conformity of generated definition against OpenAPI 2.0 specification
@@ -108,4 +107,5 @@ def build_openapi_spec(publish):
108107

109108

110109
if __name__ == "__main__":
111-
build_openapi_spec()
110+
with app.app_context():
111+
build_openapi_spec()

0 commit comments

Comments
 (0)