mlflow/mlflow · error · MlflowException
INVALID_PARAMETER_VALUE
INVALID_PARAMETER_VALUE
Error message
Dependencies schema should be set only once to the callback.
What it means
MLflow's DSPy callback stores a single dependencies schema used to enrich traces. Calling set_dependencies_schema() more than once on the same callback instance would silently overwrite tracing context, so MLflow raises INVALID_PARAMETER_VALUE on the second call.
Source
Thrown at mlflow/dspy/callback.py:76
# call_id: (LiveSpan, OTel token)
self._call_id_to_span: dict[str, SpanWithToken] = {}
self._call_id_to_module: dict[str, Any] = {}
###### state management for optimization process ######
# The current callback logic assumes there is no optimization running in parallel.
# The state management may not work when multiple optimizations are running in parallel.
# optimizer_stack_level is used to determine if the callback is called within compile
# we cannot use boolean flag because the callback can be nested
self.optimizer_stack_level = 0
# call_id: (key, step)
self._call_id_to_metric_key: dict[str, tuple[str, int]] = {}
self._evaluation_counter = defaultdict(int)
self._disabled_eval_call_ids = set()
self._eval_runs_started: set[str] = set()
def set_dependencies_schema(self, dependencies_schema: dict[str, Any]):
if self._dependencies_schema:
raise MlflowException(
"Dependencies schema should be set only once to the callback.",
error_code=MlflowException.INVALID_PARAMETER_VALUE,
)
self._dependencies_schema = dependencies_schema
@skip_if_trace_disabled
def on_module_start(self, call_id: str, instance: Any, inputs: dict[str, Any]):
span_type = self._get_span_type_for_module(instance)
attributes = self._get_span_attribute_for_module(instance)
# The __call__ method of dspy.Module has a signature of (self, *args, **kwargs),
# while all built-in modules only accepts keyword arguments. To avoid recording
# empty "args" key in the inputs, we remove it if it's empty.
if "args" in inputs and not inputs["args"]:
inputs.pop("args")
self._start_span(
call_id,View on GitHub (pinned to 6a27f2decc)
Solutions
- Call set_dependencies_schema only once per callback/tracer lifecycle (e.g. at app startup)
- Check whether the schema is already set before calling, or use a module-level 'initialized' flag
- Create a fresh callback instance if a new schema truly must be installed
- Remove duplicate invocations in per-request code paths
Example fix
// before
def handler(req):
mlflow.dspy.set_dependencies_schema(schema) # called every request
// after
init_schema():
mlflow.dspy.set_dependencies_schema(schema)
def handler(req):
pass # schema already installed at startup Defensive patterns
Strategy: validation
Validate before calling
_schema_installed = False
def install_schema(schema):
global _schema_installed
if _schema_installed:
return
mlflow.dspy.set_dependencies_schema(schema)
_schema_installed = True Try / catch
try:
callback.set_dependencies_schema(schema)
except MlflowException as e:
if 'only once' in str(e):
logger.debug('schema already set; skipping')
else:
raise Prevention
- Install the schema once at application startup, not per request
- Guard with an idempotency flag in shared/framework code
- Reset callback state between tests if reusing tracer fixtures
When it happens
Trigger: Invoking mlflow.dspy.set_dependencies_schema (via _set_dependency_schema_to_tracer) twice within one trace/session — e.g. calling it in both an initialization routine and a per-request handler with the same tracer/callback.
Common situations: A web app calls it at module import and again per request; a test suite reuses a tracer fixture across tests; framework autotuning re-invokes setup code on hot reload.
Related errors
- An MLflow Tracking URI is required, please provide the track
- An MLflow experiment ID is required, please provide the expe
- The MLflow Tracing client is not configured. Please call ini
- INVALID_PARAMETER_VALUE
- No deployments target has been set. Please either set the ML
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/a4290263cc7caf48.
Report an issue: GitHub.