yocto-gl
yocto-gl copied to clipboard
[BUG] `_check_requirement_satisfied()` ignores environment markers
Issues Policy acknowledgement
- [X] I have read and agree to submit bug reports in accordance with the issues policy
Where did you encounter this bug?
Local machine
Willingness to contribute
Yes. I can contribute a fix for this bug independently.
MLflow version
- Client: 2.17.0
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS Sonoma 14.7
- Python version: 3.12.0
Describe the problem
_check_requirement_satisfied()
does not check the Requirement
object to see if it actually needs to be installed in the current environment. Requirements can have environment markers like so:
colorama==0.4.6 ; python_version >= "3.12" and python_version < "3.13" and (platform_system == "Windows" or sys_platform == "win32")
This is very common when using requirements,txt
files that are exported from poetry
, for example.
You can evaluate whether the requirement is valid for the current detected environment by running req.marker.evaluate()
.
Tracking information
N/A
Code to reproduce issue
from langchain_core.runnables import RunnableLambda
import mlflow
from packaging.requirements import Requirement
import sys
toy_chain = RunnableLambda(lambda x: x)
req = "langchain==9.9.9 ; sys_platform == 'fake_platform'"
# confirm we are not on a platform called "fake_platform"
assert sys.platform != "fake_platform"
# confirm the environment marker indicates the requirement is not valid for this environment
assert not Requirement(req).marker.evaluate()
with mlflow.start_run():
mlflow.langchain.log_model(
lc_model=toy_chain,
artifact_path="chain",
registered_model_name="my_toy_model",
pip_requirements=[
req,
],
)
Stack trace
N/A
Other info / logs
The relevant warning from the minimal reproducible example I shared:
2024/10/17 14:43:06 WARNING mlflow.utils.requirements_utils: Detected one or more mismatches between the model's dependencies and the current Python environment:
- langchain (current: 0.1.20, required: langchain==9.9.9; sys_platform == "fake_platform")
To fix the mismatches, call `mlflow.pyfunc.get_model_dependencies(model_uri)` to fetch the model's environment and install dependencies using the resulting environment file.
What component(s) does this bug affect?
- [ ]
area/artifacts
: Artifact stores and artifact logging - [ ]
area/build
: Build and test infrastructure for MLflow - [ ]
area/deployments
: MLflow Deployments client APIs, server, and third-party Deployments integrations - [ ]
area/docs
: MLflow documentation pages - [ ]
area/examples
: Example code - [ ]
area/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registry - [X]
area/models
: MLmodel format, model serialization/deserialization, flavors - [ ]
area/recipes
: Recipes, Recipe APIs, Recipe configs, Recipe Templates - [ ]
area/projects
: MLproject format, project running backends - [ ]
area/scoring
: MLflow Model server, model deployment tools, Spark UDFs - [ ]
area/server-infra
: MLflow Tracking server backend - [ ]
area/tracking
: Tracking Service, tracking client APIs, autologging
What interface(s) does this bug affect?
- [ ]
area/uiux
: Front-end, user experience, plotting, JavaScript, JavaScript dev server - [ ]
area/docker
: Docker use across MLflow's components, such as MLflow Projects and MLflow Models - [ ]
area/sqlalchemy
: Use of SQLAlchemy in the Tracking Service or Model Registry - [ ]
area/windows
: Windows support
What language(s) does this bug affect?
- [ ]
language/r
: R APIs and clients - [ ]
language/java
: Java APIs and clients - [ ]
language/new
: Proposals for new client languages
What integration(s) does this bug affect?
- [ ]
integrations/azure
: Azure and Azure ML integrations - [ ]
integrations/sagemaker
: SageMaker integrations - [ ]
integrations/databricks
: Databricks integrations