[BUG] _compture_modules can't import modules from code_paths #14145
Labels
area/models
MLmodel format, model serialization/deserialization, flavors
bug
Something isn't working
Issues Policy acknowledgement
Where did you encounter this bug?
Local machine
MLflow version
System information
Describe the problem
I log pyfunc with loader_module and code_paths:
mlflow.pyfunc.log_model(artifact_path="scripted_model", loader_module="wrapper", data_path="scripted_model/model.pth", code_paths=["inference/wrapper.py"])
MLflow try to determine which packages are imported and run
_capture_modules.py
. However, it executes with an error:ModuleNotFoundError: No module named 'wrapper'
I thought this was a strange behavior, because
mlflow.pyfunc.load_model
could importwrapper
. Then I noticed that before importingwrapper
it adds code_paths to system_path_add_code_from_conf_to_system_path(local_path, conf, code_key=CODE)
.So the import error in
_capture_modules.py
can be solved by adding code_paths to system_path.Tracking information
System information: Linux #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 Python version: 3.11.11 MLflow version: 2.19.0 MLflow module location: /home/xdoomi/work/notebooks/investigate_pyfunc/.venv/lib/python3.11/site-packages/mlflow/__init__.py Tracking URI: http://localhost:8000 Registry URI: http://localhost:8000 MLflow environment variables: MLFLOW_TRACKING_URI: http://localhost:8000 MLflow dependencies: Flask: 3.1.0 Jinja2: 3.1.5 alembic: 1.14.0 docker: 7.1.0 graphene: 3.4.3 gunicorn: 23.0.0 markdown: 3.7 matplotlib: 3.10.0 mlflow-skinny: 2.19.0 numpy: 2.2.0 pandas: 2.2.3 pyarrow: 18.1.0 scikit-learn: 1.6.0 scipy: 1.14.1 sqlalchemy: 2.0.36
Code to reproduce issue
Stack trace
Other info / logs
What component(s) does this bug affect?
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, autologgingWhat interface(s) does this bug affect?
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 supportWhat language(s) does this bug affect?
language/r
: R APIs and clientslanguage/java
: Java APIs and clientslanguage/new
: Proposals for new client languagesWhat integration(s) does this bug affect?
integrations/azure
: Azure and Azure ML integrationsintegrations/sagemaker
: SageMaker integrationsintegrations/databricks
: Databricks integrationsThe text was updated successfully, but these errors were encountered: