-
-
Notifications
You must be signed in to change notification settings - Fork 645
Closed
Description
🐞 bug report
When trying to use external pip dependency mlflow, errors are thrown when code contains:
import mlflow
Is this a regression?
Not sure, I encountered this error while trying to migrate a repository from WORKSPACE rules_python to bzlmod with a test that uses mlflow. The test passes under WORKSPACE but fails under bzlmod. However, when I tried to recreate the issue in a minimal repro, the test fails under both WORKSPACE and bzlmod.
Description
When a py_test or py_binary contains:
import mlflow
the following error is thrown when running the code with bazel run or bazel test:
ImportError: cannot import name 'Resource' from 'mlflow.models.resources' (/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/rules_python++pip+pypi_312_mlflow_skinny/site-packages/mlflow/models/resources/__init__.py)
🔬 Minimal Reproduction
https://github.com/thirtyseven/mlflow-repro
bazel test :test
🔥 Exception or Error
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //:test
-----------------------------------------------------------------------------
Traceback (most recent call last):
File "/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/_main/test.py", line 1, in
import mlflow
File "/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/rules_python++pip+pypi_312_mlflow_skinny/site-packages/mlflow/__init__.py", line 35, in
from mlflow import (
File "/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/rules_python++pip+pypi_312_mlflow_skinny/site-packages/mlflow/models/__init__.py", line 46, in
from mlflow.models.model import Model, get_model_info, set_model, update_model_requirements
File "/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/rules_python++pip+pypi_312_mlflow_skinny/site-packages/mlflow/models/model.py", line 20, in
from mlflow.models.resources import Resource, ResourceType, _ResourceBuilder
ImportError: cannot import name 'Resource' from 'mlflow.models.resources' (/private/var/tmp/_bazel_tkaplan/5b13b869a536c448538040ea91145cae/sandbox/darwin-sandbox/1/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/rules_python++pip+pypi_312_mlflow_skinny/site-packages/mlflow/models/resources/__init__.py)
🌍 Your Environment
Operating System:
macOS 15.3.2
Output of bazel version:
Bazelisk version: 1.25.0
Build label: 8.1.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Feb 25 18:53:44 2025 (1740509624)
Build timestamp: 1740509624
Build timestamp as int: 1740509624
Rules_python version:
1.2.0
Anything else relevant?
hartikainen and mtylutkiroku
Metadata
Metadata
Assignees
Labels
No labels