-
Notifications
You must be signed in to change notification settings - Fork 144
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
Draft
maxschulz-COL
wants to merge
33
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.
Draft
Changes from 31 commits
Commits
Show all changes
33 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,36 @@ | ||
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() | ||
|
||
from vizro._themes._color_values import COLORS | ||
|
||
class ControlGroup(vm.VizroBaseModel): | ||
"""Container to group controls.""" | ||
df = px.data.gapminder() | ||
|
||
type: Literal["control_group"] = "control_group" | ||
title: str | ||
controls: List[ControlType] = [] | ||
|
||
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="Charts UI", | ||
components=[ | ||
vm.Graph(id="scatter", figure=px.scatter(df_gapminder, x="gdpPercap", y="lifeExp", size="pop")), | ||
vm.Card(text="Foo"), | ||
vm.Graph( | ||
id="gapminder", | ||
figure=px.bar( | ||
df, | ||
x="continent", | ||
y="gdpPercap", | ||
), | ||
), | ||
], | ||
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.Filter( | ||
targets=["gapminder"], | ||
column="continent", | ||
), | ||
], | ||
) | ||
|
||
dashboard = vm.Dashboard(pages=[page1]) | ||
dashboard = vm.Dashboard(pages=[page]) | ||
|
||
if __name__ == "__main__": | ||
Vizro().build(dashboard).run() |
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", | ||
|
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
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.
I guess these demo apps need manually checking because we don't have unit tests for them. It looks like they don't do anything complicated with pydantic though so hopefully they just work already.