Skip to content

Commit

Permalink
Update docs and remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschulz-COL committed Oct 25, 2023
1 parent ab5d738 commit ff3f9ff
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
8 changes: 8 additions & 0 deletions vizro-core/docs/pages/user_guides/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ All other [parameters of the Dash DataTable](https://dash.plotly.com/datatable/r
[![Table]][Table]

[Table]: ../../assets/user_guides/table/table.png

#### Styling/Modifying the Dash DataTable

Lorem ipsum

#### Custom Table

Lorem Ispum
2 changes: 0 additions & 2 deletions vizro-core/src/vizro/managers/_model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

rd = random.Random(0)

# Type used for model_manager IDs
ModelID = NewType("ModelID", str)

Model = TypeVar("Model", bound="VizroBaseModel")


Expand Down
2 changes: 0 additions & 2 deletions vizro-core/src/vizro/models/_components/_components_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

logger = logging.getLogger(__name__)


# Validator for reuse in other models to validate pages
def _process_callable_data_frame(captured_callable, values):
data_frame = captured_callable["data_frame"]

Expand Down
22 changes: 14 additions & 8 deletions vizro-core/src/vizro/models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ class CapturedCallable:
`functools.partial`.
Ready-to-use `CapturedCallable` instances are provided by Vizro. In this case refer to the user guide on
[Charts/Graph][graph] or [Actions][pre-defined-actions] to see available choices.
[Charts/Graph][graph], [Table][table] or [Actions][pre-defined-actions] to see available choices.
(Advanced) In case you would like to create your own `CapturedCallable`, please refer to the user guide on
[custom charts](../user_guides/custom_charts.md) or [custom actions][custom-actions].
[custom charts](../user_guides/custom_charts.md), [custom tables][custom-table] or
[custom actions][custom-actions].
"""

def __init__(self, function, /, *args, **kwargs):
Expand Down Expand Up @@ -152,12 +153,16 @@ class capture:
"""Captures a function call to create a [`CapturedCallable`][vizro.models.types.CapturedCallable].
This is used to add the functionality required to make graphs and actions work in a dashboard.
Typically it should be used as a function decorator. There are two possible modes: `"graph"` and `"action"`.
Typically it should be used as a function decorator. There are three possible modes: `"graph"`, `"table"` and
`"action"`.
Examples:
>>> @capture("graph")
>>> def plot_function():
>>> ...
>>> @capture("table")
>>> def plot_function():
>>> ...
>>> @capture("action")
>>> def action_function():
>>> ...
Expand All @@ -167,14 +172,15 @@ class capture:
"""

def __init__(self, mode: Literal["graph", "action", "table"]):
"""Instantiates the decorator to capture a function call. Valid modes are "graph" and "action"."""
"""Instantiates the decorator to capture a function call. Valid modes are "graph", "table" and "action"."""
self._mode = mode

def __call__(self, func, /):
"""Produces a CapturedCallable or _DashboardReadyFigure.
mode="action" gives a CapturedCallable, while mode="graph" gives a _DashboardReadyFigure that contains a
CapturedCallable. In both cases, the CapturedCallable is based on func and the provided *args and **kwargs.
mode="action" and mode="table" give a CapturedCallable, while mode="graph" gives a _DashboardReadyFigure that
contains a CapturedCallable. In both cases, the CapturedCallable is based on func and the provided
*args and **kwargs.
"""
if self._mode == "graph":
# The more difficult case, where we need to still have a valid plotly figure that renders in a notebook.
Expand Down Expand Up @@ -219,7 +225,6 @@ def wrapped(*args, **kwargs):

return wrapped
elif self._mode == "table":

@functools.wraps(func)
def wrapped(*args, **kwargs):
if "data_frame" not in inspect.signature(func).parameters:
Expand Down Expand Up @@ -294,7 +299,8 @@ class OptionsDictType(TypedDict):
),
]
"""Discriminated union. Type of component that makes up part of the layout on the page:
[`Button`][vizro.models.Button], [`Card`][vizro.models.Card] or [`Graph`][vizro.models.Graph]."""
[`Button`][vizro.models.Button], [`Card`][vizro.models.Card], [`Table`][vizro.models.Table] or
[`Graph`][vizro.models.Graph]."""

# Types used for pages values in the Navigation model.
NavigationPagesType = Annotated[
Expand Down

0 comments on commit ff3f9ff

Please sign in to comment.