diff --git a/.github/workflows/checks-vizro-ai.yml b/.github/workflows/checks-vizro-ai.yml index bc210e337..5f318cba4 100644 --- a/.github/workflows/checks-vizro-ai.yml +++ b/.github/workflows/checks-vizro-ai.yml @@ -19,8 +19,8 @@ concurrency: group: checks-ai-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 PYTHON_VERSION: "3.11" jobs: diff --git a/.github/workflows/checks-vizro-core.yml b/.github/workflows/checks-vizro-core.yml index 928d57189..a07837799 100644 --- a/.github/workflows/checks-vizro-core.yml +++ b/.github/workflows/checks-vizro-core.yml @@ -19,8 +19,8 @@ concurrency: group: checks-core-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 PYTHON_VERSION: "3.11" jobs: diff --git a/.github/workflows/lint-vizro-all.yml b/.github/workflows/lint-vizro-all.yml index 88f86d257..6d22e7518 100644 --- a/.github/workflows/lint-vizro-all.yml +++ b/.github/workflows/lint-vizro-all.yml @@ -9,14 +9,14 @@ on: branches: [main] pull_request: branches: - - "main" + - main concurrency: group: lint-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 PYTHON_VERSION: "3.11" jobs: diff --git a/.github/workflows/test-integration-vizro-ai.yml b/.github/workflows/test-integration-vizro-ai.yml index 3185242bb..3e12e4feb 100644 --- a/.github/workflows/test-integration-vizro-ai.yml +++ b/.github/workflows/test-integration-vizro-ai.yml @@ -9,22 +9,33 @@ on: branches: [main] pull_request: branches: - - "main" + - main concurrency: group: test-integration-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 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: + fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + 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 @@ -39,11 +50,14 @@ 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 }} export OPENAI_API_BASE=${{ secrets.OPENAI_API_BASE }} - hatch run all.py${{ matrix.python-version }}:test-integration + hatch run ${{ matrix.hatch-env }}:test-integration - name: Run vizro-ai integration tests with local vizro run: | @@ -52,5 +66,5 @@ jobs: 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 + 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 index d13557fca..f73e3ed79 100644 --- a/.github/workflows/test-integration-vizro-core.yml +++ b/.github/workflows/test-integration-vizro-core.yml @@ -9,23 +9,35 @@ on: branches: [main] pull_request: branches: - - "main" + - main concurrency: group: test-integration-${{ github.head_ref }} env: - PYTHONUNBUFFERED: "1" - FORCE_COLOR: "1" + PYTHONUNBUFFERED: 1 + FORCE_COLOR: 1 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: 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 steps: - uses: actions/checkout@v4 @@ -39,7 +51,7 @@ jobs: run: pip install --upgrade hatch - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze + run: hatch run ${{ matrix.hatch-env }}:pip freeze - name: Run integration tests - run: hatch run all.py${{ matrix.python-version }}:test-integration + 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 index f6c3b288e..c82616aaf 100644 --- a/.github/workflows/test-unit-vizro-ai.yml +++ b/.github/workflows/test-unit-vizro-ai.yml @@ -9,23 +9,33 @@ 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-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: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + 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 @@ -39,8 +49,7 @@ jobs: run: pip install --upgrade hatch - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze + run: hatch run ${{ matrix.hatch-env }}:pip freeze - name: Run unit tests - run: | - hatch run all.py${{ matrix.python-version }}:test-unit-coverage + 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 3ca2025c4..890091d42 100644 --- a/.github/workflows/test-unit-vizro-core.yml +++ b/.github/workflows/test-unit-vizro-core.yml @@ -9,23 +9,35 @@ 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: - 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 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 steps: - uses: actions/checkout@v4 @@ -39,7 +51,7 @@ jobs: run: pip install --upgrade hatch - name: List dependencies - run: hatch run all.py${{ matrix.python-version }}:pip freeze + run: hatch run ${{ matrix.hatch-env }}:pip freeze - name: Run unit tests - run: hatch run all.py${{ matrix.python-version }}:test-unit-coverage + run: hatch run ${{ matrix.hatch-env }}:test-unit-coverage 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-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 89e474054..d04a70dde 100644 --- a/vizro-ai/hatch.toml +++ b/vizro-ai/hatch.toml @@ -58,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-ai/src/vizro_ai/chains/_llm_models.py b/vizro-ai/src/vizro_ai/chains/_llm_models.py index 73210fc8d..dc51ae98d 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: # pragma: no cov + 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..2d280d9b8 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: # pragma: no cov + 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..fd18a5f03 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: # pragma: no cov + 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..a4a9d850d 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: # pragma: no cov + 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..2e836b281 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: # pragma: no cov + 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..f22421053 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: # pragma: no cov + 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..e2894471d 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: # pragma: no cov + 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..3bc13f79e 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: # pragma: no cov + from pydantic import BaseModel, Field, create_model class SchemaManager: 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/hatch.toml b/vizro-core/hatch.toml index de38c7c8c..0ab203a2e 100644 --- a/vizro-core/hatch.toml +++ b/vizro-core/hatch.toml @@ -73,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 diff --git a/vizro-core/pyproject.toml b/vizro-core/pyproject.toml index 1ee91974a..f5088da68 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 manually "dash_daq", "dash_mantine_components", "ipython>=8.10.0", # not directly required, pinned by Snyk to avoid a vulnerability: https://app.snyk.io/vuln/SNYK-PYTHON-IPYTHON-3318382 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/snyk/requirements.txt b/vizro-core/snyk/requirements.txt index 8d7e8efbc..81b4e6dbe 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 dash_mantine_components ipython>=8.10.0 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/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 2b1552cae..82be33701 100644 --- a/vizro-core/src/vizro/models/_action/_action.py +++ b/vizro-core/src/vizro/models/_action/_action.py @@ -4,7 +4,11 @@ from typing import Any, Dict, List from dash import Input, Output, State, callback, html -from pydantic import Field, validator + +try: + from pydantic.v1 import Field, validator +except ImportError: # pragma: no cov + 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..00c453b34 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: # 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 a46f04367..f25792b5e 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: # pragma: no cov + 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 @@ -58,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.py b/vizro-core/src/vizro/models/_components/_form.py index 3ee9c1cd5..1ef9b44a6 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: # pragma: no cov + 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..9e063fd51 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: # pragma: no cov + 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..6c9c0c448 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: # pragma: no cov + 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..e4ee08107 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: # pragma: no cov + 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..812ffc279 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: # pragma: no cov + 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..4be346041 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: # pragma: no cov + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory @@ -22,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 2b2a84dd8..5df9d580f 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: # pragma: no cov + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory @@ -25,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 0fa6733d2..07569c3c2 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: # pragma: no cov + from pydantic import Field, PrivateAttr, root_validator, validator from vizro.models import Action, VizroBaseModel from vizro.models._action._actions_chain import _action_validator_factory @@ -23,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/form/range_slider.py b/vizro-core/src/vizro/models/_components/form/range_slider.py index 6249aba22..3740dee38 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: # pragma: no cov + 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..b8b21d9a3 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: # pragma: no cov + 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..07bfe2d5f 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: # pragma: no cov + 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..5ee771261 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: # pragma: no cov + from pydantic import Field, PrivateAttr, validator import vizro.tables as vt from vizro.managers import data_manager @@ -38,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/_controls/filter.py b/vizro-core/src/vizro/models/_controls/filter.py index f3d90c284..01ceb239e 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: # pragma: no cov + 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..be5f1b3c0 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: # pragma: no cov + 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 b4012e2d8..c1d78c4b3 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: # pragma: no cov + 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..b2ccb6b0c 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: # pragma: no cov + 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 949b2ac55..724dda7d6 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: # pragma: no cov + 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..11a062d39 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: # pragma: no cov + 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 04fef50e0..319addaa2 100644 --- a/vizro-core/src/vizro/models/_navigation/nav_link.py +++ b/vizro-core/src/vizro/models/_navigation/nav_link.py @@ -6,7 +6,11 @@ import dash_bootstrap_components as dbc import dash_mantine_components as dmc from dash import html -from pydantic import Field, PrivateAttr, validator + +try: + from pydantic.v1 import Field, PrivateAttr, validator +except ImportError: # pragma: no cov + from pydantic import Field, PrivateAttr, validator from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call @@ -40,7 +44,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/src/vizro/models/_navigation/navigation.py b/vizro-core/src/vizro/models/_navigation/navigation.py index a243862f4..f71b75096 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: # pragma: no cov + 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..9391fa49c 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: # pragma: no cov + 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 eb6e887af..1423e8049 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: # pragma: no cov + 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 6e089f09d..7b67a8736 100644 --- a/vizro-core/tests/unit/vizro/models/_action/test_action.py +++ b/vizro-core/tests/unit/vizro/models/_action/test_action.py @@ -8,7 +8,12 @@ import plotly import pytest from dash import html -from pydantic import ValidationError + +try: + from pydantic.v1 import ValidationError +except ImportError: # pragma: no cov + 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..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 @@ -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: # pragma: no cov + 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..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 @@ -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: # pragma: no cov + 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..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 @@ -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: # pragma: no cov + 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..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 @@ -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: # 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 ad8e466ff..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 @@ -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: # 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 8c0d049b9..1d9b4821a 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: # 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 6f3e190f9..b41468b98 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: # pragma: no cov + 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..4ae7c2ce2 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: # pragma: no cov + 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..41eb562b3 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: # pragma: no cov + 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 43ad086a4..93fd01544 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 @@ -6,7 +6,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: # pragma: no cov + from pydantic import ValidationError import vizro.models as vm diff --git a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_link.py b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_link.py index 87abc3406..c02d55247 100644 --- a/vizro-core/tests/unit/vizro/models/_navigation/test_nav_link.py +++ b/vizro-core/tests/unit/vizro/models/_navigation/test_nav_link.py @@ -6,7 +6,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: # 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 73abd6fdc..895ae1061 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: # 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 84bafd561..ae5a09e43 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: # pragma: no cov + 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 347dee6e2..39f499528 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: # pragma: no cov + 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..9d78849f4 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: # pragma: no cov + 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..3a1e34456 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: # pragma: no cov + 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..8b0b7242b 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: # pragma: no cov + from pydantic import Field, ValidationError from vizro.charts._charts_utils import _DashboardReadyFigure from vizro.models import VizroBaseModel