Skip to content

Forward rest parameters to model#1921

Merged
sakoush merged 2 commits into
SeldonIO:masterfrom
idlefella:bugfix/fix-forwarding-params-to-model
Nov 19, 2024
Merged

Forward rest parameters to model#1921
sakoush merged 2 commits into
SeldonIO:masterfrom
idlefella:bugfix/fix-forwarding-params-to-model

Conversation

@idlefella

@idlefella idlefella commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

Pull Request

Fixes #1660

Description

The parameters sent over REST to the mlserver are not forwarded to the predict function of the model. This PR fixes that issue.

Changes Made

Properly forward the params to the predict function of the model.

Related Issues

Screenshots (if applicable)

Checklist

  • Code follows the project's style guidelines
  • All tests related to the changes pass successfully
  • Documentation is updated (if necessary)
  • Code is reviewed by at least one other team member
  • Any breaking changes are communicated and documented

Additional Notes

@idlefella idlefella changed the title Forwards rest parameters to model Forward rest parameters to model Oct 8, 2024
Comment on lines +199 to +202
params = None
if payload.parameters and payload.parameters.model_extra:
params = payload.parameters.model_extra
model_output = self._model.predict(decoded_payload, params=params)

@sakoush sakoush Oct 16, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a test that can be added for this new functionality @idlefella ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@idlefella I think params is only supported for class-based pyfunc models and therefore this proposed changed will not work for function-based models.
I think we need to find a way to check the type of the model loaded and not pass params for function-based models.
check here

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.

Hi @sakoush
Thanks for the comment. Ok then I will try to write a test for class-based and function-based models and see how or if these parameters can be forwarded. I hope to find time in the next couple of days.
Thanks!

@idlefella idlefella Oct 30, 2024

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.

Hi @sakoush, when the underlying model is a python function, then the function is wrapped into a _FunctionPythonModel:
https://github.com/mlflow/mlflow/blob/7d5dcf7e9b59c0ed8799024cae9c054634c616cd/mlflow/pyfunc/model.py#L142C1-L175C38
When params are set, the class prints a warning. So this doesn't cause any issues.
I also added some unittests for the forwarded params.

@sakoush sakoush left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks for your contribution @idlefella!

@sakoush
sakoush merged commit 7063618 into SeldonIO:master Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inference parameters are not passed to the predict function in MLFlow runtime

2 participants