mlflow: [BUG] log_artifact fails when tracking uri scheme is 'file'
Issues Policy acknowledgement
- I have read and agree to submit bug reports in accordance with the issues policy
Willingness to contribute
No. I cannot contribute a bug fix at this time.
MLflow version
- Client: 2.1.1
System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 22.04
- Python version: 3.9.12
Describe the problem
I’m using ml flow on localhost (as described here). When I call log_artifact for live run I get the following error :
mlflow.exceptions.MlflowException: The configured tracking uri scheme: 'file' is invalid for use with the proxy mlflow-artifact scheme. The allowed tracking schemes are: {'https', 'http'}
Tracking information
MLflow module location: /home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/__init__.py
Tracking URI: file:///efs/mlflow/mlruns
Registry URI: file:///efs/mlflow/mlruns
MLflow environment variables:
MLFLOW_EXPERIMENT_NAME: object_detection
MLflow dependencies:
Flask: 2.2.2
Jinja2: 3.1.2
alembic: 1.9.3
click: 8.1.3
cloudpickle: 2.2.1
databricks-cli: 0.17.4
docker: 6.0.1
entrypoints: 0.4
gitpython: 3.1.30
gunicorn: 20.1.0
importlib-metadata: 5.0.0
markdown: 3.4.1
matplotlib: 3.6.2
numpy: 1.23.4
packaging: 21.3
pandas: 1.5.1
protobuf: 3.20.3
pyarrow: 10.0.1
pytz: 2022.6
pyyaml: 6.0
querystring-parser: 1.2.4
requests: 2.27.1
scikit-learn: 1.2.1
scipy: 1.9.3
shap: 0.41.0
sqlalchemy: 1.4.46
sqlparse: 0.4.3
Code to reproduce issue
import mlflow
mlflow_exp_name = 'object_detection'
mlflow.set_tracking_uri('file:///efs/mlflow/mlruns')
os.environ['MLFLOW_EXPERIMENT_NAME'] = mlflow_exp_name
path_html = 'example.html'
with open(path_html, "w") as f:
f.write('')
with mlflow.start_run():
mlflow.log_artifact(path_html)
Stack trace
Traceback (most recent call last):
File "/efs/demo.py", line 36, in <module>
mlflow.log_artifact(path_html)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/tracking/fluent.py", line 776, in log_artifact
MlflowClient().log_artifact(run_id, local_path, artifact_path)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/tracking/client.py", line 1002, in log_artifact
self._tracking_client.log_artifact(run_id, local_path, artifact_path)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/tracking/_tracking_service/client.py", line 431, in log_artifact
artifact_repo = self._get_artifact_repo(run_id)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/tracking/_tracking_service/client.py", line 416, in _get_artifact_repo
artifact_repo = get_artifact_repository(artifact_uri)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/store/artifact/artifact_repository_registry.py", line 106, in get_artifact_repository
return _artifact_repository_registry.get_artifact_repository(artifact_uri)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/store/artifact/artifact_repository_registry.py", line 72, in get_artifact_repository
return repository(artifact_uri)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/store/artifact/mlflow_artifacts_repo.py", line 46, in __init__
super().__init__(self.resolve_uri(artifact_uri, get_tracking_uri()))
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/store/artifact/mlflow_artifacts_repo.py", line 61, in resolve_uri
_validate_uri_scheme(track_parse.scheme)
File "/home/ubuntu/miniconda3/lib/python3.9/site-packages/mlflow/store/artifact/mlflow_artifacts_repo.py", line 35, in _validate_uri_scheme
raise MlflowException(
mlflow.exceptions.MlflowException: The configured tracking uri scheme: 'file' is invalid for use with the proxy mlflow-artifact scheme. The allowed tracking schemes are: {'http', 'https'}
Process finished with exit code 1
Other info / logs
REPLACE_ME
What component(s) does this bug affect?
-
area/artifacts: Artifact stores and artifact logging -
area/build: Build and test infrastructure for MLflow -
area/docs: MLflow documentation pages -
area/examples: Example code -
area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry -
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
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 5
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Fix: [BUG] log_artifact fails when tracking uri scheme is 'file' (#7819) - Added a check to see if the tracking uri scheme is 'file' and if so, use the local artifact repository to log the artifact... — committed to Joel-hanson/mlflow by Joel-hanson a year ago
- Fix: [BUG] log_artifact fails when tracking uri scheme is 'file' (#7819) - Added a check to see if the tracking uri scheme is 'file' and if so, use the local artifact repository to log the artifact... — committed to Joel-hanson/mlflow by Joel-hanson a year ago
- Fix: [BUG] log_artifact fails when tracking uri scheme is 'file' (#7819) - Added a check to see if the tracking uri scheme is 'file' and if so, use the local artifact repository to log the artifact... — committed to Joel-hanson/mlflow by Joel-hanson a year ago
This worked for me. If you are using local files either of the below solutions should work. Add this before
mlflow.start_run()in your code.I have a similar problem, but the same stacktrace from …/artifact/… . I did:
$ mlflow gc --backend-store-uri=sqlite:///mlflow.dband I get the following error:
Hi @yossibiton, thank you for raising this issue. The problem appears to be that your MLflow experiment with name
object_detectionwas created using an HTTP request tomlflow serveror was created by manually specifying anmlflow-artifacts://URI as theartifact_location. In order to log artifacts to this experiment, you’ll need to run yourmlflow serverand set the MLflow Tracking URI to communicate with the MLflow server, e.g. something likemlflow.set_tracking_uri("http://127.0.0.1:5000").Thank you for using MLflow!
hey 👋🏻
I was following that article https://mlflow.org/docs/latest/quickstart_mlops.html. So I faced that issue. export MLFLOW_TRACKING_URI=http://127.0.0.1:5002 that command resolves the problem.
This issue can be solved by exporting the enviroment variable
MLFLOW_TRACKING_URI! 👍Hi everyone, I have recently faced the same issue while starting
mlflow uifrom my local docker container.I was following official mlflow tutorials, from this. The code is following:
Which outputs this traceback:
IMPORTANT, when I repeat this scenario with running
mlflow uifrom standard terminal (not a docker container), everything works fine.@yossibiton Any updates here? If you’re working on a PR, please link it to this issue.
@dean-sh has the right workaround. Essentially just make sure the tracking db points to anything other than its default location. --backend-store-uri mysql+pymysql://root@localhost/mlflow_tracking_database. Otherwise it seems to have a conflict over that route being used.
Any update? I’m trying to serve mlflow model using mlserver,
mlflow models serve -m runs:/df738f66448047aca9a6a2e8c6982ed9/model --enable-mlserverand getting the exact same error. My server is running with this config: