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

Add document for model dependency management #10807

Merged
merged 7 commits into from
Jan 11, 2024

Conversation

B-Step62
Copy link
Collaborator

@B-Step62 B-Step62 commented Jan 10, 2024

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

pip install git+https://github.com/mlflow/mlflow.git@refs/pull/10807/merge

Checkout with GitHub CLI

gh pr checkout 10807

What changes are proposed in this pull request?

Add a new page for describing how to deploy additional dependencies or code modules with MLflow.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

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.

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/deployments: MLflow Deployments client APIs, server, and third-party Deployments integrations
  • 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/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/breaking-change - The PR will be mentioned in the "Breaking Changes" 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

Copy link

github-actions bot commented Jan 10, 2024

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

More info

@github-actions github-actions bot added area/docs Documentation issues rn/documentation Mention under Documentation Changes in Changelogs. labels Jan 10, 2024
However, in some cases, you may need to add or modify some dependencies. This page provides a high-level description of how MLflow manages
dependencies and guidance for how to customize dependencies for your use case.

.. contents:: Table of Contents
Copy link
Collaborator Author

@B-Step62 B-Step62 Jan 10, 2024

Choose a reason for hiding this comment

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

note: Showing table of contents as the side bar doesn't show indexes at this level.

Copy link
Member

Choose a reason for hiding this comment

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

Good idea.

cloudpickle==2.5.8
sklearn==1.3.1

.. note::
Copy link
Member

Choose a reason for hiding this comment

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

Let's add another warning here that manually declaring core dependencies for the model to function that are different from those that were used during training can be especially dangerous and prone to unexpected behavior.


.. note::

Once you log the model with custom dependencies, it is advisable to test prediction in sandbox environment using MLflow predict API,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Once you log the model with custom dependencies, it is advisable to test prediction in sandbox environment using MLflow predict API,
Once you log the model with custom dependencies, it is advisable to test prediction in sandbox environment using the MLflow predict API,

"using the MLflow predict API functionality, introduced in MLflow 2.10.0...." (just in case users of older versions try this great feature out and find that the API doesn't exist in their version of MLflow)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea! Should be also helpful for users on pre-installed environment like MLR.


One workaround for this issue is to use the parent directory instead, which means doing ``code_path=["src"]`` in this example.
This way, MLflow will copy the entire ``src/`` directory under ``code/`` and your model code will be able to import ``src.utils``.

Copy link
Member

Choose a reason for hiding this comment

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

Can we add a note for recommended file structures for dependent code inclusion? (we recommend including all dependent files in their own folder that is accessible from the main entry point of your training code, as a directory, that contains no other files or code structures that are not absolutely required for the proper functionality of your model) or something to that effect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I think what you mentioned is the recommended (or perhaps only viable) way for managing dependent code.

@BenWilson2
Copy link
Member

Fantastic job here @B-Step62 !! This is an overwhelmingly great improvement to some of the most often asked questions and confusing behavior, written up in a very easy-to-follow and clear direction. Great examples, too!

B-Step62 and others added 6 commits January 11, 2024 13:35
Signed-off-by: B-Step62 <[email protected]>

By the same reason, ``code_path`` option doesn't handle the relative import like ``code_path=["../src"]``.

Recommended Project Structure
Copy link
Member

Choose a reason for hiding this comment

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

Awesome!

Copy link
Member

@BenWilson2 BenWilson2 left a comment

Choose a reason for hiding this comment

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

Fantastic!

@BenWilson2 BenWilson2 merged commit 01a590f into mlflow:master Jan 11, 2024
32 checks passed
@B-Step62 B-Step62 deleted the model-doc branch January 15, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Documentation issues rn/documentation Mention under Documentation Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants