Hi, I have a gradio app that is deployed on databricks. The app is coming from this example provided by databricks. The app works fine, but when I want to add tracing I cannot get it to work. I keep getting the error
mlflow.exceptions.MlflowException: The provided MLFLOW_EXPERIMENT_ID environment variable value `--redacted-experiment-id` does not exist in the tracking server. Provide a valid experiment_id.
I'm setting the following environment variables:
{"name": "MODEL_SERVING_ENDPOINT", "value": endpoint_name},
{"name": "MLFLOW_TRACKING_URI", "value": "databricks"},
{"name": "MLFLOW_REGISTRY_URI", "value": "databricks-uc"},
{"name": "MLFLOW_EXPERIMENT_ID", "value": experiment_id_traces}
In the gradio code I've added the following lines
mlflow.openai.autolog()
@mlflow.trace(name="genai_gradio_interaction", span_type=SpanType.CHAT_MODEL)
def respond(message, history, dropdown๐
if len(message.strip()) == 0:
return "ERROR the question should not be empty"
try:
messages = []
if history:
for human, assistant in history:
messages.append(ChatMessage(content=human, role=ChatMessageRole.USER))
messages.append(ChatMessage(content=assistant, role=ChatMessageRole.ASSISTANT))
messages.append(ChatMessage(content=message, role=ChatMessageRole.USER))
response = w.serving_endpoints.query(name=dropdown,messages=messages,temperature=0.2,stream=False)
generated_text = response.choices[0].message.content
except Exception as error:
return f"ERROR requesting endpoint {dropdown}: {error}"
return generated_text
# Note indents could be wrong
My imports are
mlflow[databricks]>=3.1.0
databricks-sdk[openai]
The experimentId is coming from a experiment created in the UI. I don't understand why it cannot find the experiment. I also tried using the experiment name, but I get the same error message. What is the recommend way to get traces working in apps running on databricks?