mlflow: [BUG] Log_params seems to not use the correct maximum length of value

Willingness to contribute

Yes. I would be willing to contribute a fix for this bug with guidance from the MLflow community.

MLflow version

1.27.0

System information

  • OS Platform and Distribution MacOS 12.1:
  • Python version 3.8.13:

Describe the problem

log_params seems to use different validation logic for max. parameter value length compared to log_param. According to doc, parameter value should support length up to 5000 but in fact 250 limit seems to be there. This passes:

some_params= {'p': [float(c) for c in range(int(45))]}
mlflow.log_param('p', some_params['p'])

But the same parameter logged with log_params will cause error

mlflow.log_params(some_params)

Tracking information

MLflow version: 1.27.0
Tracking URI: file:///***/mlflow-bug/mlruns
Artifact URI: file:///***/mlflow-bug/mlruns/0/726fe0e42d564b7a93e395cb81fa593f/artifacts

Code to reproduce issue

import mlflow

print("MLflow version:", mlflow.__version__)
print("Tracking URI:", mlflow.get_tracking_uri())
print("Artifact URI:", mlflow.get_artifact_uri())
r=45
some_params= {'p': [float(c) for c in range(int(r))]}
print("Length of stringified param", len((str(some_params['p']))))

mlflow.end_run()
with mlflow.start_run(experiment_id='0'):
    rid2 = mlflow.active_run().info.run_id
    mlflow.log_params(some_params)

Other info / logs

Traceback (most recent call last):
  File "repro_mini.py", line 13, in <module>
    mlflow.log_params(some_params)
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/tracking/fluent.py", line 675, in log_params
    MlflowClient().log_batch(run_id=run_id, metrics=[], params=params_arr, tags=[])
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/tracking/client.py", line 918, in log_batch
    self._tracking_client.log_batch(run_id, metrics, params, tags)
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/tracking/_tracking_service/client.py", line 315, in log_batch
    self.store.log_batch(
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/store/tracking/file_store.py", line 883, in log_batch
    _validate_batch_log_data(metrics, params, tags)
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/utils/validation.py", line 320, in _validate_batch_log_data
    _validate_param(param.key, param.value)
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/utils/validation.py", line 148, in _validate_param
    _validate_length_limit("Param value", MAX_PARAM_VAL_LENGTH, value)
  File "/Users/jan.sindlar/Library/Caches/pypoetry/virtualenvs/mlflow-bug-ZZrSkkBy-py3.8/lib/python3.8/site-packages/mlflow/utils/validation.py", line 268, in _validate_length_limit
    raise MlflowException(
mlflow.exceptions.MlflowException: Param value '[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0, 33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 4' had length 260, which exceeded length limit of 250

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/pipelines: Pipelines, Pipeline APIs, Pipeline configs, Pipeline 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: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 18 (7 by maintainers)

Most upvoted comments

@johnyNJ Please let us know if you need help with migration.