Skip to content

Implemented unwrap_python_model() method in mlflow.pyfunc.PyFuncModel#6807

Merged
BenWilson2 merged 8 commits intomlflow:masterfrom
ikrizanic:implement-fr-6794
Sep 19, 2022
Merged

Implemented unwrap_python_model() method in mlflow.pyfunc.PyFuncModel#6807
BenWilson2 merged 8 commits intomlflow:masterfrom
ikrizanic:implement-fr-6794

Conversation

@ikrizanic
Copy link
Copy Markdown
Contributor

Signed-off-by: Ivan Križanić [email protected]

Related Issues/PRs

Close #6794

What changes are proposed in this pull request?

Implemented unwrap_python_model() method in mlflow.pyfunc.PyFuncModel class which enables direct access to wrapped python module when loading model with mlfow.pyfunc.load_model

How is this patch tested?

There are no dedicated tests for this method, but it's tested by using it in an appropriate workflow.

Does this PR change the documentation?

  • 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.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Users are now able to load wrapped python model when using mlflow.pyfunc.load_model() method and use custom implemented methods of that object.

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

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot added area/models MLmodel format, model serialization/deserialization, flavors rn/none List under Small Changes in Changelogs. labels Sep 15, 2022
marginTop: '0',
width: '100%',
height: '100%',
padding: '5px',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is unintentional, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes it is, I wasnt aware of any other files in this commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you revert this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe I should've reverted the whole commit and not just the change

Copy link
Copy Markdown
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.

Can you add tests that validate that the object returned from this unwrapping generates the same predictions as a base model object and that object attributes match?

@ikrizanic
Copy link
Copy Markdown
Contributor Author

Can you add tests that validate that the object returned from this unwrapping generates the same predictions as a base model object and that object attributes match?

I added test in new file test_pyfunc_class_methods.py

shraddhafalane and others added 8 commits September 16, 2022 16:57
* Added padding to artifact text viewer

Signed-off-by: Shraddha Falane <[email protected]>

* Modified padding for artifact text viewer

Signed-off-by: Shraddha Falane <[email protected]>

Signed-off-by: Shraddha Falane <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Co-authored-by: Ben Wilson <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Copy link
Copy Markdown
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.

LGTM! Thanks for the contribution!

@BenWilson2 BenWilson2 merged commit 78739f7 into mlflow:master Sep 19, 2022
@ikrizanic
Copy link
Copy Markdown
Contributor Author

Thank you for your help!

@ikrizanic ikrizanic deleted the implement-fr-6794 branch September 20, 2022 06:55
nnethery pushed a commit to nnethery/mlflow that referenced this pull request Feb 1, 2024
…el (mlflow#6807)

* Added padding to artifact text viewer (mlflow#6778)

* Added padding to artifact text viewer

Signed-off-by: Shraddha Falane <[email protected]>

* Modified padding for artifact text viewer

Signed-off-by: Shraddha Falane <[email protected]>

Signed-off-by: Shraddha Falane <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>

* Implemented `unwrap_python_model()` method in mlflow.pyfunc.PyFuncModel

Signed-off-by: Ivan Križanić <[email protected]>

* Simplified unwrap_python_model and added test for it

Signed-off-by: Ivan Križanić <[email protected]>

* Fixed lint and test errors

Signed-off-by: Ivan Križanić <[email protected]>

* Remove unused imports

Signed-off-by: Ivan Križanić <[email protected]>

* Update mlflow/pyfunc/__init__.py

Co-authored-by: Ben Wilson <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>

* reverted change in ShowArtifactTextView.js

Signed-off-by: Ivan Križanić <[email protected]>

* Optimized imports and reformated with black

Signed-off-by: Ivan Križanić <[email protected]>

Signed-off-by: Shraddha Falane <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Signed-off-by: Ivan Križanić <[email protected]>
Co-authored-by: Shraddha Falane <[email protected]>
Co-authored-by: Ivan Križanić <[email protected]>
Co-authored-by: Ben Wilson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/models MLmodel format, model serialization/deserialization, flavors rn/none List under Small Changes in Changelogs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Add possibility to unwrap python_model from PyFuncModel class

3 participants