-
Notifications
You must be signed in to change notification settings - Fork 148
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
[Tidy] Bump to Pydantic V2 #917
Open
maxschulz-COL
wants to merge
43
commits into
main
Choose a base branch
from
feature/pydantic_v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
6f11390
Run bump-pydantic
maxschulz-COL 2cdb045
Un-v1 actions.py
maxschulz-COL bbaeae5
Do not fail on warnings
maxschulz-COL b90f165
Run bump-pydantic
maxschulz-COL 7ee047c
Un-v1 actions.py
maxschulz-COL b47fd4b
Do not fail on warnings
maxschulz-COL 48957af
Merge branch 'feature/pydantic_v2' of github.com:mckinsey/vizro into …
maxschulz-COL 28b3ffe
Refactor action and component models to use SkipJsonSchema for Captur…
maxschulz-COL 15aba94
Refactor model forward references to use model_rebuild
maxschulz-COL c77df9b
Refactor id validator to field_validator
maxschulz-COL 554afd3
Refactor validator usage in Dashboard model for Pydantic v2 compatibi…
maxschulz-COL ffef6dc
Refactor layout model to use field_validator and update regex to patt…
maxschulz-COL 03f9b09
Refactor imports in various models to remove Pydantic v1 compatibilit…
maxschulz-COL 4094e32
Remove Pydantic v1 compatibility code from test files and update impo…
maxschulz-COL b0f79f7
Refactor Parameter model to use AfterValidator via Annotated for targ…
maxschulz-COL a15e325
Refactor accordion model to remove Pydantic v1 compatibility code and…
maxschulz-COL b7dcd67
Refactor Dashboard and Navigation models to use Optional for nullable…
maxschulz-COL 3663293
Refactor Page model to use Optional for layout field and update Pydan…
maxschulz-COL 5052693
Refactor form, container, tabs, and page models to use conlist and Be…
maxschulz-COL 34651ae
Enable CapturedCallable as type
maxschulz-COL e93d6da
Fix Parameter model twith nested Annotated and AfterValidator to vali…
maxschulz-COL 180e75e
Merge branch 'main' into feature/pydantic_v2
maxschulz-COL 7158c01
Refactor remaining v1 out of code base
maxschulz-COL 286b039
Fix unit tests for Action and Checklist
maxschulz-COL 335c0b8
Fix form component unit tests
maxschulz-COL 4af444c
Merge branch 'main' into feature/pydantic_v2
maxschulz-COL 6b77fbf
Fix more form component unit tests
maxschulz-COL 8bff295
Fix remaining unit tests plus the Filter optional argument
maxschulz-COL f05c474
Fix remaining unit tests
maxschulz-COL 906a448
Align unit tests for CapturedCallable with new way of validating it
maxschulz-COL ee6722e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 46035b3
Refactor BaseModel.add_type
maxschulz-COL d6b11d9
Fix unit tests for types
maxschulz-COL a64d2cc
Refactor code to allow `_to_python` in V2
maxschulz-COL 3493a40
Finalise dashboard model file
maxschulz-COL 4fc0c3d
Finalise page, layout and container models
maxschulz-COL 5c2f7b9
Finalising the component models
maxschulz-COL 6bbf1b2
Finalise form component models (Checklist, Dropdown, Radio Items)
maxschulz-COL 3dd2eb9
Finalise form model (DatePicker, RangeSlider, Slider
maxschulz-COL e381c0b
Finalise accordion
maxschulz-COL 8291f82
Finalise filter
maxschulz-COL bf8534d
Finalise remaining models (Navigation, NavBar and NavLink)
maxschulz-COL 28a38b5
Clean up all remains
maxschulz-COL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,32 @@ | ||
from typing import List, Literal | ||
|
||
from dash import html | ||
|
||
import vizro.models as vm | ||
import vizro.plotly.express as px | ||
from dash import html | ||
from vizro import Vizro | ||
from vizro.models.types import ControlType | ||
|
||
df_gapminder = px.data.gapminder() | ||
|
||
|
||
class ControlGroup(vm.VizroBaseModel): | ||
"""Container to group controls.""" | ||
from vizro._themes._color_values import COLORS | ||
from vizro.actions import export_data | ||
|
||
type: Literal["control_group"] = "control_group" | ||
title: str | ||
controls: List[ControlType] = [] | ||
df = px.data.iris() | ||
|
||
def build(self): | ||
return html.Div( | ||
[html.H4(self.title), html.Hr()] + [control.build() for control in self.controls], | ||
) | ||
|
||
|
||
vm.Page.add_type("controls", ControlGroup) | ||
|
||
page1 = vm.Page( | ||
title="Relationship Analysis", | ||
page = vm.Page( | ||
title="Page 1", | ||
components=[ | ||
vm.Graph(id="scatter", figure=px.scatter(df_gapminder, x="gdpPercap", y="lifeExp", size="pop")), | ||
], | ||
controls=[ | ||
ControlGroup( | ||
title="Group A", | ||
controls=[ | ||
vm.Parameter( | ||
id="this", | ||
targets=["scatter.x"], | ||
selector=vm.Dropdown( | ||
options=["lifeExp", "gdpPercap", "pop"], multi=False, value="gdpPercap", title="Choose x-axis" | ||
), | ||
), | ||
vm.Parameter( | ||
targets=["scatter.y"], | ||
selector=vm.Dropdown( | ||
options=["lifeExp", "gdpPercap", "pop"], multi=False, value="lifeExp", title="Choose y-axis" | ||
), | ||
), | ||
], | ||
), | ||
ControlGroup( | ||
title="Group B", | ||
controls=[ | ||
vm.Parameter( | ||
targets=["scatter.size"], | ||
selector=vm.Dropdown( | ||
options=["lifeExp", "gdpPercap", "pop"], multi=False, value="pop", title="Choose bubble size" | ||
), | ||
) | ||
vm.Graph(figure=px.bar(df, x="sepal_width", y="sepal_length")), | ||
vm.Button( | ||
text="Export data", | ||
actions=[ | ||
vm.Action(function=export_data()), | ||
vm.Action(function=export_data()), | ||
], | ||
), | ||
], | ||
) | ||
|
||
dashboard = vm.Dashboard(pages=[page1]) | ||
dashboard = vm.Dashboard(pages=[page]) | ||
|
||
if __name__ == "__main__": | ||
Vizro().build(dashboard).run() | ||
# print(dashboard._to_python()) | ||
# print(dashboard.model_dump(context={"add_name": True})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,27 +13,13 @@ | |
from ._layout import Layout | ||
from ._page import Page | ||
|
||
Tabs.update_forward_refs(Container=Container) | ||
Container.update_forward_refs( | ||
AgGrid=AgGrid, Button=Button, Card=Card, Figure=Figure, Graph=Graph, Layout=Layout, Table=Table, Tabs=Tabs | ||
) | ||
Page.update_forward_refs( | ||
Accordion=Accordion, | ||
AgGrid=AgGrid, | ||
Button=Button, | ||
Card=Card, | ||
Container=Container, | ||
Figure=Figure, | ||
Filter=Filter, | ||
Graph=Graph, | ||
Parameter=Parameter, | ||
Table=Table, | ||
Tabs=Tabs, | ||
) | ||
Navigation.update_forward_refs(Accordion=Accordion, NavBar=NavBar, NavLink=NavLink) | ||
Dashboard.update_forward_refs(Page=Page, Navigation=Navigation) | ||
NavBar.update_forward_refs(NavLink=NavLink) | ||
NavLink.update_forward_refs(Accordion=Accordion) | ||
Tabs.model_rebuild() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these are removed entirely I presume things don't work? |
||
Container.model_rebuild() | ||
Page.model_rebuild() | ||
Navigation.model_rebuild() | ||
Dashboard.model_rebuild() | ||
NavBar.model_rebuild() | ||
NavLink.model_rebuild() | ||
|
||
__all__ = [ | ||
"Accordion", | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note so self, check on this