-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Enhance predict
API to serve for env validation purpose.
#10759
Conversation
Documentation preview for 7d31b19 will be available here when this CircleCI job completes successfully. More info
|
from mlflow.utils.file_utils import TempDir | ||
|
||
|
||
def build_docker( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build_docker
has no change from the original definition in mlflow/models/__init__.py
. Just moved to avoid complicating __init__.py
.
model_uri: str, | ||
# TODO: This is currently subset of PyfuncInput, ideally we should cover all | ||
input_data: Union[str, Dict[str, Any], List[Any], "pd.DataFrame", None] = None, # noqa: F821 | ||
input_path: Optional[str] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated input_path and input_data arguments, as pandas read_csv
combined with StringIO is too permissive. For exampl,e pd.read_csv(StringIO("some-incorrect-file-path.csv"))
will be read as single column DF (while we want to say file not exists).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea; the API makes sense and is clear.
raise MlflowException.invalid_parameter_value( | ||
"Both input_data and input_path are provided. Only one of them should be specified." | ||
) | ||
elif input_data is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not elif input_data:
as this can be pandas dataframe, which doesn't allow casting to single boolean.
type=click.UNPROCESSED, | ||
callback=_resolve_env_manager, | ||
help=help_string, | ||
) | ||
|
||
|
||
ENV_MANAGER = _create_env_manager_option( | ||
default=_EnvManager.VIRTUALENV, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every cli command was using this default (by doing env_manager = env_manager or _EnvMangager.VIRTUALENV
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation!
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Co-authored-by: Ben Wilson <[email protected]> Signed-off-by: Yuki Watanabe <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
Signed-off-by: B-Step62 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
🛠 DevTools 🛠
Install mlflow from this PR
Checkout with GitHub CLI
What changes are proposed in this pull request?
Enhance
mlflow models predict
CLI command so that users can use it (more easily) for validating model environment before deployment.extra_pip_requirements
.pip-requirement-override
argument to both Python/CLI APIs, so that users can try additional/updated dependencies without having to create and log model (as Python only emits error one by one, this process can be very annoying otherwise).Note
Will work on OSS/Databricks docs as a follow-up.
How is this PR tested?
Verified the functionality works in Databricks. Note that it takes a bit log for the first time creating virtualenv (0:20~0:45 in the video).
Screen.Recording.2023-12-27.at.20.42.35.mov
In Databricks, I was able to test only with virtualenv as we don't have conda installed. For conda, I tested on devbox and it worked as same.
Does this PR require documentation update?
Will work on doc update.
Release Notes
Is this a user-facing change?
Enhanced
predict
API for MLflow Model so it can be used for inference environment validation before model deployment: (1) add Python API for the sake of notebook convenience (2) introducepip-requirement-overrides
argument to test dependency change (3) enrich error message.What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/artifacts
: Artifact stores and artifact loggingarea/build
: Build and test infrastructure for MLflowarea/deployments
: MLflow Deployments client APIs, server, and third-party Deployments integrationsarea/docs
: MLflow documentation pagesarea/examples
: Example codearea/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models
: MLmodel format, model serialization/deserialization, flavorsarea/recipes
: Recipes, Recipe APIs, Recipe configs, Recipe Templatesarea/projects
: MLproject format, project running backendsarea/scoring
: MLflow Model server, model deployment tools, Spark UDFsarea/server-infra
: MLflow Tracking server backendarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/docker
: Docker use across MLflow's components, such as MLflow Projects and MLflow Modelsarea/sqlalchemy
: Use of SQLAlchemy in the Tracking Service or Model Registryarea/windows
: Windows supportLanguage
language/r
: R APIs and clientslanguage/java
: Java APIs and clientslanguage/new
: Proposals for new client languagesIntegrations
integrations/azure
: Azure and Azure ML integrationsintegrations/sagemaker
: SageMaker integrationsintegrations/databricks
: Databricks integrationsHow 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" sectionrn/breaking-change
- The PR will be mentioned in the "Breaking Changes" sectionrn/feature
- A new user-facing feature worth mentioning in the release notesrn/bug-fix
- A user-facing bug fix worth mentioning in the release notesrn/documentation
- A user-facing documentation change worth mentioning in the release notes