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

Don't use max_age if Flask version is <2.0 #8463

Merged
merged 4 commits into from
May 22, 2023
Merged

Conversation

kevingreer
Copy link
Contributor

@kevingreer kevingreer commented May 18, 2023

Related Issues/PRs

Resolve #8456

What changes are proposed in this pull request?

The max_age keyword in flask.send_from_directory was introduced in Flask 2.0, which makes MLflow currently require Flask>=2.0. This PR checks what version of Flask is running and uses the old kwarg name if Flask is older than 2.0.

How is this patch tested?

(1) Run yarn build in mlflow/server/js to build the artifacts needed to run the UI
(2) Create a Dockerfile:

FROM python:3.8.10

RUN pip install flask==1.* && \
    # Other pins needed to get Flask<2 to work (with MLflow<2.3 but not 2.3)
    pip install jinja2==3.0.3 && \
    pip install itsdangerous==2.0.1 && \
    pip install werkzeug==2.0.3 && \
    pip install markupsafe==2.0.1

# RUN pip install mlflow==2.3.1
COPY mlflow/ ./mlflow
RUN pip install ./mlflow

EXPOSE 5000

CMD mlflow server --host 0.0.0.0 --port 5000

Build and run the image:

docker build -f Dockerfile . -t mlflow-issue-8456
docker run -p 5000:5000 mlflow-issue-8456:latest

Then navigate to 0.0.0.0:5000. Without this change there is an error and a blank page is shown. With this change the UI is shown.

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests (describe details, including test results, below)

Does this PR change the documentation?

  • No. You can skip the rest of this section.
  • Yes. Make sure the changed pages / sections render correctly in the documentation preview.

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Fix a bug that made MLflow mistakenly require Flask>=2.0

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

How should the PR be classified in the release notes? Choose one:

  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Signed-off-by: Kevin Greer <kevinegreer@gmail.com>
Copy link
Collaborator

@WeichenXu123 WeichenXu123 left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Kevin Greer <kevinegreer@gmail.com>
mlflow/server/__init__.py Outdated Show resolved Hide resolved
@github-actions
Copy link

@kevingreer Thank you for the contribution! Could you fix the following issue(s)?

⚠ DCO check

The DCO check failed. Please sign off your commit(s) by following the instructions here. See https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.md#sign-your-work for more details.

@mlflow-automation
Copy link
Collaborator

mlflow-automation commented May 19, 2023

Documentation preview for 9ba5470 will be available here when this CircleCI job completes successfully.

More info

@github-actions github-actions bot added area/server-infra MLflow Tracking server backend area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs. labels May 19, 2023
Signed-off-by: Kevin Greer <kevinegreer@gmail.com>
@kevingreer
Copy link
Contributor Author

The lint failure is unrelated to my change but I could change it if we want, please let me know.

@harupy
Copy link
Member

harupy commented May 20, 2023

I think it's related. Can you move from packaging.version import Version above from flask import __version__ as flask_version?

Signed-off-by: harupy <hkawamura0130@gmail.com>
@harupy harupy enabled auto-merge (squash) May 22, 2023 05:58
@harupy harupy merged commit 9125583 into mlflow:master May 22, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/server-infra MLflow Tracking server backend area/uiux Front-end, user experience, plotting, JavaScript, JavaScript dev server rn/bug-fix Mention under Bug Fixes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] MLflow 2.3 requires Flask>=2, but requirements file states Flask<3
4 participants