From 7f3e672d891a419ee1eb3ea6066e54671603c808 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Fri, 1 Dec 2023 16:35:36 +0000 Subject: [PATCH 01/23] Try to bump version --- .pre-commit-config.yaml | 2 +- ...0231201_155112_antony.milne_pydantic_v2.md | 48 +++++++++++++++++++ vizro-core/pyproject.toml | 2 +- vizro-core/src/vizro/__init__.py | 2 +- .../src/vizro/models/_action/_action.py | 6 ++- .../vizro/models/_action/_actions_chain.py | 5 +- vizro-core/src/vizro/models/_base.py | 12 +++-- .../src/vizro/models/_components/_form.py | 6 ++- .../src/vizro/models/_components/button.py | 6 ++- .../src/vizro/models/_components/card.py | 6 ++- .../vizro/models/_components/form/_alert.py | 6 ++- .../models/_components/form/_user_input.py | 6 ++- .../models/_components/form/checklist.py | 6 ++- .../vizro/models/_components/form/dropdown.py | 6 ++- .../models/_components/form/radio_items.py | 6 ++- .../models/_components/form/range_slider.py | 6 ++- .../vizro/models/_components/form/slider.py | 6 ++- .../src/vizro/models/_components/graph.py | 6 ++- .../src/vizro/models/_components/table.py | 6 ++- .../src/vizro/models/_controls/filter.py | 6 ++- .../src/vizro/models/_controls/parameter.py | 5 +- vizro-core/src/vizro/models/_dashboard.py | 6 ++- vizro-core/src/vizro/models/_layout.py | 6 ++- .../src/vizro/models/_navigation/accordion.py | 6 ++- .../src/vizro/models/_navigation/nav_bar.py | 6 ++- .../src/vizro/models/_navigation/nav_link.py | 6 ++- .../vizro/models/_navigation/navigation.py | 6 ++- vizro-core/src/vizro/models/_page.py | 6 ++- vizro-core/src/vizro/models/types.py | 12 +++-- .../unit/vizro/models/_action/test_action.py | 6 ++- .../models/_components/form/test_checklist.py | 6 ++- .../models/_components/form/test_dropdown.py | 6 ++- .../_components/form/test_radioitems.py | 6 ++- .../_components/form/test_range_slider.py | 6 ++- .../models/_components/form/test_slider.py | 6 ++- .../vizro/models/_components/test_card.py | 6 ++- .../vizro/models/_components/test_graph.py | 6 ++- .../vizro/models/_components/test_table.py | 6 ++- .../models/_navigation/test_accordion.py | 6 ++- .../vizro/models/_navigation/test_nav_bar.py | 6 ++- .../vizro/models/_navigation/test_nav_item.py | 6 ++- .../models/_navigation/test_navigation.py | 6 ++- .../tests/unit/vizro/models/test_base.py | 6 ++- .../tests/unit/vizro/models/test_dashboard.py | 6 ++- .../tests/unit/vizro/models/test_layout.py | 6 ++- .../tests/unit/vizro/models/test_page.py | 6 ++- .../tests/unit/vizro/models/test_types.py | 6 ++- 47 files changed, 272 insertions(+), 50 deletions(-) create mode 100644 vizro-core/changelog.d/20231201_155112_antony.milne_pydantic_v2.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df8064356..486f03f29 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: - id: mypy files: ^vizro-core/src/ additional_dependencies: - - pydantic>=1.10.13, <2 + - pydantic>=2 - repo: https://github.com/gitleaks/gitleaks rev: v8.16.4 diff --git a/vizro-core/changelog.d/20231201_155112_antony.milne_pydantic_v2.md b/vizro-core/changelog.d/20231201_155112_antony.milne_pydantic_v2.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-core/changelog.d/20231201_155112_antony.milne_pydantic_v2.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-core/pyproject.toml b/vizro-core/pyproject.toml index b65a2586f..6258bc056 100644 --- a/vizro-core/pyproject.toml +++ b/vizro-core/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ # 2.11 needed for https://dash.plotly.com/dash-in-jupyter "dash_bootstrap_components", "pandas", - "pydantic>=1.10.13, <2", # must be synced with pre-commit mypy hook + "pydantic>=1.10.13", # must be synced with pre-commit mypy hook "dash_daq", "ipython>=8.10.0", # not directly required, pinned by Snyk to avoid a vulnerability: https://app.snyk.io/vuln/SNYK-PYTHON-IPYTHON-3318382 "numpy>=1.22.2", # not directly required, pinned by Snyk to avoid a vulnerability: https://security.snyk.io/vuln/SNYK-PYTHON-NUMPY-2321970 diff --git a/vizro-core/src/vizro/__init__.py b/vizro-core/src/vizro/__init__.py index 35cc3b86b..de001d411 100644 --- a/vizro-core/src/vizro/__init__.py +++ b/vizro-core/src/vizro/__init__.py @@ -5,6 +5,6 @@ __all__ = ["Vizro"] -__version__ = "0.1.7.dev0" +__version__ = "0.1.7.dev1" logging.basicConfig(level=os.getenv("VIZRO_LOG_LEVEL", "WARNING")) diff --git a/vizro-core/src/vizro/models/_action/_action.py b/vizro-core/src/vizro/models/_action/_action.py index 6f9800a1e..8a93c295a 100644 --- a/vizro-core/src/vizro/models/_action/_action.py +++ b/vizro-core/src/vizro/models/_action/_action.py @@ -3,7 +3,11 @@ from typing import Any, Dict, List from dash import Input, Output, State, callback, ctx, html -from pydantic import Field, validator + +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator import vizro.actions from vizro.managers._model_manager import ModelID diff --git a/vizro-core/src/vizro/models/_action/_actions_chain.py b/vizro-core/src/vizro/models/_action/_actions_chain.py index 57f193190..ebbbed4a1 100644 --- a/vizro-core/src/vizro/models/_action/_actions_chain.py +++ b/vizro-core/src/vizro/models/_action/_actions_chain.py @@ -1,7 +1,10 @@ from functools import partial from typing import Any, Dict, List, NamedTuple -from pydantic import validator +try: + from pydantic.v1 import validator +except ImportError: + from pydantic import validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_base.py b/vizro-core/src/vizro/models/_base.py index a46f04367..6e1b90d70 100644 --- a/vizro-core/src/vizro/models/_base.py +++ b/vizro-core/src/vizro/models/_base.py @@ -1,8 +1,14 @@ from typing import Any, List, Type, Union -from pydantic import BaseModel, Field, validator -from pydantic.fields import SHAPE_LIST, ModelField -from pydantic.typing import get_args +try: + from pydantic.v1 import BaseModel, Field, validator + from pydantic.v1.fields import SHAPE_LIST, ModelField + from pydantic.v1.typing import get_args +except ImportError: + from pydantic import BaseModel, Field, validator + from pydantic.fields import SHAPE_LIST, ModelField + from pydantic.typing import get_args + from typing_extensions import Annotated from vizro.managers import model_manager diff --git a/vizro-core/src/vizro/models/_components/_form.py b/vizro-core/src/vizro/models/_components/_form.py index 3ee9c1cd5..9b5ec01d5 100644 --- a/vizro-core/src/vizro/models/_components/_form.py +++ b/vizro-core/src/vizro/models/_components/_form.py @@ -3,7 +3,11 @@ from typing import TYPE_CHECKING, List, Literal, Optional from dash import html -from pydantic import validator + +try: + from pydantic.v1 import validator +except ImportError: + from pydantic import validator from vizro.models import VizroBaseModel from vizro.models._components.form import ( diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 140c7e7e7..7f5468a30 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -2,7 +2,11 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic import Field + +try: + from pydantic.v1 import Field +except ImportError: + from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/card.py b/vizro-core/src/vizro/models/_components/card.py index c1f850008..babe00598 100644 --- a/vizro-core/src/vizro/models/_components/card.py +++ b/vizro-core/src/vizro/models/_components/card.py @@ -2,7 +2,11 @@ import dash_bootstrap_components as dbc from dash import dcc, get_relative_path, html -from pydantic import Field + +try: + from pydantic.v1 import Field +except ImportError: + from pydantic import Field from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call diff --git a/vizro-core/src/vizro/models/_components/form/_alert.py b/vizro-core/src/vizro/models/_components/form/_alert.py index fbd6d21cd..4a1e2fc1c 100644 --- a/vizro-core/src/vizro/models/_components/form/_alert.py +++ b/vizro-core/src/vizro/models/_components/form/_alert.py @@ -2,7 +2,11 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic import Field + +try: + from pydantic.v1 import Field +except ImportError: + from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._models_utils import _log_call diff --git a/vizro-core/src/vizro/models/_components/form/_user_input.py b/vizro-core/src/vizro/models/_components/form/_user_input.py index fa3890d1d..7ca4f7633 100644 --- a/vizro-core/src/vizro/models/_components/form/_user_input.py +++ b/vizro-core/src/vizro/models/_components/form/_user_input.py @@ -2,7 +2,11 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic import Field + +try: + from pydantic.v1 import Field +except ImportError: + from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/form/checklist.py b/vizro-core/src/vizro/models/_components/form/checklist.py index 0c6afff28..bd240b1f9 100644 --- a/vizro-core/src/vizro/models/_components/form/checklist.py +++ b/vizro-core/src/vizro/models/_components/form/checklist.py @@ -1,7 +1,11 @@ from typing import List, Literal, Optional from dash import dcc, html -from pydantic import Field, PrivateAttr, root_validator, validator + +try: + from pydantic.v1 import Field, PrivateAttr, root_validator, validator +except ImportError: + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/form/dropdown.py b/vizro-core/src/vizro/models/_components/form/dropdown.py index 2b2a84dd8..14eeec9e5 100755 --- a/vizro-core/src/vizro/models/_components/form/dropdown.py +++ b/vizro-core/src/vizro/models/_components/form/dropdown.py @@ -1,7 +1,11 @@ from typing import List, Literal, Optional, Union from dash import dcc, html -from pydantic import Field, PrivateAttr, root_validator, validator + +try: + from pydantic.v1 import Field, PrivateAttr, root_validator, validator +except ImportError: + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/form/radio_items.py b/vizro-core/src/vizro/models/_components/form/radio_items.py index 0fa6733d2..b19538d84 100644 --- a/vizro-core/src/vizro/models/_components/form/radio_items.py +++ b/vizro-core/src/vizro/models/_components/form/radio_items.py @@ -1,7 +1,11 @@ from typing import List, Literal, Optional from dash import dcc, html -from pydantic import Field, PrivateAttr, root_validator, validator + +try: + from pydantic.v1 import Field, PrivateAttr, root_validator, validator +except ImportError: + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/form/range_slider.py b/vizro-core/src/vizro/models/_components/form/range_slider.py index 6249aba22..69b45cd57 100644 --- a/vizro-core/src/vizro/models/_components/form/range_slider.py +++ b/vizro-core/src/vizro/models/_components/form/range_slider.py @@ -1,7 +1,11 @@ from typing import Dict, List, Literal, Optional from dash import ClientsideFunction, Input, Output, State, clientside_callback, dcc, html -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/form/slider.py b/vizro-core/src/vizro/models/_components/form/slider.py index 687f51491..862b5b1dc 100644 --- a/vizro-core/src/vizro/models/_components/form/slider.py +++ b/vizro-core/src/vizro/models/_components/form/slider.py @@ -1,7 +1,11 @@ from typing import Dict, List, Literal, Optional from dash import ClientsideFunction, Input, Output, State, clientside_callback, dcc, html -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory diff --git a/vizro-core/src/vizro/models/_components/graph.py b/vizro-core/src/vizro/models/_components/graph.py index 33b5dbe09..28a86dcac 100644 --- a/vizro-core/src/vizro/models/_components/graph.py +++ b/vizro-core/src/vizro/models/_components/graph.py @@ -4,7 +4,11 @@ from dash import ctx, dcc from dash.exceptions import MissingCallbackContextException from plotly import graph_objects as go -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator import vizro.plotly.express as px from vizro import _themes as themes diff --git a/vizro-core/src/vizro/models/_components/table.py b/vizro-core/src/vizro/models/_components/table.py index 79addb8b1..03ea4a6a3 100644 --- a/vizro-core/src/vizro/models/_components/table.py +++ b/vizro-core/src/vizro/models/_components/table.py @@ -3,7 +3,11 @@ from dash import dash_table, dcc, html from pandas import DataFrame -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator import vizro.tables as vt from vizro.managers import data_manager diff --git a/vizro-core/src/vizro/models/_controls/filter.py b/vizro-core/src/vizro/models/_controls/filter.py index f3d90c284..8ecd6f224 100644 --- a/vizro-core/src/vizro/models/_controls/filter.py +++ b/vizro-core/src/vizro/models/_controls/filter.py @@ -4,7 +4,11 @@ import pandas as pd from pandas.api.types import is_numeric_dtype -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator from vizro._constants import FILTER_ACTION_PREFIX from vizro.actions import _filter diff --git a/vizro-core/src/vizro/models/_controls/parameter.py b/vizro-core/src/vizro/models/_controls/parameter.py index 9c61b3135..037c27b8e 100644 --- a/vizro-core/src/vizro/models/_controls/parameter.py +++ b/vizro-core/src/vizro/models/_controls/parameter.py @@ -1,6 +1,9 @@ from typing import List, Literal -from pydantic import Field, validator +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator from vizro._constants import PARAMETER_ACTION_PREFIX from vizro.actions import _parameter diff --git a/vizro-core/src/vizro/models/_dashboard.py b/vizro-core/src/vizro/models/_dashboard.py index d6f4fefcd..b65e86a8a 100644 --- a/vizro-core/src/vizro/models/_dashboard.py +++ b/vizro-core/src/vizro/models/_dashboard.py @@ -8,7 +8,11 @@ import dash_bootstrap_components as dbc import dash_daq as daq from dash import ClientsideFunction, Input, Output, clientside_callback, get_relative_path, html -from pydantic import Field, validator + +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator import vizro from vizro._constants import MODULE_PAGE_404, STATIC_URL_PREFIX diff --git a/vizro-core/src/vizro/models/_layout.py b/vizro-core/src/vizro/models/_layout.py index 0bc22e43e..6bca0f0ba 100644 --- a/vizro-core/src/vizro/models/_layout.py +++ b/vizro-core/src/vizro/models/_layout.py @@ -2,7 +2,11 @@ import numpy as np from numpy import ma -from pydantic import Field, PrivateAttr, ValidationError, validator + +try: + from pydantic.v1 import Field, PrivateAttr, ValidationError, validator +except ImportError: + from pydantic import Field, PrivateAttr, ValidationError, validator from vizro._constants import EMPTY_SPACE_CONST from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_navigation/accordion.py b/vizro-core/src/vizro/models/_navigation/accordion.py index 4bd374444..8c2b1914c 100644 --- a/vizro-core/src/vizro/models/_navigation/accordion.py +++ b/vizro-core/src/vizro/models/_navigation/accordion.py @@ -5,7 +5,11 @@ import dash import dash_bootstrap_components as dbc from dash import html -from pydantic import Field, validator + +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator from vizro._constants import ACCORDION_DEFAULT_TITLE from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_navigation/nav_bar.py b/vizro-core/src/vizro/models/_navigation/nav_bar.py index 270fe0f1e..a95df89e3 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_bar.py +++ b/vizro-core/src/vizro/models/_navigation/nav_bar.py @@ -4,7 +4,11 @@ from typing import Dict, List, Literal from dash import html -from pydantic import Field, validator + +try: + from pydantic.v1 import Field, validator +except ImportError: + from pydantic import Field, validator from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call diff --git a/vizro-core/src/vizro/models/_navigation/nav_link.py b/vizro-core/src/vizro/models/_navigation/nav_link.py index fd899bcb5..1b644e3a6 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_link.py +++ b/vizro-core/src/vizro/models/_navigation/nav_link.py @@ -5,7 +5,11 @@ import dash import dash_bootstrap_components as dbc from dash import html -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: + from pydantic import Field, PrivateAttr, validator from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call diff --git a/vizro-core/src/vizro/models/_navigation/navigation.py b/vizro-core/src/vizro/models/_navigation/navigation.py index a243862f4..77e0db9c8 100644 --- a/vizro-core/src/vizro/models/_navigation/navigation.py +++ b/vizro-core/src/vizro/models/_navigation/navigation.py @@ -1,7 +1,11 @@ from __future__ import annotations from dash import html -from pydantic import validator + +try: + from pydantic.v1 import validator +except ImportError: + from pydantic import validator from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call diff --git a/vizro-core/src/vizro/models/_page.py b/vizro-core/src/vizro/models/_page.py index df1da26b9..e947aca45 100644 --- a/vizro-core/src/vizro/models/_page.py +++ b/vizro-core/src/vizro/models/_page.py @@ -3,7 +3,11 @@ from typing import List, Optional, TypedDict from dash import Input, Output, Patch, callback, dcc, html -from pydantic import Field, root_validator, validator + +try: + from pydantic.v1 import Field, root_validator, validator +except ImportError: + from pydantic import Field, root_validator, validator from vizro._constants import ON_PAGE_LOAD_ACTION_PREFIX from vizro.actions import _on_page_load diff --git a/vizro-core/src/vizro/models/types.py b/vizro-core/src/vizro/models/types.py index f33684057..d97d25143 100644 --- a/vizro-core/src/vizro/models/types.py +++ b/vizro-core/src/vizro/models/types.py @@ -6,9 +6,15 @@ import inspect from typing import Any, Dict, List, Literal, Protocol, Union, runtime_checkable -from pydantic import Field, StrictBool -from pydantic.fields import ModelField -from pydantic.schema import SkipField +try: + from pydantic.v1 import Field, StrictBool + from pydantic.v1.fields import ModelField + from pydantic.v1.schema import SkipField +except ImportError: + from pydantic import Field, StrictBool + from pydantic.fields import ModelField + from pydantic.schema import SkipField + from typing_extensions import Annotated, TypedDict from vizro.charts._charts_utils import _DashboardReadyFigure diff --git a/vizro-core/tests/unit/vizro/models/_action/test_action.py b/vizro-core/tests/unit/vizro/models/_action/test_action.py index 088f6b495..b54cb43d7 100644 --- a/vizro-core/tests/unit/vizro/models/_action/test_action.py +++ b/vizro-core/tests/unit/vizro/models/_action/test_action.py @@ -9,7 +9,11 @@ from dash import html from dash._callback_context import context_value from dash._utils import AttributeDict -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError from vizro.actions import export_data from vizro.models._action._action import Action diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py index 56509ab10..5eecd30ec 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError from vizro.models._action._action import Action from vizro.models._components.form import Checklist diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py index 5b4a2f9b4..01d39ec59 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError from vizro.models._action._action import Action from vizro.models._components.form import Dropdown diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py index b9998e90c..ef8861f04 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError from vizro.models._action._action import Action from vizro.models._components.form import RadioItems diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py index 8cb6a9ab6..7d5142a34 100644 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py index ad8e466ff..9355ba995 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/test_card.py b/vizro-core/tests/unit/vizro/models/_components/test_card.py index 8c0d049b9..608116bd2 100755 --- a/vizro-core/tests/unit/vizro/models/_components/test_card.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_card.py @@ -5,7 +5,11 @@ import plotly import pytest from dash import dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/test_graph.py b/vizro-core/tests/unit/vizro/models/_components/test_graph.py index 6f3e190f9..b2f689be9 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_graph.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_graph.py @@ -7,7 +7,11 @@ from dash import dcc from dash._callback_context import context_value from dash._utils import AttributeDict -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm import vizro.plotly.express as px diff --git a/vizro-core/tests/unit/vizro/models/_components/test_table.py b/vizro-core/tests/unit/vizro/models/_components/test_table.py index 87f4bd1e7..db5fe78d2 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_table.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_table.py @@ -4,7 +4,11 @@ import plotly import pytest from dash import dash_table, dcc, html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm import vizro.plotly.express as px diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py index 894275c73..338418ed2 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py @@ -5,7 +5,11 @@ import pytest from asserts import assert_component_equal from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm from vizro._constants import ACCORDION_DEFAULT_TITLE diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py index ff633a6a6..d4d72f676 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py @@ -5,7 +5,11 @@ import pytest from asserts import assert_component_equal from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py index 71710ed2a..0d1214a57 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py @@ -5,7 +5,11 @@ import pytest from asserts import assert_component_equal from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py index 73abd6fdc..53184ddd3 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py @@ -5,7 +5,11 @@ import pytest from asserts import assert_component_equal from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_base.py b/vizro-core/tests/unit/vizro/models/test_base.py index 84bafd561..b29906215 100644 --- a/vizro-core/tests/unit/vizro/models/test_base.py +++ b/vizro-core/tests/unit/vizro/models/test_base.py @@ -1,7 +1,11 @@ from typing import List, Literal, Optional, Union import pytest -from pydantic import Field, ValidationError + +try: + from pydantic.v1 import Field, ValidationError +except ImportError: + from pydantic import Field, ValidationError from typing_extensions import Annotated import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_dashboard.py b/vizro-core/tests/unit/vizro/models/test_dashboard.py index 2529a57cf..7dadcd28b 100644 --- a/vizro-core/tests/unit/vizro/models/test_dashboard.py +++ b/vizro-core/tests/unit/vizro/models/test_dashboard.py @@ -7,7 +7,11 @@ import plotly import pytest from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_layout.py b/vizro-core/tests/unit/vizro/models/test_layout.py index 322cbf3e3..4886b3bef 100755 --- a/vizro-core/tests/unit/vizro/models/test_layout.py +++ b/vizro-core/tests/unit/vizro/models/test_layout.py @@ -1,6 +1,10 @@ import numpy as np import pytest -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm from vizro.models._layout import GAP_DEFAULT, MIN_DEFAULT, ColRowGridLines diff --git a/vizro-core/tests/unit/vizro/models/test_page.py b/vizro-core/tests/unit/vizro/models/test_page.py index 77d42f3b8..79d483d91 100644 --- a/vizro-core/tests/unit/vizro/models/test_page.py +++ b/vizro-core/tests/unit/vizro/models/test_page.py @@ -2,7 +2,11 @@ import pandas as pd import pytest -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: + from pydantic import ValidationError import vizro.models as vm import vizro.plotly.express as px diff --git a/vizro-core/tests/unit/vizro/models/test_types.py b/vizro-core/tests/unit/vizro/models/test_types.py index 910c30b7b..ff9c266da 100644 --- a/vizro-core/tests/unit/vizro/models/test_types.py +++ b/vizro-core/tests/unit/vizro/models/test_types.py @@ -3,7 +3,11 @@ import plotly.express as plotly_express import plotly.graph_objects as go import pytest -from pydantic import Field, ValidationError + +try: + from pydantic.v1 import Field, ValidationError +except ImportError: + from pydantic import Field, ValidationError from vizro.charts._charts_utils import _DashboardReadyFigure from vizro.models import VizroBaseModel From 3a9da896ed08609ba92f1e824326020db022d29d Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Fri, 1 Dec 2023 16:48:06 +0000 Subject: [PATCH 02/23] Revert change to pre-commit-config --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 486f03f29..df8064356 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: - id: mypy files: ^vizro-core/src/ additional_dependencies: - - pydantic>=2 + - pydantic>=1.10.13, <2 - repo: https://github.com/gitleaks/gitleaks rev: v8.16.4 From 73f25876e366689f0046a2683441afca5abbde54 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 17:05:27 +0000 Subject: [PATCH 03/23] Update VizroAI --- vizro-ai/src/vizro_ai/chains/_llm_models.py | 6 +++++- vizro-ai/src/vizro_ai/components/chart_selection.py | 6 +++++- vizro-ai/src/vizro_ai/components/code_validation.py | 5 ++++- vizro-ai/src/vizro_ai/components/custom_chart_wrap.py | 5 ++++- vizro-ai/src/vizro_ai/components/dataframe_craft.py | 6 +++++- vizro-ai/src/vizro_ai/components/explanation.py | 5 ++++- vizro-ai/src/vizro_ai/components/visual_code.py | 5 ++++- vizro-ai/src/vizro_ai/schema_manager/schema_manager.py | 5 ++++- 8 files changed, 35 insertions(+), 8 deletions(-) diff --git a/vizro-ai/src/vizro_ai/chains/_llm_models.py b/vizro-ai/src/vizro_ai/chains/_llm_models.py index 73210fc8d..68c61e583 100644 --- a/vizro-ai/src/vizro_ai/chains/_llm_models.py +++ b/vizro-ai/src/vizro_ai/chains/_llm_models.py @@ -1,7 +1,11 @@ from typing import Callable, Dict, List, Union from langchain.chat_models import ChatOpenAI -from pydantic import BaseModel, Field + +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field # TODO add new wrappers in if new model support is added LLM_MODELS = Union[ChatOpenAI] diff --git a/vizro-ai/src/vizro_ai/components/chart_selection.py b/vizro-ai/src/vizro_ai/components/chart_selection.py index bda57bb58..3d4677aa1 100644 --- a/vizro-ai/src/vizro_ai/components/chart_selection.py +++ b/vizro-ai/src/vizro_ai/components/chart_selection.py @@ -2,7 +2,11 @@ from typing import Dict, Tuple import pandas as pd -from pydantic import BaseModel, Field + +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/components/code_validation.py b/vizro-ai/src/vizro_ai/components/code_validation.py index 0d4f32633..b826c77de 100644 --- a/vizro-ai/src/vizro_ai/components/code_validation.py +++ b/vizro-ai/src/vizro_ai/components/code_validation.py @@ -2,7 +2,10 @@ import traceback from typing import Dict, Tuple -from pydantic import BaseModel, Field +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py b/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py index 07783bf2a..5412c2a61 100644 --- a/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py +++ b/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py @@ -2,7 +2,10 @@ import logging from typing import Dict, Tuple -from pydantic import BaseModel, Field +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/components/dataframe_craft.py b/vizro-ai/src/vizro_ai/components/dataframe_craft.py index 65f95f445..db9396e0d 100755 --- a/vizro-ai/src/vizro_ai/components/dataframe_craft.py +++ b/vizro-ai/src/vizro_ai/components/dataframe_craft.py @@ -4,7 +4,11 @@ from typing import Dict, Tuple import pandas as pd -from pydantic import BaseModel, Field + +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/components/explanation.py b/vizro-ai/src/vizro_ai/components/explanation.py index 3a1148cbc..22d9b70ab 100644 --- a/vizro-ai/src/vizro_ai/components/explanation.py +++ b/vizro-ai/src/vizro_ai/components/explanation.py @@ -1,7 +1,10 @@ """Chart Type Selection Component.""" from typing import Dict, Tuple -from pydantic import BaseModel, Field +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/components/visual_code.py b/vizro-ai/src/vizro_ai/components/visual_code.py index 1570ba5a3..7e40e6871 100644 --- a/vizro-ai/src/vizro_ai/components/visual_code.py +++ b/vizro-ai/src/vizro_ai/components/visual_code.py @@ -1,7 +1,10 @@ """Visual Code Component.""" from typing import Dict, Tuple -from pydantic import BaseModel, Field +try: + from pydantic.v1 import BaseModel, Field +except ImportError: + from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time from vizro_ai.chains._llm_models import LLM_MODELS diff --git a/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py b/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py index 9d0033de5..e2f23ca9d 100644 --- a/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py +++ b/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py @@ -2,7 +2,10 @@ import inspect from typing import Callable, List, Union -from pydantic import BaseModel, Field, create_model +try: + from pydantic.v1 import BaseModel, Field, create_model +except ImportError: + from pydantic import BaseModel, Field, create_model class SchemaManager: From 879be5b7c013ff863a38fa112436d9368b811279 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 17:12:57 +0000 Subject: [PATCH 04/23] Fix mypy --- .pre-commit-config.yaml | 2 +- vizro-core/pyproject.toml | 2 +- .../vizro/actions/_action_loop/_action_loop_utils.py | 2 +- vizro-core/src/vizro/actions/_actions_utils.py | 10 ++++------ .../_callback_mapping/_callback_mapping_utils.py | 12 ++++++------ .../_get_action_callback_mapping.py | 2 +- vizro-core/src/vizro/actions/_on_page_load_action.py | 6 +++++- vizro-core/src/vizro/models/_action/_action.py | 1 + vizro-core/src/vizro/models/_base.py | 2 +- .../src/vizro/models/_components/form/checklist.py | 2 +- .../src/vizro/models/_components/form/dropdown.py | 2 +- .../src/vizro/models/_components/form/radio_items.py | 2 +- vizro-core/src/vizro/models/_components/table.py | 2 +- vizro-core/src/vizro/models/_navigation/nav_link.py | 2 +- .../tests/unit/vizro/models/_action/test_action.py | 3 +-- 15 files changed, 27 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index df8064356..9b4c50b01 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: - id: mypy files: ^vizro-core/src/ additional_dependencies: - - pydantic>=1.10.13, <2 + - pydantic>=1.10.13, <2 # deliberately pinned to <2 until we bump our pydantic requirement to strictly >=2 - repo: https://github.com/gitleaks/gitleaks rev: v8.16.4 diff --git a/vizro-core/pyproject.toml b/vizro-core/pyproject.toml index 6258bc056..26747a3bf 100644 --- a/vizro-core/pyproject.toml +++ b/vizro-core/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ # 2.11 needed for https://dash.plotly.com/dash-in-jupyter "dash_bootstrap_components", "pandas", - "pydantic>=1.10.13", # must be synced with pre-commit mypy hook + "pydantic>=1.10.13", # must be synced with pre-commit mypy hook manually "dash_daq", "ipython>=8.10.0", # not directly required, pinned by Snyk to avoid a vulnerability: https://app.snyk.io/vuln/SNYK-PYTHON-IPYTHON-3318382 "numpy>=1.22.2", # not directly required, pinned by Snyk to avoid a vulnerability: https://security.snyk.io/vuln/SNYK-PYTHON-NUMPY-2321970 diff --git a/vizro-core/src/vizro/actions/_action_loop/_action_loop_utils.py b/vizro-core/src/vizro/actions/_action_loop/_action_loop_utils.py index 55e2835cd..379a066ec 100644 --- a/vizro-core/src/vizro/actions/_action_loop/_action_loop_utils.py +++ b/vizro-core/src/vizro/actions/_action_loop/_action_loop_utils.py @@ -38,7 +38,7 @@ def _get_actions_chains_on_registered_pages() -> List[ActionsChain]: actions_chains: List[ActionsChain] = [] for registered_page in page_registry.values(): try: - page: Page = model_manager[registered_page["module"]] # type: ignore[assignment] + page: Page = model_manager[registered_page["module"]] except KeyError: continue actions_chains.extend(_get_all_actions_chains_on_page(page=page)) diff --git a/vizro-core/src/vizro/actions/_actions_utils.py b/vizro-core/src/vizro/actions/_actions_utils.py index b3d153d6a..25c22358c 100644 --- a/vizro-core/src/vizro/actions/_actions_utils.py +++ b/vizro-core/src/vizro/actions/_actions_utils.py @@ -82,7 +82,7 @@ def _apply_graph_filter_interaction( source_graph_id: ModelID = ctd_click_data["id"] source_graph_actions = _get_component_actions(model_manager[source_graph_id]) try: - custom_data_columns = model_manager[source_graph_id]["custom_data"] # type: ignore[index] + custom_data_columns = model_manager[source_graph_id]["custom_data"] except KeyError as exc: raise KeyError(f"No `custom_data` argument found for source graph with id {source_graph_id}.") from exc @@ -160,7 +160,7 @@ def _validate_selector_value_none(value: Union[SingleValueType, MultiValueType]) if value == NONE_OPTION: return None elif isinstance(value, list): - return [i for i in value if i != NONE_OPTION] or [None] # type: ignore[list-item, return-value] + return [i for i in value if i != NONE_OPTION] or [None] return value @@ -190,7 +190,7 @@ def _get_parametrized_config( for target in targets: # TODO - avoid calling _captured_callable. Once we have done this we can remove _arguments from # CapturedCallable entirely. - graph_config = deepcopy(model_manager[target].figure._arguments) # type: ignore[attr-defined] + graph_config = deepcopy(model_manager[target].figure._arguments) if "data_frame" in graph_config: graph_config.pop("data_frame") @@ -267,8 +267,6 @@ def _get_modified_page_figures( outputs: Dict[ModelID, Any] = {} for target in targets: - outputs[target] = model_manager[target]( # type: ignore[operator] - data_frame=filtered_data[target], **parameterized_config[target] - ) + outputs[target] = model_manager[target](data_frame=filtered_data[target], **parameterized_config[target]) return namedtuple("Outputs", outputs.keys())(**outputs) diff --git a/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py b/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py index 8ceb74742..a8fae095a 100644 --- a/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py +++ b/vizro-core/src/vizro/actions/_callback_mapping/_callback_mapping_utils.py @@ -132,7 +132,7 @@ def _get_inputs_of_figure_interactions( def _get_action_callback_inputs(action_id: ModelID) -> Dict[str, Any]: """Creates mapping of pre-defined action names and a list of States.""" - action_function = model_manager[action_id].function._function # type: ignore[attr-defined] + action_function = model_manager[action_id].function._function if action_function == export_data.__wrapped__: include_inputs = ["filters", "filter_interaction"] @@ -162,7 +162,7 @@ def _get_action_callback_inputs(action_id: ModelID) -> Dict[str, Any]: # CALLBACK OUTPUTS -------------- def _get_action_callback_outputs(action_id: ModelID) -> Dict[str, Output]: """Creates mapping of target names and their Output.""" - action_function = model_manager[action_id].function._function # type: ignore[attr-defined] + action_function = model_manager[action_id].function._function # The right solution for mypy here is to not e.g. define new attributes on the base but instead to get mypy to # recognize that model_manager[action_id] is of type Action and hence has the function attribute. @@ -170,7 +170,7 @@ def _get_action_callback_outputs(action_id: ModelID) -> Dict[str, Output]: # If not then we can do the cast to Action at the point of consumption here to avoid needing mypy ignores. try: - targets = model_manager[action_id].function["targets"] # type: ignore[attr-defined] + targets = model_manager[action_id].function["targets"] except KeyError: targets = [] @@ -183,7 +183,7 @@ def _get_action_callback_outputs(action_id: ModelID) -> Dict[str, Output]: return { target: Output( component_id=target, - component_property=model_manager[target]._output_property, # type: ignore[attr-defined] + component_property=model_manager[target]._output_property, allow_duplicate=True, ) for target in targets @@ -195,7 +195,7 @@ def _get_export_data_callback_outputs(action_id: ModelID) -> Dict[str, List[Stat action = model_manager[action_id] try: - targets = action.function["targets"] # type: ignore[attr-defined] + targets = action.function["targets"] except KeyError: targets = None @@ -221,7 +221,7 @@ def _get_export_data_callback_components(action_id: ModelID) -> List[dcc.Downloa action = model_manager[action_id] try: - targets = action.function["targets"] # type: ignore[attr-defined] + targets = action.function["targets"] except KeyError: targets = None diff --git a/vizro-core/src/vizro/actions/_callback_mapping/_get_action_callback_mapping.py b/vizro-core/src/vizro/actions/_callback_mapping/_get_action_callback_mapping.py index 43baef8b2..d69acecb7 100644 --- a/vizro-core/src/vizro/actions/_callback_mapping/_get_action_callback_mapping.py +++ b/vizro-core/src/vizro/actions/_callback_mapping/_get_action_callback_mapping.py @@ -23,7 +23,7 @@ def _get_action_callback_mapping( action_id: ModelID, argument: str ) -> Union[List[dcc.Download], Dict[str, DashDependency]]: """Creates mapping of action name and required callback input/output.""" - action_function = model_manager[action_id].function._function # type: ignore[attr-defined] + action_function = model_manager[action_id].function._function action_callback_mapping: Dict[str, Any] = { export_data.__wrapped__: { diff --git a/vizro-core/src/vizro/actions/_on_page_load_action.py b/vizro-core/src/vizro/actions/_on_page_load_action.py index 31b66092b..1c5688899 100644 --- a/vizro-core/src/vizro/actions/_on_page_load_action.py +++ b/vizro-core/src/vizro/actions/_on_page_load_action.py @@ -24,7 +24,11 @@ def _on_page_load(page_id: ModelID, **inputs: Dict[str, Any]) -> Tuple[Any, ...] Returns: Dict mapping target chart ids to modified figures e.g. {'my_scatter': Figure({})} """ - targets = [component.id for component in model_manager[page_id].components if data_manager._has_registered_data(component.id)] # type: ignore[attr-defined] # noqa: E501 + targets = [ + component.id + for component in model_manager[page_id].components + if data_manager._has_registered_data(component.id) + ] return _get_modified_page_figures( targets=targets, diff --git a/vizro-core/src/vizro/models/_action/_action.py b/vizro-core/src/vizro/models/_action/_action.py index 1b6ade49e..8a059c2c6 100644 --- a/vizro-core/src/vizro/models/_action/_action.py +++ b/vizro-core/src/vizro/models/_action/_action.py @@ -4,6 +4,7 @@ from typing import Any, Dict, List from dash import Input, Output, State, callback, html + try: from pydantic.v1 import Field, validator except ImportError: diff --git a/vizro-core/src/vizro/models/_base.py b/vizro-core/src/vizro/models/_base.py index 6e1b90d70..e1fe3d351 100644 --- a/vizro-core/src/vizro/models/_base.py +++ b/vizro-core/src/vizro/models/_base.py @@ -64,7 +64,7 @@ def _is_discriminated_union(field): return hasattr(field.outer_type_, "__metadata__") and get_args(field.outer_type_)[1].discriminator field = cls.__fields__[field_name] - sub_field = field.sub_fields[0] if field.shape == SHAPE_LIST else None # type: ignore[index] + sub_field = field.sub_fields[0] if field.shape == SHAPE_LIST else None if _is_discriminated_union(field): # Field itself is a non-optional discriminated union, e.g. selector: SelectorType or Optional[SelectorType]. diff --git a/vizro-core/src/vizro/models/_components/form/checklist.py b/vizro-core/src/vizro/models/_components/form/checklist.py index bd240b1f9..512745c1b 100644 --- a/vizro-core/src/vizro/models/_components/form/checklist.py +++ b/vizro-core/src/vizro/models/_components/form/checklist.py @@ -26,7 +26,7 @@ class Checklist(VizroBaseModel): """ type: Literal["checklist"] = "checklist" - options: OptionsType = [] # type: ignore[assignment] + options: OptionsType = [] value: Optional[MultiValueType] = None title: str = Field("", description="Title to be displayed") actions: List[Action] = [] diff --git a/vizro-core/src/vizro/models/_components/form/dropdown.py b/vizro-core/src/vizro/models/_components/form/dropdown.py index 14eeec9e5..acc1a1e45 100755 --- a/vizro-core/src/vizro/models/_components/form/dropdown.py +++ b/vizro-core/src/vizro/models/_components/form/dropdown.py @@ -29,7 +29,7 @@ class Dropdown(VizroBaseModel): """ type: Literal["dropdown"] = "dropdown" - options: OptionsType = [] # type: ignore[assignment] + options: OptionsType = [] value: Optional[Union[SingleValueType, MultiValueType]] = None multi: bool = Field(True, description="Whether to allow selection of multiple values") title: str = Field("", description="Title to be displayed") diff --git a/vizro-core/src/vizro/models/_components/form/radio_items.py b/vizro-core/src/vizro/models/_components/form/radio_items.py index b19538d84..b73d7bd6d 100644 --- a/vizro-core/src/vizro/models/_components/form/radio_items.py +++ b/vizro-core/src/vizro/models/_components/form/radio_items.py @@ -27,7 +27,7 @@ class RadioItems(VizroBaseModel): """ type: Literal["radio_items"] = "radio_items" - options: OptionsType = [] # type: ignore[assignment] + options: OptionsType = [] value: Optional[SingleValueType] = None title: str = Field("", description="Title to be displayed") actions: List[Action] = [] diff --git a/vizro-core/src/vizro/models/_components/table.py b/vizro-core/src/vizro/models/_components/table.py index 03ea4a6a3..dd797b919 100644 --- a/vizro-core/src/vizro/models/_components/table.py +++ b/vizro-core/src/vizro/models/_components/table.py @@ -42,7 +42,7 @@ class Table(VizroBaseModel): _output_property: str = PrivateAttr("children") # validator - set_actions = _action_validator_factory("active_cell") # type: ignore[pydantic-field] + set_actions = _action_validator_factory("active_cell") _validate_callable = validator("figure", allow_reuse=True, always=True)(_process_callable_data_frame) # Convenience wrapper/syntactic sugar. diff --git a/vizro-core/src/vizro/models/_navigation/nav_link.py b/vizro-core/src/vizro/models/_navigation/nav_link.py index 1b644e3a6..8208b8cca 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_link.py +++ b/vizro-core/src/vizro/models/_navigation/nav_link.py @@ -43,7 +43,7 @@ class NavLink(VizroBaseModel): def pre_build(self): from vizro.models._navigation.accordion import Accordion - self._nav_selector = Accordion(pages=self.pages) # type: ignore[arg-type] + self._nav_selector = Accordion(pages=self.pages) @_log_call def build(self, *, active_page_id=None): diff --git a/vizro-core/tests/unit/vizro/models/_action/test_action.py b/vizro-core/tests/unit/vizro/models/_action/test_action.py index ad651ead5..a6ccf4c85 100644 --- a/vizro-core/tests/unit/vizro/models/_action/test_action.py +++ b/vizro-core/tests/unit/vizro/models/_action/test_action.py @@ -8,8 +8,7 @@ import plotly import pytest from dash import html -from dash._callback_context import context_value -from dash._utils import AttributeDict + try: from pydantic.v1 import ValidationError except ImportError: From f07e5bf90419156344280b6f3f5095d49cf6f3bb Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:27:09 +0000 Subject: [PATCH 05/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 9 +++++++++ vizro-core/hatch.toml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index 3ca2025c4..80bede91d 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -26,7 +26,11 @@ jobs: fail-fast: false matrix: python-version: ["3.8", "3.9", "3.10", "3.11"] + include: + - python-version: "3.11" + lower-bounds: true + # write matrix out manually with var for hatch env steps: - uses: actions/checkout@v4 @@ -38,6 +42,11 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch + - if: matrix.lower-bounds + name: Activate hatch environment + run: hatch -e lower-bounds shell + + - name: List dependencies run: hatch run all.py${{ matrix.python-version }}:pip freeze diff --git a/vizro-core/hatch.toml b/vizro-core/hatch.toml index de38c7c8c..bff378b78 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -8,6 +8,9 @@ matrix.python.features = [ {value = "kedro", if = ["3.8", "3.9", "3.10"]} ] +[envs.lower-bounds] +extra-dependencies = ["pydantic==2.5.0"] + [envs.changelog] dependencies = ["scriv"] detached = true From 672d1ffb517b8f9f6d3c2fff784104b17fc55b72 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:33:12 +0000 Subject: [PATCH 06/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index 80bede91d..9362ac1b9 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -20,7 +20,7 @@ env: jobs: test-unit-vizro-core: - name: test-unit-vizro-core on Py${{ matrix.python-version }} + name: test-unit-vizro-core on Py${{ matrix.python-version }} ${{ matrix.label }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -29,6 +29,7 @@ jobs: include: - python-version: "3.11" lower-bounds: true + label: lower # write matrix out manually with var for hatch env steps: From 7acf10427a803be96917fc820db4c67950d964b9 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:48:18 +0000 Subject: [PATCH 07/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index 9362ac1b9..c2501217f 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -25,10 +25,13 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + #python-version: ["3.8", "3.9", "3.10", "3.11"] include: - python-version: "3.11" - lower-bounds: true + hatch-env: all.py3.11 + label: lower + - python-version: "3.11" + hatch-env: all.py3.11 label: lower # write matrix out manually with var for hatch env @@ -49,7 +52,7 @@ jobs: - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze + run: hatch run all.py${{ matrix.hatch-env }}:pip freeze - name: Run unit tests - run: hatch run all.py${{ matrix.python-version }}:test-unit-coverage + run: hatch run all.py${{ matrix.hatch-env }}:test-unit-coverage From 4f226c9ab04204d0d0c0aa21389e5aa99dc5ce06 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:48:28 +0000 Subject: [PATCH 08/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index c2501217f..bdb220601 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -46,10 +46,6 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch - - if: matrix.lower-bounds - name: Activate hatch environment - run: hatch -e lower-bounds shell - - name: List dependencies run: hatch run all.py${{ matrix.hatch-env }}:pip freeze From 7940d36e8da6f560dda2dbcb9cb3ec7d6758f4f4 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:49:57 +0000 Subject: [PATCH 09/23] Test GHA --- .../workflows/test-integration-vizro-ai.yml | 56 ------------------- .../workflows/test-integration-vizro-core.yml | 45 --------------- .github/workflows/test-unit-vizro-ai.yml | 46 --------------- .github/workflows/test-unit-vizro-core.yml | 1 - 4 files changed, 148 deletions(-) delete mode 100644 .github/workflows/test-integration-vizro-ai.yml delete mode 100644 .github/workflows/test-integration-vizro-core.yml delete mode 100644 .github/workflows/test-unit-vizro-ai.yml diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml deleted file mode 100644 index 3185242bb..000000000 --- a/.github/workflows/test-integration-vizro-ai.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Integration tests for VizroAI - -defaults: - run: - working-directory: vizro-ai - -on: - push: - branches: [main] - pull_request: - branches: - - "main" - -concurrency: - group: test-integration-${{ github.head_ref }} - -env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - -jobs: - test-integration-vizro-ai: - name: test-integration-vizro-ai on Py${{ matrix.python-version }} - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Hatch - run: pip install --upgrade hatch - - - name: Run vizro-ai integration tests with pypi vizro - run: | - export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} - export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }} - hatch run all.py${{ matrix.python-version }}:test-integration - - - name: Run vizro-ai integration tests with local vizro - run: | - export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} - export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }} - cd ../vizro-core - hatch build - cd ../vizro-ai - hatch run all.py${{ matrix.python-version }}:pip install ../vizro-core/dist/vizro*.tar.gz - hatch run all.py${{ matrix.python-version }}:test-integration diff --git a/.github/workflows/test-integration-vizro-core.yml b/.github/workflows/test-integration-vizro-core.yml deleted file mode 100644 index d13557fca..000000000 --- a/.github/workflows/test-integration-vizro-core.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Integration tests for Vizro - -defaults: - run: - working-directory: vizro-core - -on: - push: - branches: [main] - pull_request: - branches: - - "main" - -concurrency: - group: test-integration-${{ github.head_ref }} - -env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - -jobs: - test-integration-vizro-core: - name: test-integration-vizro-core on Py${{ matrix.python-version }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Hatch - run: pip install --upgrade hatch - - - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze - - - name: Run integration tests - run: hatch run all.py${{ matrix.python-version }}:test-integration diff --git a/.github/workflows/test-unit-vizro-ai.yml b/.github/workflows/test-unit-vizro-ai.yml deleted file mode 100644 index f6c3b288e..000000000 --- a/.github/workflows/test-unit-vizro-ai.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Unit tests for VizroAI - -defaults: - run: - working-directory: vizro-ai - -on: - push: - branches: [main] - pull_request: - branches: - - "main" - -concurrency: - group: test-unit-${{ github.head_ref }} - -env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - -jobs: - test-unit-vizro-ai: - name: test-unit-vizro-ai on Py${{ matrix.python-version }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install Hatch - run: pip install --upgrade hatch - - - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze - - - name: Run unit tests - run: | - hatch run all.py${{ matrix.python-version }}:test-unit-coverage diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index bdb220601..f745761b9 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -29,7 +29,6 @@ jobs: include: - python-version: "3.11" hatch-env: all.py3.11 - label: lower - python-version: "3.11" hatch-env: all.py3.11 label: lower From 8f6cb9376ab4a6edc78e584d15e9238577de65c6 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:54:39 +0000 Subject: [PATCH 10/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index f745761b9..5e86281bb 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -9,14 +9,14 @@ on: branches: [main] pull_request: branches: - - "main" + - main concurrency: group: test-unit-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 jobs: test-unit-vizro-core: @@ -27,11 +27,11 @@ jobs: matrix: #python-version: ["3.8", "3.9", "3.10", "3.11"] include: - - python-version: "3.11" + - python-version: 3.11 hatch-env: all.py3.11 - - python-version: "3.11" - hatch-env: all.py3.11 - label: lower + - python-version: 3.11 + hatch-env: lower-bounds + label: lower bounds # write matrix out manually with var for hatch env steps: @@ -45,9 +45,8 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch - - name: List dependencies - run: hatch run all.py${{ matrix.hatch-env }}:pip freeze + run: hatch run ${{ matrix.hatch-env }}:pip freeze - name: Run unit tests - run: hatch run all.py${{ matrix.hatch-env }}:test-unit-coverage + run: hatch run ${{ matrix.hatch-env }}:test-unit-coverage From bff37e34f6f8bffdb5c2d066008b3fdc7d95e5e7 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 20:58:15 +0000 Subject: [PATCH 11/23] Test GHA --- .github/workflows/test-unit-vizro-core.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index 5e86281bb..442318738 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -25,15 +25,18 @@ jobs: strategy: fail-fast: false matrix: - #python-version: ["3.8", "3.9", "3.10", "3.11"] include: + - python-version: 3.8 + hatch-env: all.py3.8 + - python-version: 3.9 + hatch-env: all.py3.9 + - python-version: 3.10 + hatch-env: all.py3.10 - python-version: 3.11 hatch-env: all.py3.11 - python-version: 3.11 hatch-env: lower-bounds label: lower bounds - - # write matrix out manually with var for hatch env steps: - uses: actions/checkout@v4 From 394f919dea70ab8da149d0ad348f108603336f55 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:09:22 +0000 Subject: [PATCH 12/23] Test GHA --- .github/workflows/checks-vizro-ai.yml | 6 +- .github/workflows/checks-vizro-core.yml | 6 +- .github/workflows/lint-vizro-all.yml | 8 +-- .github/workflows/release-if-needed.yml | 2 +- .github/workflows/secret-scan.yml | 2 +- .../workflows/test-integration-vizro-ai.yml | 67 +++++++++++++++++++ .../workflows/test-integration-vizro-core.yml | 57 ++++++++++++++++ .github/workflows/test-unit-vizro-ai.yml | 55 +++++++++++++++ .github/workflows/test-unit-vizro-core.yml | 2 + 9 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/test-integration-vizro-ai.yml create mode 100644 .github/workflows/test-integration-vizro-core.yml create mode 100644 .github/workflows/test-unit-vizro-ai.yml diff --git a/.github/workflows/checks-vizro-ai.yml b/.github/workflows/checks-vizro-ai.yml index bc210e337..ccc94a322 100644 --- a/.github/workflows/checks-vizro-ai.yml +++ b/.github/workflows/checks-vizro-ai.yml @@ -19,9 +19,9 @@ concurrency: group: checks-ai-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - PYTHON_VERSION: "3.11" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + PYTHON_VERSION: 3.11 jobs: checks-vizro-ai: diff --git a/.github/workflows/checks-vizro-core.yml b/.github/workflows/checks-vizro-core.yml index 928d57189..b6b12d980 100644 --- a/.github/workflows/checks-vizro-core.yml +++ b/.github/workflows/checks-vizro-core.yml @@ -19,9 +19,9 @@ concurrency: group: checks-core-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - PYTHON_VERSION: "3.11" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + PYTHON_VERSION: 3.11 jobs: checks-vizro-core: diff --git a/.github/workflows/lint-vizro-all.yml b/.github/workflows/lint-vizro-all.yml index 88f86d257..9f77e59cb 100644 --- a/.github/workflows/lint-vizro-all.yml +++ b/.github/workflows/lint-vizro-all.yml @@ -9,15 +9,15 @@ on: branches: [main] pull_request: branches: - - "main" + - main concurrency: group: lint-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" - PYTHON_VERSION: "3.11" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + PYTHON_VERSION: 3.11 jobs: lint-vizro-all: diff --git a/.github/workflows/release-if-needed.yml b/.github/workflows/release-if-needed.yml index 05aa19fe9..dd09f878e 100644 --- a/.github/workflows/release-if-needed.yml +++ b/.github/workflows/release-if-needed.yml @@ -6,7 +6,7 @@ on: - main env: - PYTHON_VERSION: "3.11" + PYTHON_VERSION: 3.11 jobs: check-version: diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml index 9d049ad4f..103903867 100644 --- a/.github/workflows/secret-scan.yml +++ b/.github/workflows/secret-scan.yml @@ -8,7 +8,7 @@ on: - cron: "0 4 * * *" # run once a day at 4 AM env: - PYTHON_VERSION: "3.11" + PYTHON_VERSION: 3.11 jobs: secret-scan: diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml new file mode 100644 index 000000000..91dfd0f5d --- /dev/null +++ b/.github/workflows/test-integration-vizro-ai.yml @@ -0,0 +1,67 @@ +name: Integration tests for VizroAI + +defaults: + run: + working-directory: vizro-ai + +on: + push: + branches: [main] + pull_request: + branches: + - main + +concurrency: + group: test-integration-${{ github.head_ref }} + +env: + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + +jobs: + test-integration-vizro-ai: + name: test-integration-vizro-ai on Py${{ matrix.python-version }} + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - python-version: 3.9 + hatch-env: all.py3.9 + - python-version: 3.10 + hatch-env: all.py3.10 + - python-version: 3.11 + hatch-env: all.py3.11 + - python-version: 3.11 + hatch-env: lower-bounds + label: lower bounds + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: Run vizro-ai integration tests with pypi vizro + run: | + export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} + export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }} + hatch run ${{ matrix.hatch-env }}:test-integration + + - name: Run vizro-ai integration tests with local vizro + run: | + export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} + export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }} + cd ../vizro-core + hatch build + cd ../vizro-ai + hatch run ${{ matrix.hatch-env }}:pip install ../vizro-core/dist/vizro*.tar.gz + hatch run ${{ matrix.hatch-env }}:test-integration diff --git a/.github/workflows/test-integration-vizro-core.yml b/.github/workflows/test-integration-vizro-core.yml new file mode 100644 index 000000000..e5509c513 --- /dev/null +++ b/.github/workflows/test-integration-vizro-core.yml @@ -0,0 +1,57 @@ +name: Integration tests for Vizro + +defaults: + run: + working-directory: vizro-core + +on: + push: + branches: [main] + pull_request: + branches: + - main + +concurrency: + group: test-integration-${{ github.head_ref }} + +env: + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + +jobs: + test-integration-vizro-core: + name: test-integration-vizro-core on Py${{ matrix.python-version }} + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - python-version: 3.8 + hatch-env: all.py3.8 + - python-version: 3.9 + hatch-env: all.py3.9 + - python-version: 3.10 + hatch-env: all.py3.10 + - python-version: 3.11 + hatch-env: all.py3.11 + - python-version: 3.11 + hatch-env: lower-bounds + label: lower bounds + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: List dependencies + run: hatch run ${{ matrix.hatch-env }}:pip freeze + + - name: Run integration tests + run: hatch run ${{ matrix.hatch-env }}:test-integration diff --git a/.github/workflows/test-unit-vizro-ai.yml b/.github/workflows/test-unit-vizro-ai.yml new file mode 100644 index 000000000..d490c3108 --- /dev/null +++ b/.github/workflows/test-unit-vizro-ai.yml @@ -0,0 +1,55 @@ +name: Unit tests for VizroAI + +defaults: + run: + working-directory: vizro-ai + +on: + push: + branches: [main] + pull_request: + branches: + - main + +concurrency: + group: test-unit-${{ github.head_ref }} + +env: + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 + +jobs: + test-unit-vizro-ai: + name: test-unit-vizro-ai on Py${{ matrix.python-version }} + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - python-version: 3.9 + hatch-env: all.py3.9 + - python-version: 3.10 + hatch-env: all.py3.10 + - python-version: 3.11 + hatch-env: all.py3.11 + - python-version: 3.11 + hatch-env: lower-bounds + label: lower bounds + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Hatch + run: pip install --upgrade hatch + + - name: List dependencies + run: hatch run ${{ matrix.hatch-env }}:pip freeze + + - name: Run unit tests + run: hatch run ${{ matrix.hatch-env }}:test-unit-coverage diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index 442318738..ddad1f287 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -21,6 +21,7 @@ env: jobs: test-unit-vizro-core: name: test-unit-vizro-core on Py${{ matrix.python-version }} ${{ matrix.label }} + runs-on: ubuntu-latest strategy: fail-fast: false @@ -37,6 +38,7 @@ jobs: - python-version: 3.11 hatch-env: lower-bounds label: lower bounds + steps: - uses: actions/checkout@v4 From 7ae24ea0097130ea4e1e1cbc02bc8405ac1c0d57 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:16:58 +0000 Subject: [PATCH 13/23] Test GHA --- .github/workflows/checks-vizro-ai.yml | 2 +- .github/workflows/checks-vizro-core.yml | 2 +- .github/workflows/lint-vizro-all.yml | 2 +- .github/workflows/release-if-needed.yml | 2 +- .github/workflows/secret-scan.yml | 2 +- .github/workflows/test-integration-vizro-ai.yml | 8 ++++---- .github/workflows/test-integration-vizro-core.yml | 10 +++++----- .github/workflows/test-unit-vizro-ai.yml | 8 ++++---- .github/workflows/test-unit-vizro-core.yml | 10 +++++----- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.github/workflows/checks-vizro-ai.yml b/.github/workflows/checks-vizro-ai.yml index ccc94a322..5f318cba4 100644 --- a/.github/workflows/checks-vizro-ai.yml +++ b/.github/workflows/checks-vizro-ai.yml @@ -21,7 +21,7 @@ concurrency: env: PYTHONUNBUFFERED: 1 FORCE_COLOR: 1 - PYTHON_VERSION: 3.11 + PYTHON_VERSION: "3.11" jobs: checks-vizro-ai: diff --git a/.github/workflows/checks-vizro-core.yml b/.github/workflows/checks-vizro-core.yml index b6b12d980..a07837799 100644 --- a/.github/workflows/checks-vizro-core.yml +++ b/.github/workflows/checks-vizro-core.yml @@ -21,7 +21,7 @@ concurrency: env: PYTHONUNBUFFERED: 1 FORCE_COLOR: 1 - PYTHON_VERSION: 3.11 + PYTHON_VERSION: "3.11" jobs: checks-vizro-core: diff --git a/.github/workflows/lint-vizro-all.yml b/.github/workflows/lint-vizro-all.yml index 9f77e59cb..6d22e7518 100644 --- a/.github/workflows/lint-vizro-all.yml +++ b/.github/workflows/lint-vizro-all.yml @@ -17,7 +17,7 @@ concurrency: env: PYTHONUNBUFFERED: 1 FORCE_COLOR: 1 - PYTHON_VERSION: 3.11 + PYTHON_VERSION: "3.11" jobs: lint-vizro-all: diff --git a/.github/workflows/release-if-needed.yml b/.github/workflows/release-if-needed.yml index dd09f878e..05aa19fe9 100644 --- a/.github/workflows/release-if-needed.yml +++ b/.github/workflows/release-if-needed.yml @@ -6,7 +6,7 @@ on: - main env: - PYTHON_VERSION: 3.11 + PYTHON_VERSION: "3.11" jobs: check-version: diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml index 103903867..9d049ad4f 100644 --- a/.github/workflows/secret-scan.yml +++ b/.github/workflows/secret-scan.yml @@ -8,7 +8,7 @@ on: - cron: "0 4 * * *" # run once a day at 4 AM env: - PYTHON_VERSION: 3.11 + PYTHON_VERSION: "3.11" jobs: secret-scan: diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml index 91dfd0f5d..387d7b9c7 100644 --- a/.github/workflows/test-integration-vizro-ai.yml +++ b/.github/workflows/test-integration-vizro-ai.yml @@ -27,13 +27,13 @@ jobs: fail-fast: false matrix: include: - - python-version: 3.9 + - python-version: "3.9" hatch-env: all.py3.9 - - python-version: 3.10 + - python-version: "3.10" hatch-env: all.py3.10 - - python-version: 3.11 + - python-version: "3.11" hatch-env: all.py3.11 - - python-version: 3.11 + - python-version: "3.11" hatch-env: lower-bounds label: lower bounds diff --git a/.github/workflows/test-integration-vizro-core.yml b/.github/workflows/test-integration-vizro-core.yml index e5509c513..27cdadaed 100644 --- a/.github/workflows/test-integration-vizro-core.yml +++ b/.github/workflows/test-integration-vizro-core.yml @@ -27,15 +27,15 @@ jobs: fail-fast: false matrix: include: - - python-version: 3.8 + - python-version: "3.8" hatch-env: all.py3.8 - - python-version: 3.9 + - python-version: "3.9" hatch-env: all.py3.9 - - python-version: 3.10 + - python-version: "3.10" hatch-env: all.py3.10 - - python-version: 3.11 + - python-version: "3.11" hatch-env: all.py3.11 - - python-version: 3.11 + - python-version: "3.11" hatch-env: lower-bounds label: lower bounds diff --git a/.github/workflows/test-unit-vizro-ai.yml b/.github/workflows/test-unit-vizro-ai.yml index d490c3108..1711b61c9 100644 --- a/.github/workflows/test-unit-vizro-ai.yml +++ b/.github/workflows/test-unit-vizro-ai.yml @@ -27,13 +27,13 @@ jobs: fail-fast: false matrix: include: - - python-version: 3.9 + - python-version: "3.9" hatch-env: all.py3.9 - - python-version: 3.10 + - python-version: "3.10" hatch-env: all.py3.10 - - python-version: 3.11 + - python-version: "3.11" hatch-env: all.py3.11 - - python-version: 3.11 + - python-version: "3.11" hatch-env: lower-bounds label: lower bounds diff --git a/.github/workflows/test-unit-vizro-core.yml b/.github/workflows/test-unit-vizro-core.yml index ddad1f287..890091d42 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -27,15 +27,15 @@ jobs: fail-fast: false matrix: include: - - python-version: 3.8 + - python-version: "3.8" hatch-env: all.py3.8 - - python-version: 3.9 + - python-version: "3.9" hatch-env: all.py3.9 - - python-version: 3.10 + - python-version: "3.10" hatch-env: all.py3.10 - - python-version: 3.11 + - python-version: "3.11" hatch-env: all.py3.11 - - python-version: 3.11 + - python-version: "3.11" hatch-env: lower-bounds label: lower bounds From 22ca0ed6e516962b14d60289f6d6be3320af4e39 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:26:17 +0000 Subject: [PATCH 14/23] Insert # pragma: no cov --- vizro-ai/src/vizro_ai/chains/_llm_models.py | 2 +- vizro-ai/src/vizro_ai/components/chart_selection.py | 2 +- vizro-ai/src/vizro_ai/components/code_validation.py | 2 +- vizro-ai/src/vizro_ai/components/custom_chart_wrap.py | 2 +- vizro-ai/src/vizro_ai/components/dataframe_craft.py | 2 +- vizro-ai/src/vizro_ai/components/explanation.py | 2 +- vizro-ai/src/vizro_ai/components/visual_code.py | 2 +- vizro-ai/src/vizro_ai/schema_manager/schema_manager.py | 2 +- vizro-core/src/vizro/models/_action/_action.py | 2 +- vizro-core/src/vizro/models/_action/_actions_chain.py | 2 +- vizro-core/src/vizro/models/_base.py | 2 +- vizro-core/src/vizro/models/_components/_form.py | 2 +- vizro-core/src/vizro/models/_components/button.py | 2 +- vizro-core/src/vizro/models/_components/card.py | 2 +- vizro-core/src/vizro/models/_components/form/_alert.py | 2 +- vizro-core/src/vizro/models/_components/form/_user_input.py | 2 +- vizro-core/src/vizro/models/_components/form/checklist.py | 2 +- vizro-core/src/vizro/models/_components/form/dropdown.py | 2 +- vizro-core/src/vizro/models/_components/form/radio_items.py | 2 +- vizro-core/src/vizro/models/_components/form/range_slider.py | 2 +- vizro-core/src/vizro/models/_components/form/slider.py | 2 +- vizro-core/src/vizro/models/_components/graph.py | 2 +- vizro-core/src/vizro/models/_components/table.py | 2 +- vizro-core/src/vizro/models/_controls/filter.py | 2 +- vizro-core/src/vizro/models/_controls/parameter.py | 2 +- vizro-core/src/vizro/models/_dashboard.py | 2 +- vizro-core/src/vizro/models/_layout.py | 2 +- vizro-core/src/vizro/models/_navigation/accordion.py | 2 +- vizro-core/src/vizro/models/_navigation/nav_bar.py | 2 +- vizro-core/src/vizro/models/_navigation/nav_link.py | 2 +- vizro-core/src/vizro/models/_navigation/navigation.py | 2 +- vizro-core/src/vizro/models/_page.py | 2 +- vizro-core/src/vizro/models/types.py | 2 +- vizro-core/tests/unit/vizro/models/_action/test_action.py | 2 +- .../tests/unit/vizro/models/_components/form/test_checklist.py | 2 +- .../tests/unit/vizro/models/_components/form/test_dropdown.py | 2 +- .../tests/unit/vizro/models/_components/form/test_radioitems.py | 2 +- .../unit/vizro/models/_components/form/test_range_slider.py | 2 +- .../tests/unit/vizro/models/_components/form/test_slider.py | 2 +- vizro-core/tests/unit/vizro/models/_components/test_card.py | 2 +- vizro-core/tests/unit/vizro/models/_components/test_graph.py | 2 +- vizro-core/tests/unit/vizro/models/_components/test_table.py | 2 +- .../tests/unit/vizro/models/_navigation/test_accordion.py | 2 +- vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py | 2 +- vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py | 2 +- .../tests/unit/vizro/models/_navigation/test_navigation.py | 2 +- vizro-core/tests/unit/vizro/models/test_base.py | 2 +- vizro-core/tests/unit/vizro/models/test_dashboard.py | 2 +- vizro-core/tests/unit/vizro/models/test_layout.py | 2 +- vizro-core/tests/unit/vizro/models/test_page.py | 2 +- vizro-core/tests/unit/vizro/models/test_types.py | 2 +- 51 files changed, 51 insertions(+), 51 deletions(-) diff --git a/vizro-ai/src/vizro_ai/chains/_llm_models.py b/vizro-ai/src/vizro_ai/chains/_llm_models.py index 68c61e583..dc51ae98d 100644 --- a/vizro-ai/src/vizro_ai/chains/_llm_models.py +++ b/vizro-ai/src/vizro_ai/chains/_llm_models.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field # TODO add new wrappers in if new model support is added diff --git a/vizro-ai/src/vizro_ai/components/chart_selection.py b/vizro-ai/src/vizro_ai/components/chart_selection.py index 3d4677aa1..2d280d9b8 100644 --- a/vizro-ai/src/vizro_ai/components/chart_selection.py +++ b/vizro-ai/src/vizro_ai/components/chart_selection.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/components/code_validation.py b/vizro-ai/src/vizro_ai/components/code_validation.py index b826c77de..fd18a5f03 100644 --- a/vizro-ai/src/vizro_ai/components/code_validation.py +++ b/vizro-ai/src/vizro_ai/components/code_validation.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py b/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py index 5412c2a61..a4a9d850d 100644 --- a/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py +++ b/vizro-ai/src/vizro_ai/components/custom_chart_wrap.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/components/dataframe_craft.py b/vizro-ai/src/vizro_ai/components/dataframe_craft.py index db9396e0d..2e836b281 100755 --- a/vizro-ai/src/vizro_ai/components/dataframe_craft.py +++ b/vizro-ai/src/vizro_ai/components/dataframe_craft.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/components/explanation.py b/vizro-ai/src/vizro_ai/components/explanation.py index 22d9b70ab..f22421053 100644 --- a/vizro-ai/src/vizro_ai/components/explanation.py +++ b/vizro-ai/src/vizro_ai/components/explanation.py @@ -3,7 +3,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/components/visual_code.py b/vizro-ai/src/vizro_ai/components/visual_code.py index 7e40e6871..e2894471d 100644 --- a/vizro-ai/src/vizro_ai/components/visual_code.py +++ b/vizro-ai/src/vizro_ai/components/visual_code.py @@ -3,7 +3,7 @@ try: from pydantic.v1 import BaseModel, Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field from vizro_ai.chains._chain_utils import _log_time diff --git a/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py b/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py index e2f23ca9d..3bc13f79e 100644 --- a/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py +++ b/vizro-ai/src/vizro_ai/schema_manager/schema_manager.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import BaseModel, Field, create_model -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field, create_model diff --git a/vizro-core/src/vizro/models/_action/_action.py b/vizro-core/src/vizro/models/_action/_action.py index 8a059c2c6..82be33701 100644 --- a/vizro-core/src/vizro/models/_action/_action.py +++ b/vizro-core/src/vizro/models/_action/_action.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import Field, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, validator import vizro.actions diff --git a/vizro-core/src/vizro/models/_action/_actions_chain.py b/vizro-core/src/vizro/models/_action/_actions_chain.py index ebbbed4a1..00c453b34 100644 --- a/vizro-core/src/vizro/models/_action/_actions_chain.py +++ b/vizro-core/src/vizro/models/_action/_actions_chain.py @@ -3,7 +3,7 @@ try: from pydantic.v1 import validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_base.py b/vizro-core/src/vizro/models/_base.py index e1fe3d351..f25792b5e 100644 --- a/vizro-core/src/vizro/models/_base.py +++ b/vizro-core/src/vizro/models/_base.py @@ -4,7 +4,7 @@ from pydantic.v1 import BaseModel, Field, validator from pydantic.v1.fields import SHAPE_LIST, ModelField from pydantic.v1.typing import get_args -except ImportError: +except ImportError: # pragma: no cov from pydantic import BaseModel, Field, validator from pydantic.fields import SHAPE_LIST, ModelField from pydantic.typing import get_args diff --git a/vizro-core/src/vizro/models/_components/_form.py b/vizro-core/src/vizro/models/_components/_form.py index 9b5ec01d5..1ef9b44a6 100644 --- a/vizro-core/src/vizro/models/_components/_form.py +++ b/vizro-core/src/vizro/models/_components/_form.py @@ -6,7 +6,7 @@ try: from pydantic.v1 import validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import validator from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 7f5468a30..9e063fd51 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/card.py b/vizro-core/src/vizro/models/_components/card.py index babe00598..6c9c0c448 100644 --- a/vizro-core/src/vizro/models/_components/card.py +++ b/vizro-core/src/vizro/models/_components/card.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/_alert.py b/vizro-core/src/vizro/models/_components/form/_alert.py index 4a1e2fc1c..e4ee08107 100644 --- a/vizro-core/src/vizro/models/_components/form/_alert.py +++ b/vizro-core/src/vizro/models/_components/form/_alert.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/_user_input.py b/vizro-core/src/vizro/models/_components/form/_user_input.py index 7ca4f7633..812ffc279 100644 --- a/vizro-core/src/vizro/models/_components/form/_user_input.py +++ b/vizro-core/src/vizro/models/_components/form/_user_input.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import Field -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/checklist.py b/vizro-core/src/vizro/models/_components/form/checklist.py index 512745c1b..4be346041 100644 --- a/vizro-core/src/vizro/models/_components/form/checklist.py +++ b/vizro-core/src/vizro/models/_components/form/checklist.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, PrivateAttr, root_validator, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/dropdown.py b/vizro-core/src/vizro/models/_components/form/dropdown.py index acc1a1e45..5df9d580f 100755 --- a/vizro-core/src/vizro/models/_components/form/dropdown.py +++ b/vizro-core/src/vizro/models/_components/form/dropdown.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, PrivateAttr, root_validator, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/radio_items.py b/vizro-core/src/vizro/models/_components/form/radio_items.py index b73d7bd6d..07569c3c2 100644 --- a/vizro-core/src/vizro/models/_components/form/radio_items.py +++ b/vizro-core/src/vizro/models/_components/form/radio_items.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, PrivateAttr, root_validator, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/range_slider.py b/vizro-core/src/vizro/models/_components/form/range_slider.py index 69b45cd57..3740dee38 100644 --- a/vizro-core/src/vizro/models/_components/form/range_slider.py +++ b/vizro-core/src/vizro/models/_components/form/range_slider.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/form/slider.py b/vizro-core/src/vizro/models/_components/form/slider.py index 862b5b1dc..b8b21d9a3 100644 --- a/vizro-core/src/vizro/models/_components/form/slider.py +++ b/vizro-core/src/vizro/models/_components/form/slider.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator from vizro.models import Action, VizroBaseModel diff --git a/vizro-core/src/vizro/models/_components/graph.py b/vizro-core/src/vizro/models/_components/graph.py index 28a86dcac..07bfe2d5f 100644 --- a/vizro-core/src/vizro/models/_components/graph.py +++ b/vizro-core/src/vizro/models/_components/graph.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator import vizro.plotly.express as px diff --git a/vizro-core/src/vizro/models/_components/table.py b/vizro-core/src/vizro/models/_components/table.py index dd797b919..5ee771261 100644 --- a/vizro-core/src/vizro/models/_components/table.py +++ b/vizro-core/src/vizro/models/_components/table.py @@ -6,7 +6,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator import vizro.tables as vt diff --git a/vizro-core/src/vizro/models/_controls/filter.py b/vizro-core/src/vizro/models/_controls/filter.py index 8ecd6f224..01ceb239e 100644 --- a/vizro-core/src/vizro/models/_controls/filter.py +++ b/vizro-core/src/vizro/models/_controls/filter.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator from vizro._constants import FILTER_ACTION_PREFIX diff --git a/vizro-core/src/vizro/models/_controls/parameter.py b/vizro-core/src/vizro/models/_controls/parameter.py index 037c27b8e..be5f1b3c0 100644 --- a/vizro-core/src/vizro/models/_controls/parameter.py +++ b/vizro-core/src/vizro/models/_controls/parameter.py @@ -2,7 +2,7 @@ try: from pydantic.v1 import Field, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, validator from vizro._constants import PARAMETER_ACTION_PREFIX diff --git a/vizro-core/src/vizro/models/_dashboard.py b/vizro-core/src/vizro/models/_dashboard.py index 5944da13f..c1d78c4b3 100644 --- a/vizro-core/src/vizro/models/_dashboard.py +++ b/vizro-core/src/vizro/models/_dashboard.py @@ -11,7 +11,7 @@ try: from pydantic.v1 import Field, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, validator import vizro diff --git a/vizro-core/src/vizro/models/_layout.py b/vizro-core/src/vizro/models/_layout.py index 6bca0f0ba..b2ccb6b0c 100644 --- a/vizro-core/src/vizro/models/_layout.py +++ b/vizro-core/src/vizro/models/_layout.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import Field, PrivateAttr, ValidationError, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, ValidationError, validator from vizro._constants import EMPTY_SPACE_CONST diff --git a/vizro-core/src/vizro/models/_navigation/accordion.py b/vizro-core/src/vizro/models/_navigation/accordion.py index 8c2b1914c..d7a44d11b 100644 --- a/vizro-core/src/vizro/models/_navigation/accordion.py +++ b/vizro-core/src/vizro/models/_navigation/accordion.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import Field, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, validator from vizro._constants import ACCORDION_DEFAULT_TITLE diff --git a/vizro-core/src/vizro/models/_navigation/nav_bar.py b/vizro-core/src/vizro/models/_navigation/nav_bar.py index a95df89e3..11a062d39 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_bar.py +++ b/vizro-core/src/vizro/models/_navigation/nav_bar.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import Field, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, validator from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_navigation/nav_link.py b/vizro-core/src/vizro/models/_navigation/nav_link.py index 8208b8cca..bbf8864c1 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_link.py +++ b/vizro-core/src/vizro/models/_navigation/nav_link.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import Field, PrivateAttr, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, PrivateAttr, validator from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_navigation/navigation.py b/vizro-core/src/vizro/models/_navigation/navigation.py index 77e0db9c8..f71b75096 100644 --- a/vizro-core/src/vizro/models/_navigation/navigation.py +++ b/vizro-core/src/vizro/models/_navigation/navigation.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import validator from vizro.models import VizroBaseModel diff --git a/vizro-core/src/vizro/models/_page.py b/vizro-core/src/vizro/models/_page.py index e947aca45..9391fa49c 100644 --- a/vizro-core/src/vizro/models/_page.py +++ b/vizro-core/src/vizro/models/_page.py @@ -6,7 +6,7 @@ try: from pydantic.v1 import Field, root_validator, validator -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, root_validator, validator from vizro._constants import ON_PAGE_LOAD_ACTION_PREFIX diff --git a/vizro-core/src/vizro/models/types.py b/vizro-core/src/vizro/models/types.py index 831963ddf..1423e8049 100644 --- a/vizro-core/src/vizro/models/types.py +++ b/vizro-core/src/vizro/models/types.py @@ -10,7 +10,7 @@ from pydantic.v1 import Field, StrictBool from pydantic.v1.fields import ModelField from pydantic.v1.schema import SkipField -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, StrictBool from pydantic.fields import ModelField from pydantic.schema import SkipField diff --git a/vizro-core/tests/unit/vizro/models/_action/test_action.py b/vizro-core/tests/unit/vizro/models/_action/test_action.py index a6ccf4c85..7b67a8736 100644 --- a/vizro-core/tests/unit/vizro/models/_action/test_action.py +++ b/vizro-core/tests/unit/vizro/models/_action/test_action.py @@ -11,7 +11,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py index 5eecd30ec..528a614ab 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_checklist.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError from vizro.models._action._action import Action diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py index 01d39ec59..12cb3301f 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_dropdown.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError from vizro.models._action._action import Action diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py index ef8861f04..e27804723 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_radioitems.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError from vizro.models._action._action import Action diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py index 7d5142a34..0eaebfaff 100644 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_range_slider.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py index 9355ba995..d51f9cd66 100755 --- a/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py +++ b/vizro-core/tests/unit/vizro/models/_components/form/test_slider.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/test_card.py b/vizro-core/tests/unit/vizro/models/_components/test_card.py index 608116bd2..1d9b4821a 100755 --- a/vizro-core/tests/unit/vizro/models/_components/test_card.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_card.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/test_graph.py b/vizro-core/tests/unit/vizro/models/_components/test_graph.py index b2f689be9..b41468b98 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_graph.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_graph.py @@ -10,7 +10,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_components/test_table.py b/vizro-core/tests/unit/vizro/models/_components/test_table.py index db5fe78d2..4ae7c2ce2 100644 --- a/vizro-core/tests/unit/vizro/models/_components/test_table.py +++ b/vizro-core/tests/unit/vizro/models/_components/test_table.py @@ -7,7 +7,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py index 338418ed2..41eb562b3 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_accordion.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py index d4d72f676..734fc4020 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_bar.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py index 0d1214a57..50243a19d 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_item.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py index 53184ddd3..895ae1061 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_navigation.py @@ -8,7 +8,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_base.py b/vizro-core/tests/unit/vizro/models/test_base.py index b29906215..ae5a09e43 100644 --- a/vizro-core/tests/unit/vizro/models/test_base.py +++ b/vizro-core/tests/unit/vizro/models/test_base.py @@ -4,7 +4,7 @@ try: from pydantic.v1 import Field, ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, ValidationError from typing_extensions import Annotated diff --git a/vizro-core/tests/unit/vizro/models/test_dashboard.py b/vizro-core/tests/unit/vizro/models/test_dashboard.py index 021490767..39f499528 100644 --- a/vizro-core/tests/unit/vizro/models/test_dashboard.py +++ b/vizro-core/tests/unit/vizro/models/test_dashboard.py @@ -10,7 +10,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro diff --git a/vizro-core/tests/unit/vizro/models/test_layout.py b/vizro-core/tests/unit/vizro/models/test_layout.py index 4886b3bef..9d78849f4 100755 --- a/vizro-core/tests/unit/vizro/models/test_layout.py +++ b/vizro-core/tests/unit/vizro/models/test_layout.py @@ -3,7 +3,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_page.py b/vizro-core/tests/unit/vizro/models/test_page.py index 79d483d91..3a1e34456 100644 --- a/vizro-core/tests/unit/vizro/models/test_page.py +++ b/vizro-core/tests/unit/vizro/models/test_page.py @@ -5,7 +5,7 @@ try: from pydantic.v1 import ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/test_types.py b/vizro-core/tests/unit/vizro/models/test_types.py index ff9c266da..8b0b7242b 100644 --- a/vizro-core/tests/unit/vizro/models/test_types.py +++ b/vizro-core/tests/unit/vizro/models/test_types.py @@ -6,7 +6,7 @@ try: from pydantic.v1 import Field, ValidationError -except ImportError: +except ImportError: # pragma: no cov from pydantic import Field, ValidationError from vizro.charts._charts_utils import _DashboardReadyFigure From 711c123ef6a5f72e43dd9289945c09085a817dcf Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:27:59 +0000 Subject: [PATCH 15/23] Fix pydantic version --- vizro-ai/hatch.toml | 3 +++ vizro-core/hatch.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vizro-ai/hatch.toml b/vizro-ai/hatch.toml index 89e474054..276429a42 100644 --- a/vizro-ai/hatch.toml +++ b/vizro-ai/hatch.toml @@ -8,6 +8,9 @@ dependencies = ["scriv"] detached = true scripts = {add = "scriv create --add", collect = ["scriv collect --add", "- hatch run lint:lint --files=CHANGELOG.md"]} +[envs.lower-bounds] +extra-dependencies = ["pydantic==1.10.13"] + [envs.default] dependencies = [ "devtools[pygments]", diff --git a/vizro-core/hatch.toml b/vizro-core/hatch.toml index bff378b78..73c6c9f45 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -9,7 +9,7 @@ matrix.python.features = [ ] [envs.lower-bounds] -extra-dependencies = ["pydantic==2.5.0"] +extra-dependencies = ["pydantic==1.10.13"] [envs.changelog] dependencies = ["scriv"] From 7197c3fb2d81b88084fe58cc4d016357550f2975 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:31:43 +0000 Subject: [PATCH 16/23] Trigger --- ...0231206_212921_antony.milne_pydantic_v2.md | 48 +++++++++++++++++++ vizro-ai/hatch.toml | 6 +-- vizro-core/hatch.toml | 6 +-- 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 vizro-ai/changelog.d/20231206_212921_antony.milne_pydantic_v2.md diff --git a/vizro-ai/changelog.d/20231206_212921_antony.milne_pydantic_v2.md b/vizro-ai/changelog.d/20231206_212921_antony.milne_pydantic_v2.md new file mode 100644 index 000000000..f1f65e73c --- /dev/null +++ b/vizro-ai/changelog.d/20231206_212921_antony.milne_pydantic_v2.md @@ -0,0 +1,48 @@ + + + + + + + + + diff --git a/vizro-ai/hatch.toml b/vizro-ai/hatch.toml index 276429a42..d04a70dde 100644 --- a/vizro-ai/hatch.toml +++ b/vizro-ai/hatch.toml @@ -8,9 +8,6 @@ dependencies = ["scriv"] detached = true scripts = {add = "scriv create --add", collect = ["scriv collect --add", "- hatch run lint:lint --files=CHANGELOG.md"]} -[envs.lower-bounds] -extra-dependencies = ["pydantic==1.10.13"] - [envs.default] dependencies = [ "devtools[pygments]", @@ -61,5 +58,8 @@ dependencies = [ detached = true scripts = {lint = "SKIP=gitleaks pre-commit run {args:--all-files}"} +[envs.lower-bounds] +extra-dependencies = ["pydantic==1.10.13"] + [version] path = "src/vizro_ai/__init__.py" diff --git a/vizro-core/hatch.toml b/vizro-core/hatch.toml index 73c6c9f45..0ab203a2e 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -8,9 +8,6 @@ matrix.python.features = [ {value = "kedro", if = ["3.8", "3.9", "3.10"]} ] -[envs.lower-bounds] -extra-dependencies = ["pydantic==1.10.13"] - [envs.changelog] dependencies = ["scriv"] detached = true @@ -76,6 +73,9 @@ dependencies = [ detached = true scripts = {lint = "SKIP=gitleaks pre-commit run {args:--all-files}"} +[envs.lower-bounds] +extra-dependencies = ["pydantic==1.10.13"] + [publish.index] disable = true From c0b504a8cbb9a2d051aafb58995a8b81a68770c0 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:52:09 +0000 Subject: [PATCH 17/23] Fix names --- .github/workflows/test-integration-vizro-ai.yml | 5 ++++- .github/workflows/test-integration-vizro-core.yml | 2 +- .github/workflows/test-unit-vizro-ai.yml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml index 387d7b9c7..3e12e4feb 100644 --- a/.github/workflows/test-integration-vizro-ai.yml +++ b/.github/workflows/test-integration-vizro-ai.yml @@ -20,7 +20,7 @@ env: jobs: test-integration-vizro-ai: - name: test-integration-vizro-ai on Py${{ matrix.python-version }} + name: test-integration-vizro-ai on Py${{ matrix.python-version }} ${{ matrix.label }} runs-on: ubuntu-latest strategy: @@ -50,6 +50,9 @@ jobs: - name: Install Hatch run: pip install --upgrade hatch + - name: List dependencies + run: hatch run ${{ matrix.hatch-env }}:pip freeze + - name: Run vizro-ai integration tests with pypi vizro run: | export OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/test-integration-vizro-core.yml b/.github/workflows/test-integration-vizro-core.yml index 27cdadaed..f73e3ed79 100644 --- a/.github/workflows/test-integration-vizro-core.yml +++ b/.github/workflows/test-integration-vizro-core.yml @@ -20,7 +20,7 @@ env: jobs: test-integration-vizro-core: - name: test-integration-vizro-core on Py${{ matrix.python-version }} + name: test-integration-vizro-core on Py${{ matrix.python-version }} ${{ matrix.label }} runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/test-unit-vizro-ai.yml b/.github/workflows/test-unit-vizro-ai.yml index 1711b61c9..c82616aaf 100644 --- a/.github/workflows/test-unit-vizro-ai.yml +++ b/.github/workflows/test-unit-vizro-ai.yml @@ -20,7 +20,7 @@ env: jobs: test-unit-vizro-ai: - name: test-unit-vizro-ai on Py${{ matrix.python-version }} + name: test-unit-vizro-ai on Py${{ matrix.python-version }} ${{ matrix.label }} runs-on: ubuntu-latest strategy: From 5f1343c22a621d8f863b1cc842a0d628619bad44 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 21:56:53 +0000 Subject: [PATCH 18/23] Test breaking something --- vizro-core/schemas/0.1.7.dev1.json | 1089 +++++++++++++++++ .../src/vizro/models/_components/button.py | 5 +- 2 files changed, 1090 insertions(+), 4 deletions(-) create mode 100644 vizro-core/schemas/0.1.7.dev1.json diff --git a/vizro-core/schemas/0.1.7.dev1.json b/vizro-core/schemas/0.1.7.dev1.json new file mode 100644 index 000000000..0af9f1feb --- /dev/null +++ b/vizro-core/schemas/0.1.7.dev1.json @@ -0,0 +1,1089 @@ +{ + "title": "Dashboard", + "description": "Vizro Dashboard to be used within [`Vizro`][vizro._vizro.Vizro.build].\n\nArgs:\n pages (List[Page]): See [`Page`][vizro.models.Page].\n theme (Literal[\"vizro_dark\", \"vizro_light\"]): Layout theme to be applied across dashboard.\n Defaults to `vizro_dark`.\n navigation (Optional[Navigation]): See [`Navigation`][vizro.models.Navigation]. Defaults to `None`.\n title (str): Dashboard title to appear on every page on top left-side. Defaults to `\"\"`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "pages": { + "title": "Pages", + "type": "array", + "items": { + "$ref": "#/definitions/Page" + } + }, + "theme": { + "title": "Theme", + "description": "Layout theme to be applied across dashboard. Defaults to `vizro_dark`", + "default": "vizro_dark", + "enum": ["vizro_dark", "vizro_light"], + "type": "string" + }, + "navigation": { + "$ref": "#/definitions/Navigation" + }, + "title": { + "title": "Title", + "description": "Dashboard title to appear on every page on top left-side.", + "default": "", + "type": "string" + } + }, + "required": ["pages"], + "additionalProperties": false, + "definitions": { + "Action": { + "title": "Action", + "description": "Action to be inserted into `actions` of relevant component.\n\nArgs:\n function (CapturedCallable): See [`CapturedCallable`][vizro.models.types.CapturedCallable].\n inputs (List[str]): Inputs in the form `.` passed to the action function.\n Defaults to `[]`.\n outputs (List[str]): Outputs in the form `.` changed by the action function.\n Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "inputs": { + "title": "Inputs", + "description": "Inputs in the form `.` passed to the action function.", + "default": [], + "pattern": "^[a-zA-Z0-9_]+[.][a-zA-Z_]+$", + "type": "array", + "items": { + "type": "string", + "pattern": "^[a-zA-Z0-9_]+[.][a-zA-Z_]+$" + } + }, + "outputs": { + "title": "Outputs", + "description": "Outputs in the form `.` changed by the action function.", + "default": [], + "pattern": "^[a-zA-Z0-9_]+[.][a-zA-Z_]+$", + "type": "array", + "items": { + "type": "string", + "pattern": "^[a-zA-Z0-9_]+[.][a-zA-Z_]+$" + } + } + }, + "additionalProperties": false + }, + "Button": { + "title": "Button", + "description": "Component provided to `Page` to trigger any defined `action` in `Page`.\n\nArgs:\n type (Literal[\"button\"]): Defaults to `\"button\"`.\n text (str): Text to be displayed on button. Defaults to `\"Click me!\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "button", + "enum": ["button"], + "type": "string" + }, + "text": { + "title": "Text", + "description": "Text to be displayed on button.", + "default": "Click me!", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Card": { + "title": "Card", + "description": "Creates a card utilizing `dcc.Markdown` as title and text component.\n\nArgs:\n type (Literal[\"card\"]): Defaults to `\"card\"`.\n text (str): Markdown string to create card title/text that should adhere to the CommonMark Spec.\n href (str): URL (relative or absolute) to navigate to. If not provided the Card serves as a text card\n only. Defaults to `\"\"`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "card", + "enum": ["card"], + "type": "string" + }, + "text": { + "title": "Text", + "description": "Markdown string to create card title/text that should adhere to the CommonMark Spec.", + "type": "string" + }, + "href": { + "title": "Href", + "description": "URL (relative or absolute) to navigate to. If not provided the Card serves as a text card only.", + "default": "", + "type": "string" + } + }, + "required": ["text"], + "additionalProperties": false + }, + "Graph": { + "title": "Graph", + "description": "Wrapper for `dcc.Graph` to visualize charts in dashboard.\n\nArgs:\n type (Literal[\"graph\"]): Defaults to `\"graph\"`.\n figure (CapturedCallable): See [`CapturedCallable`][vizro.models.types.CapturedCallable].\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "graph", + "enum": ["graph"], + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Table": { + "title": "Table", + "description": "Wrapper for table components to visualize in dashboard.\n\nArgs:\n type (Literal[\"table\"]): Defaults to `\"table\"`.\n figure (CapturedCallable): Table like object to be displayed. Current choices include:\n [`dash_table.DataTable`](https://dash.plotly.com/datatable).\n title (str): Title of the table. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "table", + "enum": ["table"], + "type": "string" + }, + "title": { + "title": "Title", + "description": "Title of the table", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Layout": { + "title": "Layout", + "description": "Grid specification to place chart/components on the [`Page`][vizro.models.Page].\n\nArgs:\n grid (List[List[int]]): Grid specification to arrange components on screen.\n row_gap (str): Gap between rows in px. Defaults to `\"12px\"`.\n col_gap (str): Gap between columns in px. Defaults to `\"12px\"`.\n row_min_height (str): Minimum row height in px. Defaults to `\"0px\"`.\n col_min_width (str): Minimum column width in px. Defaults to `\"0px\"`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "grid": { + "title": "Grid", + "description": "Grid specification to arrange components on screen.", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "row_gap": { + "title": "Row Gap", + "description": "Gap between rows in px. Defaults to 12px.", + "default": "12px", + "pattern": "[0-9]+px", + "type": "string" + }, + "col_gap": { + "title": "Col Gap", + "description": "Gap between columns in px. Defaults to 12px.", + "default": "12px", + "pattern": "[0-9]+px", + "type": "string" + }, + "row_min_height": { + "title": "Row Min Height", + "description": "Minimum row height in px. Defaults to 0px.", + "default": "0px", + "pattern": "[0-9]+px", + "type": "string" + }, + "col_min_width": { + "title": "Col Min Width", + "description": "Minimum column width in px. Defaults to 0px.", + "default": "0px", + "pattern": "[0-9]+px", + "type": "string" + } + }, + "required": ["grid"], + "additionalProperties": false + }, + "OptionsDictType": { + "title": "OptionsDictType", + "type": "object", + "properties": { + "label": { + "title": "Label", + "type": "string" + }, + "value": { + "title": "Value", + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + } + ] + } + }, + "required": ["label", "value"], + "additionalProperties": false + }, + "Checklist": { + "title": "Checklist", + "description": "Categorical multi-selector `Checklist` to be provided to [`Filter`][vizro.models.Filter].\n\nArgs:\n type (Literal[\"checklist\"]): Defaults to `\"checklist\"`.\n options (OptionsType): See [`OptionsType`][vizro.models.types.OptionsType]. Defaults to `[]`.\n value (Optional[MultiValueType]): See [`MultiValueType`][vizro.models.types.MultiValueType]. Defaults to `None`.\n title (str): Title to be displayed. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "checklist", + "enum": ["checklist"], + "type": "string" + }, + "options": { + "title": "Options", + "default": [], + "anyOf": [ + { + "type": "array", + "items": { + "type": "boolean" + } + }, + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/OptionsDictType" + } + } + ] + }, + "value": { + "title": "Value", + "anyOf": [ + { + "type": "array", + "items": { + "type": "boolean" + } + }, + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "title": { + "title": "Title", + "description": "Title to be displayed", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Dropdown": { + "title": "Dropdown", + "description": "Categorical multi-selector `Dropdown` to be provided to [`Filter`][vizro.models.Filter].\n\nArgs:\n type (Literal[\"dropdown\"]): Defaults to `\"dropdown\"`.\n options (OptionsType): See [`OptionsType`][vizro.models.types.OptionsType]. Defaults to `[]`.\n value (Optional[Union[SingleValueType, MultiValueType]]): See\n [`SingleValueType`][vizro.models.types.SingleValueType] and\n [`MultiValueType`][vizro.models.types.MultiValueType]. Defaults to `None`.\n multi (bool): Whether to allow selection of multiple values. Defaults to `True`.\n title (str): Title to be displayed. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "dropdown", + "enum": ["dropdown"], + "type": "string" + }, + "options": { + "title": "Options", + "default": [], + "anyOf": [ + { + "type": "array", + "items": { + "type": "boolean" + } + }, + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/OptionsDictType" + } + } + ] + }, + "value": { + "title": "Value", + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "boolean" + } + }, + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "multi": { + "title": "Multi", + "description": "Whether to allow selection of multiple values", + "default": true, + "type": "boolean" + }, + "title": { + "title": "Title", + "description": "Title to be displayed", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "RadioItems": { + "title": "RadioItems", + "description": "Categorical single-selector `RadioItems` to be provided to `Filter`.\n\nArgs:\n type (Literal[\"radio_items\"]): Defaults to `\"radio_items\"`.\n options (OptionsType): See [`OptionsType`][vizro.models.types.OptionsType]. Defaults to `[]`.\n value (Optional[SingleValueType]): See [`SingleValueType`][vizro.models.types.SingleValueType].\n Defaults to `None`.\n title (str): Title to be displayed. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "radio_items", + "enum": ["radio_items"], + "type": "string" + }, + "options": { + "title": "Options", + "default": [], + "anyOf": [ + { + "type": "array", + "items": { + "type": "boolean" + } + }, + { + "type": "array", + "items": { + "type": "number" + } + }, + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "array", + "items": { + "$ref": "#/definitions/OptionsDictType" + } + } + ] + }, + "value": { + "title": "Value", + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "number" + }, + { + "type": "string" + } + ] + }, + "title": { + "title": "Title", + "description": "Title to be displayed", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "RangeSlider": { + "title": "RangeSlider", + "description": "Numeric multi-selector `RangeSlider`.\n\nCan be provided to [`Filter`][vizro.models.Filter] or\n[`Parameter`][vizro.models.Parameter]. Based on the underlying\n[`dcc.RangeSlider`](https://dash.plotly.com/dash-core-components/rangeslider).\n\nArgs:\n type (Literal[\"range_slider\"]): Defaults to `\"range_slider\"`.\n min (Optional[float]): Start value for slider. Defaults to `None`.\n max (Optional[float]): End value for slider. Defaults to `None`.\n step (Optional[float]): Step-size for marks on slider. Defaults to `None`.\n marks (Optional[Dict[float, str]]): Marks to be displayed on slider. Defaults to `{}`.\n value (Optional[List[float]]): Default start and end value for slider. Must be 2 items. Defaults to `None`.\n title (str): Title to be displayed. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "range_slider", + "enum": ["range_slider"], + "type": "string" + }, + "min": { + "title": "Min", + "description": "Start value for slider.", + "type": "number" + }, + "max": { + "title": "Max", + "description": "End value for slider.", + "type": "number" + }, + "step": { + "title": "Step", + "description": "Step-size for marks on slider.", + "type": "number" + }, + "marks": { + "title": "Marks", + "description": "Marks to be displayed on slider.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "value": { + "title": "Value", + "description": "Default start and end value for slider", + "minItems": 2, + "maxItems": 2, + "type": "array", + "items": { + "type": "number" + } + }, + "title": { + "title": "Title", + "description": "Title to be displayed.", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Slider": { + "title": "Slider", + "description": "Numeric single-selector `Slider`.\n\nCan be provided to [`Filter`][vizro.models.Filter] or\n[`Parameter`][vizro.models.Parameter]. Based on the underlying\n[`dcc.Slider`](https://dash.plotly.com/dash-core-components/slider).\n\nArgs:\n type (Literal[\"range_slider\"]): Defaults to `\"range_slider\"`.\n min (Optional[float]): Start value for slider. Defaults to `None`.\n max (Optional[float]): End value for slider. Defaults to `None`.\n step (Optional[float]): Step-size for marks on slider. Defaults to `None`.\n marks (Optional[Dict[float, str]]): Marks to be displayed on slider. Defaults to `{}`.\n value (Optional[float]): Default value for slider. Defaults to `None`.\n title (str): Title to be displayed. Defaults to `\"\"`.\n actions (List[Action]): See [`Action`][vizro.models.Action]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "slider", + "enum": ["slider"], + "type": "string" + }, + "min": { + "title": "Min", + "description": "Start value for slider.", + "type": "number" + }, + "max": { + "title": "Max", + "description": "End value for slider.", + "type": "number" + }, + "step": { + "title": "Step", + "description": "Step-size for marks on slider.", + "type": "number" + }, + "marks": { + "title": "Marks", + "description": "Marks to be displayed on slider.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "value": { + "title": "Value", + "description": "Default value for slider.", + "type": "number" + }, + "title": { + "title": "Title", + "description": "Title to be displayed.", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "additionalProperties": false + }, + "Filter": { + "title": "Filter", + "description": "Filter the data supplied to `targets` on the [`Page`][vizro.models.Page].\n\nExamples:\n >>> print(repr(Filter(column=\"species\")))\n\nArgs:\n type (Literal[\"filter\"]): Defaults to `\"filter\"`.\n column (str): Column of `DataFrame` to filter.\n targets (List[ModelID]): Target component to be affected by filter. If none are given then target all components\n on the page that use `column`.\n selector (Optional[SelectorType]): See [SelectorType][vizro.models.types.SelectorType]. Defaults to `None`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "filter", + "enum": ["filter"], + "type": "string" + }, + "column": { + "title": "Column", + "description": "Column of DataFrame to filter.", + "type": "string" + }, + "targets": { + "title": "Targets", + "description": "Target component to be affected by filter. If none are given then target all components on the page that use `column`.", + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "selector": { + "title": "Selector", + "anyOf": [ + { + "$ref": "#/definitions/Checklist" + }, + { + "$ref": "#/definitions/Dropdown" + }, + { + "$ref": "#/definitions/RadioItems" + }, + { + "$ref": "#/definitions/RangeSlider" + }, + { + "$ref": "#/definitions/Slider" + } + ] + } + }, + "required": ["column"], + "additionalProperties": false + }, + "Parameter": { + "title": "Parameter", + "description": "Alter the arguments supplied to any `targets` on the [`Page`][vizro.models.Page].\n\nExamples:\n >>> print(repr(Parameter(\n >>> targets=[\"scatter.x\"], selector=Slider(min=0, max=1, default=0.8, title=\"Bubble opacity\"))))\n\nArgs:\n type (Literal[\"parameter\"]): Defaults to `\"parameter\"`.\n targets (List[str]): Targets in the form of `.`.\n selector (SelectorType): See [SelectorType][vizro.models.types.SelectorType]. Converts selector value\n `\"NONE\"` into `None` to allow optional parameters.\n\nRaises:\n ValueError: If targets are invalid and not of the form `.`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "parameter", + "enum": ["parameter"], + "type": "string" + }, + "targets": { + "title": "Targets", + "description": "Targets in the form of `.`.", + "type": "array", + "items": { + "type": "string" + } + }, + "selector": { + "title": "Selector", + "description": "Selectors to be used inside a control.", + "discriminator": { + "propertyName": "type", + "mapping": { + "checklist": "#/definitions/Checklist", + "dropdown": "#/definitions/Dropdown", + "radio_items": "#/definitions/RadioItems", + "range_slider": "#/definitions/RangeSlider", + "slider": "#/definitions/Slider" + } + }, + "oneOf": [ + { + "$ref": "#/definitions/Checklist" + }, + { + "$ref": "#/definitions/Dropdown" + }, + { + "$ref": "#/definitions/RadioItems" + }, + { + "$ref": "#/definitions/RangeSlider" + }, + { + "$ref": "#/definitions/Slider" + } + ] + } + }, + "required": ["targets", "selector"], + "additionalProperties": false + }, + "ActionsChain": { + "title": "ActionsChain", + "description": "All models that are registered to the model manager should inherit from this class.\n\nArgs:\n id (str): ID to identify model. Must be unique throughout the whole dashboard. Defaults to `\"\"`.\n When no ID is chosen, ID will be automatically generated.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "trigger": { + "title": "Trigger", + "type": "array", + "items": [ + { + "title": "Component Id", + "type": "string" + }, + { + "title": "Component Property", + "type": "string" + } + ], + "minItems": 2, + "maxItems": 2 + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/Action" + } + } + }, + "required": ["trigger"], + "additionalProperties": false + }, + "Page": { + "title": "Page", + "description": "A page in [`Dashboard`][vizro.models.Dashboard] with its own URL path and place in the `Navigation`.\n\nArgs:\n components (List[ComponentType]): See [ComponentType][vizro.models.types.ComponentType]. At least one component\n has to be provided.\n title (str): Title to be displayed.\n layout (Optional[Layout]): Layout to place components in. Defaults to `None`.\n controls (List[ControlType]): See [ControlType][vizro.models.types.ControlType]. Defaults to `[]`.\n path (str): Path to navigate to page. Defaults to `\"\"`.\n\nRaises:\n ValueError: If number of page and grid components is not the same", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "components": { + "title": "Components", + "type": "array", + "items": { + "discriminator": { + "propertyName": "type", + "mapping": { + "button": "#/definitions/Button", + "card": "#/definitions/Card", + "graph": "#/definitions/Graph", + "table": "#/definitions/Table" + } + }, + "oneOf": [ + { + "$ref": "#/definitions/Button" + }, + { + "$ref": "#/definitions/Card" + }, + { + "$ref": "#/definitions/Graph" + }, + { + "$ref": "#/definitions/Table" + } + ] + } + }, + "title": { + "title": "Title", + "description": "Title to be displayed.", + "type": "string" + }, + "layout": { + "$ref": "#/definitions/Layout" + }, + "controls": { + "title": "Controls", + "default": [], + "type": "array", + "items": { + "discriminator": { + "propertyName": "type", + "mapping": { + "filter": "#/definitions/Filter", + "parameter": "#/definitions/Parameter" + } + }, + "oneOf": [ + { + "$ref": "#/definitions/Filter" + }, + { + "$ref": "#/definitions/Parameter" + } + ] + } + }, + "path": { + "title": "Path", + "description": "Path to navigate to page.", + "default": "", + "type": "string" + }, + "actions": { + "title": "Actions", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/ActionsChain" + } + } + }, + "required": ["components", "title"], + "additionalProperties": false + }, + "Accordion": { + "title": "Accordion", + "description": "Accordion to be used as nav_selector in [`Navigation`][vizro.models.Navigation].\n\nArgs:\n type (Literal[\"accordion\"]): Defaults to `\"accordion\"`.\n pages (Dict[str, List[str]]): Mapping from name of a pages group to a list of page IDs. Defaults to `{}`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "accordion", + "enum": ["accordion"], + "type": "string" + }, + "pages": { + "title": "Pages", + "description": "Mapping from name of a pages group to a list of page IDs.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + "NavLink": { + "title": "NavLink", + "description": "Icon to be used in Navigation Panel of Dashboard.\n\nArgs:\n ages (Optional[NavPagesType]): See [`NavPagesType`][vizro.models.types.NavPagesType].\n Defaults to `[]`.\n label (str): Text description of the icon for use in tooltip.\n icon (str): Icon name from [Google Material icons library](https://fonts.google.com/icons).\n Defaults to `\"\"`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "pages": { + "title": "Pages", + "default": [], + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + ] + }, + "label": { + "title": "Label", + "description": "Text description of the icon for use in tooltip.", + "type": "string" + }, + "icon": { + "title": "Icon", + "description": "Icon name from Google Material icons library.", + "default": "", + "type": "string" + } + }, + "required": ["label"], + "additionalProperties": false + }, + "NavBar": { + "title": "NavBar", + "description": "Navigation bar to be used as a nav_selector for `Navigation`.\n\nArgs:\n type (Literal[\"nav_bar\"]): Defaults to `\"nav_bar\"`.\n pages (Dict[str, List[str]]): Mapping from name of a pages group to a list of page IDs. Defaults to `{}`.\n items (List[NavLink]): See [`NavLink`][vizro.models.NavLink]. Defaults to `[]`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "type": { + "title": "Type", + "default": "nav_bar", + "enum": ["nav_bar"], + "type": "string" + }, + "pages": { + "title": "Pages", + "description": "Mapping from name of a pages group to a list of page IDs.", + "default": {}, + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "items": { + "title": "Items", + "default": [], + "type": "array", + "items": { + "$ref": "#/definitions/NavLink" + } + } + }, + "additionalProperties": false + }, + "Navigation": { + "title": "Navigation", + "description": "Navigation in [`Dashboard`][vizro.models.Dashboard] to structure [`Pages`][vizro.models.Page].\n\nArgs:\n pages (Optional[NavPagesType]): See [`NavPagesType`][vizro.models.types.NavPagesType].\n Defaults to [].\n nav_selector (Optional[NavSelectorType]): See [`NavSelectorType`][vizro.models.types.NavSelectorType].\n Defaults to `None`.", + "type": "object", + "properties": { + "id": { + "title": "Id", + "description": "ID to identify model. Must be unique throughout the whole dashboard.When no ID is chosen, ID will be automatically generated.", + "default": "", + "type": "string" + }, + "pages": { + "title": "Pages", + "default": [], + "anyOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + ] + }, + "nav_selector": { + "title": "Nav Selector", + "anyOf": [ + { + "$ref": "#/definitions/Accordion" + }, + { + "$ref": "#/definitions/NavBar" + } + ] + } + }, + "additionalProperties": false + } + } +} diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 9e063fd51..d604f5cdc 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -3,10 +3,7 @@ import dash_bootstrap_components as dbc from dash import html -try: - from pydantic.v1 import Field -except ImportError: # pragma: no cov - from pydantic import Field +from pydantic.v1 import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory From d241500fd6677c428d4fb15d4b145a7fbaf93b8b Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 22:03:09 +0000 Subject: [PATCH 19/23] Test breaking something else --- vizro-core/src/vizro/models/_components/button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index d604f5cdc..2c001904f 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -3,7 +3,7 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic.v1 import Field +from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory From efc31692419cadcf93738e665eb20d64a1899e35 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 22:09:12 +0000 Subject: [PATCH 20/23] Try to lower bound dash --- vizro-core/hatch.toml | 2 +- vizro-core/src/vizro/models/_components/button.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/vizro-core/hatch.toml b/vizro-core/hatch.toml index 0ab203a2e..225537129 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -74,7 +74,7 @@ detached = true scripts = {lint = "SKIP=gitleaks pre-commit run {args:--all-files}"} [envs.lower-bounds] -extra-dependencies = ["pydantic==1.10.13"] +extra-dependencies = ["pydantic==1.10.13", "dash==2.11"] [publish.index] disable = true diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 2c001904f..9e063fd51 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -3,7 +3,10 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic import Field +try: + from pydantic.v1 import Field +except ImportError: # pragma: no cov + from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory From 54a8a20e49846bd86aecd3e00525d340526518a4 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 22:13:59 +0000 Subject: [PATCH 21/23] Revert "Try to lower bound dash" This reverts commit efc31692419cadcf93738e665eb20d64a1899e35. --- vizro-core/hatch.toml | 2 +- vizro-core/src/vizro/models/_components/button.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/vizro-core/hatch.toml b/vizro-core/hatch.toml index 225537129..0ab203a2e 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -74,7 +74,7 @@ detached = true scripts = {lint = "SKIP=gitleaks pre-commit run {args:--all-files}"} [envs.lower-bounds] -extra-dependencies = ["pydantic==1.10.13", "dash==2.11"] +extra-dependencies = ["pydantic==1.10.13"] [publish.index] disable = true diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 9e063fd51..2c001904f 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -3,10 +3,7 @@ import dash_bootstrap_components as dbc from dash import html -try: - from pydantic.v1 import Field -except ImportError: # pragma: no cov - from pydantic import Field +from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory From fbff5c754641cf91f938544ebf1e77cf15523868 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 22:14:21 +0000 Subject: [PATCH 22/23] Update snyk requirements --- vizro-core/snyk/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vizro-core/snyk/requirements.txt b/vizro-core/snyk/requirements.txt index a65406ad0..5d2fe4b32 100644 --- a/vizro-core/snyk/requirements.txt +++ b/vizro-core/snyk/requirements.txt @@ -1,7 +1,7 @@ dash>=2.11 dash_bootstrap_components pandas -pydantic>=1.10.13, <2 +pydantic>=1.10.13 dash_daq ipython>=8.10.0 numpy>=1.22.2 From a5ddf6dc89d95500628906ccd5eb43bb03510190 Mon Sep 17 00:00:00 2001 From: Antony Milne Date: Wed, 6 Dec 2023 22:19:23 +0000 Subject: [PATCH 23/23] Lint --- vizro-core/src/vizro/models/_components/button.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vizro-core/src/vizro/models/_components/button.py b/vizro-core/src/vizro/models/_components/button.py index 2c001904f..9e063fd51 100644 --- a/vizro-core/src/vizro/models/_components/button.py +++ b/vizro-core/src/vizro/models/_components/button.py @@ -3,7 +3,10 @@ import dash_bootstrap_components as dbc from dash import html -from pydantic import Field +try: + from pydantic.v1 import Field +except ImportError: # pragma: no cov + from pydantic import Field from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory