Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whats the relationship to FastUI✨ #280

Open
paddymul opened this issue Feb 13, 2024 · 1 comment
Open

Whats the relationship to FastUI✨ #280

paddymul opened this issue Feb 13, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@paddymul
Copy link

Is your feature request related to a problem? Please describe.
I'm writing to think here. Pydantic the comapny is working on FastUI but that seems more aimed at creating simple static websites. Samuel doesn't seem to be too familiar with ipywidgets or interested in supporting them.
pydantic/FastUI#51

I have a dataframe widget that I'm looking at doing a couple of things with.

  1. Continue supporting IPYwidgets
  2. Add more Pydantic typing to the widget code
  3. Possibly support FastUI

I would like that to be easier

Describe the solution you'd like
Could you show an example of supporting both with the minimal amount of extra code?

Describe alternatives you've considered
I'm also looking at porting my widget to streamlit and solara. Do they have a Pydantic story? Anything I should look at?

Additional context
N/A

@paddymul paddymul added the enhancement New feature or request label Feb 13, 2024
@jgunstone
Copy link
Collaborator

hi there @paddymul -

currently no relation to FastUI. I'm interested in it though and had previously spotted your issue - your message here prompted me to respond and also create this: pydantic/FastUI#197.

I'm not sure exactly what you're after... but here are some bits that are maybe of interest:

In terms of using pydantic with jupyter-widgets ... the landscape is a little confusing as traitlets fulfils much of the same functionality as pydantic in a widget context.
The way I do it is:

  • pydantic, data and validation of data. i.e. setting / validating data. + UI config.
  • Traitlets, anything relating to the UI.

when a ipyautoui form is built, kwargs stored in json_schema_extra are passed to ipyautoui traits - this is how I'm able to store form configuration in the pydantic model.

every form widget has a _value dict which is defined by the pydantic model. on change of the ui widget it updates, and then the whole value gets validated by the pydantic model, and then changes to the whole form then get passed back to the ui objects. this is a little complex (and could probs be done better) but is handled here:
https://github.com/maxfordham/ipyautoui/blob/main/src/ipyautoui/watch_validate.py

other:
have you seen pandera ? its pydantic for dataframes.
in ipyautoui i interpret the following type of pydantic model as a dataframe:
https://github.com/maxfordham/ipyautoui/blob/main/src/ipyautoui/demo_schemas/editable_datagrid.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants