Skip to content

Support app factory for mlflow server app#8691

Merged
harupy merged 12 commits intomlflow:masterfrom
harupy:support-factory-in-auth
Jun 14, 2023
Merged

Support app factory for mlflow server app#8691
harupy merged 12 commits intomlflow:masterfrom
harupy:support-factory-in-auth

Conversation

@harupy
Copy link
Member

@harupy harupy commented Jun 10, 2023

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Support app factory in auth to avoid undesired app mutation.

How is this patch tested?

  • 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.

(Details in 1-2 sentences. You can just refer to another PR with a description if this PR is part of a larger change.)

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

@mlflow-automation
Copy link
Contributor

mlflow-automation commented Jun 10, 2023

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

More info

@github-actions github-actions bot added the rn/none List under Small Changes in Changelogs. label Jun 10, 2023
@harupy harupy force-pushed the support-factory-in-auth branch from 0157ac1 to 9d6cb8b Compare June 10, 2023 12:42
@harupy
Copy link
Member Author

harupy commented Jun 10, 2023

cc @gabrielfu



def _enable_auth(app: Flask):
def enable_auth(app: Flask = app):
Copy link
Member Author

Choose a reason for hiding this comment

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

The goal is to avoid accidental app mutation. In the original code, touching this module mutates the app. In the new code, it doesn't.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this looks great and is much easier to debug

@harupy harupy changed the title Support app factory in auth Support app factory for mlflow server app Jun 11, 2023
app = f"{__name__}:app"
else:
app = _find_app(app_name)
app = f"{app}()" if _is_factory(app) else app
Copy link
Collaborator

@gabrielfu gabrielfu Jun 12, 2023

Choose a reason for hiding this comment

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

i think waitress needs --call flag and doesn't need the ()

https://flask.palletsprojects.com/en/2.3.x/deploying/waitress/#running

Copy link
Collaborator

Choose a reason for hiding this comment

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

i got error when running a plugin app

1. Malformed application 'my_auth:create_app()'

Copy link
Member Author

Choose a reason for hiding this comment

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

On windows?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, let's see what happens if we remove () on windows. Pushing a commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, we need --call.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pushed another commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gabrielfu Did it work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes it's working now after putting --call before app name!

Copy link
Collaborator

@dbczumar dbczumar left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @harupy !

harupy added 12 commits June 14, 2023 17:52
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
Signed-off-by: harupy <[email protected]>
@harupy harupy force-pushed the support-factory-in-auth branch from 0575404 to aceb667 Compare June 14, 2023 08:52
@harupy harupy enabled auto-merge (squash) June 14, 2023 09:36
@harupy harupy merged commit 1889dc3 into mlflow:master Jun 14, 2023
@harupy harupy deleted the support-factory-in-auth branch June 14, 2023 11:48
BenWilson2 pushed a commit to BenWilson2/mlflow that referenced this pull request Jun 16, 2023
* Support app factory in auth

Signed-off-by: harupy <[email protected]>

* Add return doc

Signed-off-by: harupy <[email protected]>

* Update _init_server

Signed-off-by: harupy <[email protected]>

* Add run

Signed-off-by: harupy <[email protected]>

* Rename factory

Signed-off-by: harupy <[email protected]>

* Fix failed test

Signed-off-by: harupy <[email protected]>

* handle windows

Signed-off-by: harupy <[email protected]>

* Handle windows

Signed-off-by: harupy <[email protected]>

* Comment

Signed-off-by: harupy <[email protected]>

* Fix test_build_waitress_command

Signed-off-by: harupy <[email protected]>

* Refactor _build_gunicorn_command

Signed-off-by: harupy <[email protected]>

* Fix test_build_waitress_command

Signed-off-by: harupy <[email protected]>

---------

Signed-off-by: harupy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rn/none List under Small Changes in Changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants