Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/API-reference/action-callables.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

API reference for all built-in action functions.

::: vizro.actions
<!-- ::: vizro.actions
options:
# Don't show underscore methods, function or output. AbstractAction is done separately below.
filters: ["!^_","!function", "!outputs", "!AbstractAction"]
show_bases: false
show_bases: false -->

<!--
TODO-AV2 D 5: uncomment the below and remove `show_bases: false` from above when AbstractAction becomes public.
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/API-reference/figure-callables.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ API reference for all built-in [`CapturedCallable`][vizro.models.types.CapturedC
from vizro.figures.library import kpi_card, kpi_card_reference
```

::: vizro.figures
<!-- ::: vizro.figures
options:
show_source: true
show_source: true -->

<!-- vale on -->
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/API-reference/kedro-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

API reference for all Kedro integration functions. The how-to guide on [Kedro Data Catalog integration](../user-guides/kedro-data-catalog.md) contains more information.

::: vizro.integrations.kedro
<!-- ::: vizro.integrations.kedro
options:
show_source: true
show_source: true -->

<!-- vale on -->
4 changes: 3 additions & 1 deletion vizro-core/docs/pages/API-reference/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<!-- vale off -->
API reference for all [`pydantic`](https://docs.pydantic.dev/latest/) models used.

::: vizro.models._dashboard.ExampleModel


::: vizro.models
options:
filters: ["!^_","!build","!model_post_init"] # Don't show underscore methods, build method, and model_post_init

::: vizro.models.types
options:
filters: ["!^_"] # Don't show dunder methods as well as single underscore ones
Expand Down
1 change: 1 addition & 0 deletions vizro-core/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ dependencies = [
"mkdocstrings[python]",
"linkchecker",
"mkdocs-pycafe",
"griffe-pydantic",
"PyGithub",
"playwright"
]
Expand Down
10 changes: 10 additions & 0 deletions vizro-core/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ plugins:
merge_init_into_class: true
docstring_section_style: list
separate_signature: true
unwrap_annotated: true
show_symbol_type_heading: true
show_symbol_type_toc: true
signature_crossrefs: true
show_signature_annotations: true
# filters: ["!^_"]
show_root_heading: true
docstring_options:
Expand All @@ -152,7 +157,12 @@ plugins:
- docs/griffe_extensions.py:
paths:
[vizro.figures.kpi_card, vizro.figures.kpi_card_reference]
- griffe_pydantic:
schema: false
paths: [src]
inventories:
- https://docs.python.org/3/objects.inv
- https://docs.pydantic.dev/latest/objects.inv
- git-revision-date-localized:
enable_creation_date: false

Expand Down
52 changes: 26 additions & 26 deletions vizro-core/schemas/0.1.44.dev0.json

Large diffs are not rendered by default.

16 changes: 3 additions & 13 deletions vizro-core/src/vizro/models/_action/_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from dash import Input, Output, State, callback, html
from dash.development.base_component import Component
from pydantic import Field, TypeAdapter, field_validator
from pydantic import Field, TypeAdapter
from pydantic.json_schema import SkipJsonSchema
from typing_extensions import TypedDict

Expand All @@ -21,7 +21,6 @@
ControlType,
_IdOrIdProperty,
_IdProperty,
validate_captured_callable,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -333,16 +332,7 @@ def callback_wrapper(external: Union[list[Any], dict[str, Any]], internal: dict[


class Action(_BaseAction):
"""Action to be inserted into `actions` of relevant component.

Args:
function (CapturedCallable): Action function.
inputs (list[str]): List of inputs provided to the action function. Each input can be specified as `<model_id>`
or `<model_id>.<argument_name>` or `<component_id>.<property>`. Defaults to `[]`.
outputs (Union[list[str], dict[str, str]]): List or dictionary of outputs modified by the action function. Each
output can be specified as `<model_id>` or `<model_id>.<argument_name>` or `<component_id>.<property>`.
Defaults to `[]`.
"""
"""Action to be inserted into `actions` of relevant component."""

# TODO-AV2 D 5: when it's made public, add something like below to docstring:
# This class is only relevant for user-defined actions using @capture("action"). Actions that are defined by
Expand Down Expand Up @@ -405,7 +395,7 @@ def _legacy(self) -> bool:
logger.debug("Action with id %s, function %s, has legacy=%s", self.id, self._action_name, legacy)
return legacy

_validate_function = field_validator("function", mode="before")(validate_captured_callable)
# _validate_function = field_validator("function", mode="before")(validate_captured_callable)

@property
def _parameters(self) -> set[str]:
Expand Down
8 changes: 1 addition & 7 deletions vizro-core/src/vizro/models/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,7 @@ def set_id(id: ModelID) -> ModelID:


class VizroBaseModel(BaseModel):
"""All models that are registered to the model manager should inherit from this class.

Args:
id (ModelID): ID to identify model. Must be unique throughout the whole dashboard. Defaults to `""`.
When no ID is chosen, ID will be automatically generated.

"""
"""All models that are registered to the model manager should inherit from this class."""

id: Annotated[
ModelID,
Expand Down
22 changes: 3 additions & 19 deletions vizro-core/src/vizro/models/_components/ag_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dash_ag_grid as dag
import pandas as pd
from dash import ClientsideFunction, Input, Output, State, clientside_callback, dcc, html
from pydantic import AfterValidator, BeforeValidator, Field, PrivateAttr, field_validator
from pydantic import AfterValidator, BeforeValidator, Field, PrivateAttr
from pydantic.functional_serializers import PlainSerializer
from pydantic.json_schema import SkipJsonSchema

Expand All @@ -21,7 +21,6 @@
ActionType,
CapturedCallable,
_IdProperty,
validate_captured_callable,
)

logger = logging.getLogger(__name__)
Expand All @@ -33,22 +32,7 @@


class AgGrid(VizroBaseModel):
"""Wrapper for `dash-ag-grid.AgGrid` to visualize grids in dashboard.

Args:
type (Literal["ag_grid"]): Defaults to `"ag_grid"`.
figure (CapturedCallable): Function that returns a Dash AgGrid. See [`vizro.tables`][vizro.tables].
title (str): Title of the `AgGrid`. Defaults to `""`.
header (str): Markdown text positioned below the `AgGrid.title`. Follows the CommonMark specification.
Ideal for adding supplementary information such as subtitles, descriptions, or additional context.
Defaults to `""`.
footer (str): Markdown text positioned below the `AgGrid`. Follows the CommonMark specification.
Ideal for providing further details such as sources, disclaimers, or additional notes. Defaults to `""`.
description (Optional[Tooltip]): Optional markdown string that adds an icon next to the title.
Hovering over the icon shows a tooltip with the provided description. Defaults to `None`.
actions (list[ActionType]): See [`ActionType`][vizro.models.types.ActionType]. Defaults to `[]`.

"""
"""Wrapper for `dash-ag-grid.AgGrid` to visualize grids in dashboard."""

type: Literal["ag_grid"] = "ag_grid"
figure: Annotated[
Expand Down Expand Up @@ -90,7 +74,7 @@ class AgGrid(VizroBaseModel):
]

_inner_component_id: str = PrivateAttr()
_validate_figure = field_validator("figure", mode="before")(validate_captured_callable)
# _validate_figure = field_validator("figure", mode="before")(validate_captured_callable)

def model_post_init(self, context) -> None:
super().model_post_init(context)
Expand Down
19 changes: 1 addition & 18 deletions vizro-core/src/vizro/models/_components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,7 @@


class Button(VizroBaseModel):
"""Component provided to `Page` to trigger any defined `action` in `Page`.

Args:
type (Literal["button"]): Defaults to `"button"`.
text (str): Text to be displayed on button. Needs to have at least 1 character. Defaults to `"Click me!"`.
href (str): URL (relative or absolute) to navigate to. Defaults to `""`.
actions (list[ActionType]): See [`ActionType`][vizro.models.types.ActionType]. Defaults to `[]`.
variant (Literal["plain", "filled", "outlined"]): Predefined styles to choose from. Options are `plain`,
`filled` or `outlined`. Defaults to `filled`.
description (Optional[Tooltip]): Optional markdown string that adds an icon next to the button text.
Hovering over the icon shows a tooltip with the provided description. Defaults to `None`.
extra (Optional[dict[str, Any]]): Extra keyword arguments that are passed to `dbc.Button` and overwrite any
defaults chosen by the Vizro team. This may have unexpected behavior.
Visit the [dbc documentation](https://dash-bootstrap-components.opensource.faculty.ai/docs/components/button/)
to see all available arguments. [Not part of the official Vizro schema](../explanation/schema.md) and the
underlying component may change in the future. Defaults to `{}`.

"""
"""Component provided to `Page` to trigger any defined `action` in `Page`."""

type: Literal["button"] = "button"
text: Annotated[str, Field(default="Click me!", description="Text to be displayed on button.", min_length=1)]
Expand Down
15 changes: 1 addition & 14 deletions vizro-core/src/vizro/models/_components/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,7 @@


class Card(VizroBaseModel):
"""Creates a card based on Markdown syntax.

Args:
type (Literal["card"]): Defaults to `"card"`.
text (str): Markdown string to create card title/text that should adhere to the CommonMark Spec.
href (str): URL (relative or absolute) to navigate to. If not provided the Card serves as a text card
only. Defaults to `""`.
extra (Optional[dict[str, Any]]): Extra keyword arguments that are passed to `dbc.Card` and overwrite any
defaults chosen by the Vizro team. This may have unexpected behavior.
Visit the [dbc documentation](https://dash-bootstrap-components.opensource.faculty.ai/docs/components/card/)
to see all available arguments. [Not part of the official Vizro schema](../explanation/schema.md) and the
underlying component may change in the future. Defaults to `{}`.

"""
"""Creates a card based on Markdown syntax."""

type: Literal["card"] = "card"
text: str = Field(
Expand Down
25 changes: 1 addition & 24 deletions vizro-core/src/vizro/models/_components/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,7 @@ def set_variant(variant: Optional[Literal["plain", "filled", "outlined"]], info:


class Container(VizroBaseModel):
"""Container to group together a set of components on a page.

Args:
type (Literal["container"]): Defaults to `"container"`.
components (list[ComponentType]): See [ComponentType][vizro.models.types.ComponentType]. At least one component
has to be provided.
title (str): Title of the `Container`. Defaults to `""`.
layout (Optional[LayoutType]): Layout to place components in. Defaults to `None`.
collapsed (Optional[bool]): Boolean flag that determines whether the container is collapsed on initial load.
Set to `True` for a collapsed state, `False` for an expanded state. Defaults to `None`, meaning the
container is not collapsible.
variant (Optional[Literal["plain", "filled", "outlined"]]): Predefined styles to choose from. Options are
`plain`, `filled` or `outlined`. Defaults to `plain` (or `outlined` for collapsible container).
description (Optional[Tooltip]): Optional markdown string that adds an icon next to the title.
Hovering over the icon shows a tooltip with the provided description. Defaults to `None`.
controls (list[ControlType]): See [ControlType][vizro.models.types.ControlType]. Defaults to `[]`.
extra (Optional[dict[str, Any]]): Extra keyword arguments that are passed to `dbc.Container` and overwrite any
defaults chosen by the Vizro team. This may have unexpected behavior.
Visit the [dbc documentation](https://dash-bootstrap-components.opensource.faculty.ai/docs/components/layout/)
to see all available arguments. [Not part of the official Vizro schema](../explanation/schema.md) and the
underlying component may change in the future. Defaults to `{}`.


"""
"""Container to group together a set of components on a page."""

type: Literal["container"] = "container"
# TODO[mypy], see: https://github.com/pydantic/pydantic/issues/156 for components field
Expand Down
14 changes: 4 additions & 10 deletions vizro-core/src/vizro/models/_components/figure.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
from typing import Annotated, Literal

from dash import dcc, html
from pydantic import AfterValidator, Field, field_validator
from pydantic import AfterValidator, Field
from pydantic.json_schema import SkipJsonSchema

from vizro.managers import data_manager
from vizro.models import VizroBaseModel
from vizro.models._components._components_utils import _process_callable_data_frame
from vizro.models._models_utils import _log_call
from vizro.models.types import CapturedCallable, _IdProperty, validate_captured_callable
from vizro.models.types import CapturedCallable, _IdProperty


class Figure(VizroBaseModel):
"""Creates a figure-like object that can be displayed in the dashboard and is reactive to controls.

Args:
type (Literal["figure"]): Defaults to `"figure"`.
figure (CapturedCallable): Function that returns a figure-like object. See [`vizro.figures`][vizro.figures].

"""
"""Creates a figure-like object that can be displayed in the dashboard and is reactive to controls."""

type: Literal["figure"] = "figure"
figure: Annotated[
Expand All @@ -31,7 +25,7 @@ class Figure(VizroBaseModel):
]

# Component properties for actions and interactions
_validate_figure = field_validator("figure", mode="before")(validate_captured_callable)
# _validate_figure = field_validator("figure", mode="before")(validate_captured_callable)

@property
def _action_outputs(self) -> dict[str, _IdProperty]:
Expand Down
21 changes: 2 additions & 19 deletions vizro-core/src/vizro/models/_components/form/checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

import dash_bootstrap_components as dbc
from dash import ClientsideFunction, Input, Output, State, clientside_callback, html
from pydantic import AfterValidator, BeforeValidator, Field, PrivateAttr, model_validator
from pydantic import AfterValidator, BeforeValidator, Field, PrivateAttr
from pydantic.functional_serializers import PlainSerializer
from pydantic.json_schema import SkipJsonSchema

from vizro.models import Tooltip, VizroBaseModel
from vizro.models._action._actions_chain import _action_validator_factory
from vizro.models._components.form._form_utils import (
get_dict_options_and_default,
validate_options_dict,
validate_value,
)
from vizro.models._models_utils import _log_call, warn_description_without_title
Expand All @@ -23,22 +22,6 @@ class Checklist(VizroBaseModel):

Can be provided to [`Filter`][vizro.models.Filter] or
[`Parameter`][vizro.models.Parameter].

Args:
type (Literal["checklist"]): Defaults to `"checklist"`.
options (OptionsType): See [`OptionsType`][vizro.models.types.OptionsType]. Defaults to `[]`.
value (Optional[MultiValueType]): See [`MultiValueType`][vizro.models.types.MultiValueType]. Defaults to `None`.
title (str): Title to be displayed. Defaults to `""`.
show_select_all (Optional[bool]): Whether to display the 'Select All' option that allows users to select or
deselect all available options with a single click. Defaults to `True`.
description (Optional[Tooltip]): Optional markdown string that adds an icon next to the title.
Hovering over the icon shows a tooltip with the provided description. Defaults to `None`.
actions (list[ActionType]): See [`ActionType`][vizro.models.types.ActionType]. Defaults to `[]`.
extra (Optional[dict[str, Any]]): Extra keyword arguments that are passed to `dbc.Checklist` and overwrite any
defaults chosen by the Vizro team. This may have unexpected behavior.
Visit the [dbc documentation](https://dash-bootstrap-components.opensource.faculty.ai/docs/components/input/)
to see all available arguments. [Not part of the official Vizro schema](../explanation/schema.md) and the
underlying component may change in the future. Defaults to `{}`.
"""

type: Literal["checklist"] = "checklist"
Expand Down Expand Up @@ -88,7 +71,7 @@ class Checklist(VizroBaseModel):
_in_container: bool = PrivateAttr(False)

# Reused validators
_validate_options = model_validator(mode="before")(validate_options_dict)
# _validate_options = model_validator(mode="before")(validate_options_dict)

@property
def _action_outputs(self) -> dict[str, _IdProperty]:
Expand Down
16 changes: 0 additions & 16 deletions vizro-core/src/vizro/models/_components/form/date_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ class DatePicker(VizroBaseModel):
"""Temporal single/range option selector `DatePicker`.

Can be provided to [`Filter`][vizro.models.Filter] or [`Parameter`][vizro.models.Parameter].

Args:
type (Literal["date_picker"]): Defaults to `"date_picker"`.
min (Optional[date]): Start date for date picker. Defaults to `None`.
max (Optional[date]): End date for date picker. Defaults to `None`.
value (Optional[Union[list[date], date]]): Default date/dates for date picker. Defaults to `None`.
title (str): Title to be displayed. Defaults to `""`.
range (bool): Boolean flag for displaying range picker. Defaults to `True`.
description (Optional[Tooltip]): Optional markdown string that adds an icon next to the title.
Hovering over the icon shows a tooltip with the provided description. Defaults to `None`.
actions (list[ActionType]): See [`ActionType`][vizro.models.types.ActionType]. Defaults to `[]`.
extra (Optional[dict[str, Any]]): Extra keyword arguments that are passed to `dmc.DatePickerInput` and overwrite
any defaults chosen by the Vizro team. This may have unexpected behavior.
Visit the [dmc documentation](https://www.dash-mantine-components.com/components/datepicker)
to see all available arguments. [Not part of the official Vizro schema](../explanation/schema.md) and the
underlying component may change in the future. Defaults to `{}`.
"""

type: Literal["date_picker"] = "date_picker"
Expand Down
Loading
Loading