Project injection in Dash callbacks#
This section covers common issues encountered when the solution project instance is not injected as expected into a Dash callback. See Project injection in callbacks for a description of the injection mechanism.
When encountering issues with project injection, follow these debugging steps:
Verify type hints: Ensure all callback arguments have proper type annotations.
Check Dash version: Confirm you’re using Dash 3.0.0 or higher:
import dash print(dash.__version__)
Validate project type: Make sure your project type annotation matches your solution class:
from ansys.solutions.your_solution.definition import YourSolution @callback(State("url", "pathname")) def my_callback(project: YourSolution): # Use your actual solution class pass
Check import statements: Ensure you’re importing the callback decorator from the correct module:
from ansys.saf.glow.client import callback # Correct import
Enable debug logging: Add logging to help diagnose issues:
import logging logging.basicConfig(level=logging.DEBUG) @callback(State("url", "pathname")) def my_callback(project: YourSolution): logging.debug(f"Project injected: {type(project)}") # Your callback logic pass