Open mohammadaffaneh opened 2 days ago
Wow, this is an amazing issue, thank you for taking the time to write everything up so carefully and thoroughly @mohammadaffaneh! 🌟
You are absolutely right about the current strengths and weaknesses in Vizro in providing this functionality. I've actually made very similar Vizro apps to what you describe, with Previous/Next buttons stepping through a form. They're internal dashboards but if you're interested I can try to dig them out and upload a sanitised version.
Something similar is already on our roadmap, although it might take a while before we get to something that closely resembles your Wizard
functionality, which has a lot of features!
Here's very roughly where I hope things will go:
Form
component or at least show how Container
can be used similarly, together with any remaining form input components. As you can from the files with prefix _
these have existed for a while but are not officially supported/documented yet although some people have used them already and they generally work fineCurrently the main thing stopping this from being developed is that we're busy reworking the actions system which I think will need to be more robust and flexible to handle this sort of thing. After that it's towards the top of our list of priorities, so no promises but hopefully at least some of this will be possible within a few months 🤞
One challenge here is that we need to develop something that is general enough to be useful across a variety of use cases while specific and powerful enough that it's easy to use for each person's individual use case. e.g. we would like to make it easier for a user to configure machine learning model parameters and then run a pipeline from Vizro. This is quite different from what you're trying to do but would need to use similar wizard/form components.
I have a few questions for you, just to understand your requirements a bit better:
Configurable steps that can be added or modified dynamically.
What do you mean by this? The sort of thing like form fields appearing/disappearing depending on the values of previously input fields?
Seamless integration with external databases or APIs.
Is this achieved just by connecting your custom_callbacks={'on_complete': some_completion_function}
to something that does request.post
or inserts a row into a database or similar? What else are you imagining here? e.g. maybe something that loads up a row from a database, allows the user to edit the values and then save back into the database?
The validation logic is applied dynamically using the validation_rules defined in each Step instance.
How would you expect this validation logic to be applied? On the server side or clientside? e.g. one good option here might be to use pydantic to do validation.
It's not exactly what you describe, but this may be of interest to you: https://community.plotly.com/t/dash-pydantic-form/84435/31
@antonymilne Thank you for your prompt and detailed response! I appreciate the insights you've shared and the effort you're putting into enhancing Vizro's capabilities.
Regarding your questions:
Configurable steps that can be added or modified dynamically.
What do you mean by this? The sort of thing like form fields appearing/disappearing depending on the values of previously input fields?
Answer:
By "configurable steps that can be added or modified dynamically," I mean the ability to adjust the wizard's flow based on user inputs or external data during runtime. This includes:
This functionality enables the creation of more personalized and efficient user experiences, similar to conditional routing in forms. And yes this can be achieved by changing the 'style' property of a component within a callback.
Seamless integration with external databases or APIs.
Is this achieved just by connecting your custom_callbacks={'on_complete': some_completion_function}
to something that does request.post
or inserts a row into a database or similar? What else are you imagining here? e.g., maybe something that loads up a row from a database, allows the user to edit the values, and then save back into the database?
Answer:
Yes, integrating with external databases or APIs would involve using callbacks to perform operations like requests.post
or database transactions. Additionally, I envision:
The validation logic is applied dynamically using the validation_rules
defined in each Step instance.
How would you expect this validation logic to be applied? On the server side or client-side? e.g., one good option here might be to use Pydantic to do validation.
Answer:
I anticipate a hybrid approach for validation:
This ensures robust validation while maintaining responsiveness and security.
Thank you again for your efforts and quick reply. I'm excited about the direction Vizro is heading and am happy to assist further or provide feedback on early implementations.
Thank you for all the answers @mohammadaffaneh, that's very helpful! 🙏 I think it will be a while before we can achieve many of the advanced features you're looking for here, but we'll definitely try and make some progress and refer back to these ideas when we develop the Form
component. FYI @maxschulz-COL.
Which package?
vizro
What's the problem this feature will solve?
Vizro excels at creating modular dashboards, but as users tackle more sophisticated applications, the need arises for reusable and extensible complex UI components. These include multi-step wizards with dynamic behavior, CRUD operations, and seamless integration with external systems. Currently, building such components requires significant effort, often resulting in custom, non-reusable code. This limits the scalability and maintainability of applications developed with Vizro.
I’m working on applications that require complex workflows, such as multi-step wizards with real-time input validation and CRUD operations. While I’ve managed to achieve this using Dash callbacks and custom Python code, the lack of modularity and reusability makes the process cumbersome. Every new project requires re-implementing these components, which is time-consuming and error-prone.
Describe the solution you'd like
I envision Vizro evolving to support the creation of highly reusable and extensible complex components, which could transform how users approach sophisticated Dash applications. Here’s what this could look like:
Object-Oriented Component Development: Provide the ability to encapsulate UI components and their logic (advanced dynamic callbacks) in Python classes, making them easy to reuse and extend across projects. This could be similar to the component architecture found in frameworks like React.
Modular Multi-Step Wizard: A powerful wizard component with:
Integrated CRUD Operations: Built-in support for Create, Read, Update, and Delete functionality, ensuring data security and consistency:
Dynamic Callback Management: Enable advanced callbacks that can be registered and updated dynamically, reducing the complexity of handling inter-component interactions.
Extensibility Features:
How This Could Enhance Vizro
By introducing such capabilities, Vizro would empower users to go beyond dashboards and build complex, enterprise-level applications more efficiently. These features could help attract a broader audience, including those who require not only dashboards but also robust, interactive data workflows in their data applications.
Similar Solutions for Inspiration
My imagination:
Below is an high-level and simple implementation of the multistep wizard, where all wizard components and functionalities are isolated into a class (
Wizard
) following the Facade Design Pattern, complemented by elements of the Factory Pattern and the State Pattern. This class dynamically creates the logic based on the parameters and integration with the steps. TheStep
class represents individual steps.wizard_module.py
app.py
Explanation:
Isolation of Components and Logic: All wizard functionalities, including rendering and navigation logic, are encapsulated within the
Wizard
class. Each step is represented by aStep
class instance.Dynamic Logic Creation: The
Wizard
class dynamically generates the layout and callbacks based on the steps provided. The validation logic is applied dynamically using thevalidation_rules
defined in eachStep
instance.Ease of Extension: To add more steps or modify existing ones, you simply need to create or update instances of the
Step
class. TheWizard
class handles the integration and navigation between steps without any additional changes.Validation Rules: Each
Step
contains avalidation_rules
list, which specifies which input components need to be validated. This allows for flexible validation logic that can be customized per step.Code of Conduct