Skip to content
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

Cannot import mlflow #2702

Open
thirtyseven opened this issue Mar 25, 2025 · 0 comments
Open

Cannot import mlflow #2702

thirtyseven opened this issue Mar 25, 2025 · 0 comments

Comments

@thirtyseven
Copy link

thirtyseven commented Mar 25, 2025

🐞 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?

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

No branches or pull requests

1 participant