Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 10, 2024
1 parent e002014 commit 2848bba
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 18 deletions.
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/user-guides/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ graph TD
refresh -- Yes --> dynamic
specification -- No --> static-direct
specification -- Yes --> static-name
click static-direct href "../static-data#supply-directly"
click static-name href "../static-data#reference-by-name"
click dynamic href "../dynamic-data"
classDef clickable color:#4051b5;
```

Expand Down
4 changes: 2 additions & 2 deletions vizro-core/docs/pages/user-guides/dynamic-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Since dynamic data sources must always be added to the Data Manager and referenc

By default, every time the dashboard is refreshed a dynamic data function will be executed again. This means that your dashboard will always show the very latest data. In fact, if there are multiple graphs on the same page using the same dynamic data source then the loading function will be executed _multiple_ times, once for each graph on the page. Hence, if loading your data is a slow operation, your dashboard performance may suffer.

The Vizro Data Manager has a server-side caching mechanism to help solve this. Vizro's cache uses [Flask-Caching](https://flask-caching.readthedocs.io/en/latest/), which supports a number of possible cache backends and [configuration options](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching). By default, the cache is turned off.
The Vizro Data Manager has a server-side caching mechanism to help solve this. Vizro's cache uses [Flask-Caching](https://flask-caching.readthedocs.io/en/latest/), which supports a number of possible cache backends and [configuration options](https://flask-caching.readthedocs.io/en/latest/#configuring-flask-caching). By default, the cache is turned off.

In a development environment the easiest way to enable caching is to use a [simple memory cache](https://cachelib.readthedocs.io/en/stable/simple/) with the default configuration options. This is achieved by adding one line to the above example to set `data_manager.cache`:

Expand All @@ -68,7 +68,7 @@ In a development environment the easiest way to enable caching is to use a [simp
def load_iris_data():
iris = pd.read_csv("iris.csv")
return iris.sample(30)

data_manager.cache = Cache(config={"CACHE_TYPE": "SimpleCache"})
data_manager["iris"] = load_iris_data

Expand Down
4 changes: 0 additions & 4 deletions vizro-core/examples/_dev/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
"""Example to show dashboard configuration."""

from typing import Optional

import pandas as pd
import vizro.models as vm
import vizro.plotly.express as px
from flask_caching import Cache
Expand Down Expand Up @@ -34,7 +31,6 @@
vm.Graph(figure=px.scatter("no_expire_data", "sepal_width", "sepal_length")),
],
controls=[vm.Filter(column="species")],

)
dashboard = vm.Dashboard(pages=[page])
app = Vizro().build(dashboard)
Expand Down
1 change: 0 additions & 1 deletion vizro-core/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ markdown_extensions:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg


plugins:
- search
- autorefs
Expand Down
3 changes: 2 additions & 1 deletion vizro-core/src/vizro/_vizro.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def _reset():
"""Private method that clears all state in the `Vizro` app.
This deliberately does not clear the data manager cache - see comments in data_manager._clear for
explanation."""
explanation.
"""
data_manager._clear()
model_manager._clear()
dash._callback.GLOBAL_CALLBACK_LIST = []
Expand Down
5 changes: 1 addition & 4 deletions vizro-core/src/vizro/managers/_data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

from __future__ import annotations

import warnings

from contextlib import suppress

import logging
import os
import warnings
from typing import Callable, Dict, Optional, Union

import pandas as pd
Expand Down
7 changes: 3 additions & 4 deletions vizro-core/tests/unit/vizro/managers/test_data_manager.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
"""Unit tests for vizro.managers.data_manager."""
from contextlib import suppress

import time
from contextlib import suppress

import numpy as np
import pandas as pd
import pytest
from flask_caching import Cache

from asserts import assert_frame_not_equal
from flask_caching import Cache
from pandas.testing import assert_frame_equal
from vizro import Vizro
from vizro.managers import data_manager
from pandas.testing import assert_frame_equal


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 2848bba

Please sign in to comment.