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

Wheeled Model #6586

Merged
merged 9 commits into from
Sep 12, 2022
Merged

Wheeled Model #6586

merged 9 commits into from
Sep 12, 2022

Conversation

arjundc-db
Copy link
Contributor

@arjundc-db arjundc-db commented Aug 25, 2022

Signed-off-by: Arjun DCunha arjun.dcunha@databricks.com

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Add functionality to create a wheeled model where the dependencies are stored as wheels along with the model. Credit goes to anirudhachal-db who started this #6416
How to use:

  • With the helper function:
import mlflow.models.utils
mlflow.models.utils.add_libraries_to_model(<model_uri>)
  • Standalone
from mlflow.models.wheeled_model import WheeledModel
WheeledModel.log_model(<model_uri>, <optional_registered_model_name>)

How is this patch tested?

Unit tests have been added.
I also manually tested this functionality.

  • [ x] I have written tests (not required for typo or doc fix) and confirmed the proposed feature/bug-fix/change works.

Does this PR change the documentation?

  • [x ] No. You can skip the rest of this section.
  • Yes. Make sure the changed pages / sections render correctly by following the steps below.
  1. Click the Details link on the Preview docs check.
  2. Find the changed pages / sections and make sure they render correctly.

Release Notes

Is this a user-facing change?

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

Add functionality to create a wheeled model where the dependencies are stored as wheels along with the model.
(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
  • [ x] area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • [ x] area/models: MLmodel format, model serialization/deserialization, flavors
  • area/pipelines: Pipelines, Pipeline APIs, Pipeline configs, Pipeline 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
  • [ x] 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: Arjun DCunha <arjun.dcunha@databricks.com>
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
@github-actions github-actions bot added area/model-registry Model registry, model registry APIs, and the fluent client calls for model registry area/models MLmodel format, model serialization/deserialization, flavors rn/feature Mention under Features in Changelogs. labels Aug 25, 2022
os.makedirs(dst_path)

download_command = (
f"python -m pip wheel --only-binary=:all: --wheel-dir={dst_path} -r"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if there is a better mechanism?

os.makedirs(dst_path)

download_command = (
f"python -m pip wheel --only-binary=:all: --wheel-dir={dst_path} -r"
Copy link
Contributor

Choose a reason for hiding this comment

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

why the --only-binary flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was to prevent downloading source packages. I guess that wont be as big of a problem as I am imagine it, since sdist can be harder to work with?

mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
@dbczumar dbczumar requested a review from harupy August 31, 2022 22:20
mlflow/models/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
mlflow/models/utils.py Outdated Show resolved Hide resolved
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
mlflow/models/utils.py Outdated Show resolved Hide resolved
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.

@harupy
Copy link
Member

harupy commented Sep 9, 2022

I got the following warning when I served a model logged by add_libraries_to_model:

[2022-09-09 16:44:13 +0900] [68271] [INFO] Starting gunicorn 20.1.0
[2022-09-09 16:44:13 +0900] [68271] [INFO] Listening at: http://127.0.0.1:5000 (68271)
[2022-09-09 16:44:13 +0900] [68271] [INFO] Using worker: sync
[2022-09-09 16:44:13 +0900] [68277] [INFO] Booting worker with pid: 68277
2022/09/09 16:44:14 WARNING mlflow.pyfunc: Encountered an unexpected error (InvalidRequirement('Parse error at "\'/websock\'": Expected string_end')) while detecting model dependency mismatches. Set logging level to DEBUG to see the full traceback.

We can fix this in a follow-up PR.


Traceback:

Traceback (most recent call last):
  File "/home/haru/miniconda3/envs/mlflow-12e24ad657c7ce03802f8dd40170d80284174e0c/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/home/haru/miniconda3/envs/mlflow-12e24ad657c7ce03802f8dd40170d80284174e0c/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing/core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pkg_resources._vendor.pyparsing.exceptions.ParseException: Expected string_end, found '/'  (at char 6), (line:1, col:7)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/haru/Desktop/repositories/mlflow/mlflow/pyfunc/__init__.py", line 418, in _warn_dependency_requirement_mismatches
    mismatch_info = _check_requirement_satisfied(req_line)
  File "/home/haru/Desktop/repositories/mlflow/mlflow/utils/requirements_utils.py", line 458, in _check_requirement_satisfied
    req = pkg_resources.Requirement.parse(requirement_str)
  File "/home/haru/miniconda3/envs/mlflow-12e24ad657c7ce03802f8dd40170d80284174e0c/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3147, in parse
    req, = parse_requirements(s)
  File "/home/haru/miniconda3/envs/mlflow-12e24ad657c7ce03802f8dd40170d80284174e0c/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3102, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/home/haru/miniconda3/envs/mlflow-12e24ad657c7ce03802f8dd40170d80284174e0c/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 105, in __init__
    f'Parse error at "{ requirement_string[e.loc : e.loc + 8]!r}": {e.msg}'
pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'/websock'": Expected string_end

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
@arjundc-db arjundc-db merged commit b3a04ec into mlflow:master Sep 12, 2022
nnethery pushed a commit to nnethery/mlflow that referenced this pull request Feb 1, 2024
* Wheeled Model

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* Docs

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* Comments

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* More tests

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* English

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* Comments part 2

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* fix

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

* Haru Comments

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>

Signed-off-by: Arjun DCunha <arjun.dcunha@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/model-registry Model registry, model registry APIs, and the fluent client calls for model registry area/models MLmodel format, model serialization/deserialization, flavors rn/feature Mention under Features in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants