Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mckinsey/vizro into score_t…
Browse files Browse the repository at this point in the history
…ests_improvements
  • Loading branch information
l0uden committed Feb 4, 2025
2 parents cc943df + 72b90e1 commit b640aa8
Show file tree
Hide file tree
Showing 28 changed files with 271 additions and 60 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
pass_filenames: false

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
Expand All @@ -45,15 +45,15 @@ repos:
args: [--autofix]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.4
hooks:
- id: ruff
args: [--fix]
exclude: "vizro-core/examples/scratch_dev/app.py"
- id: ruff-format

- repo: https://github.com/PyCQA/bandit
rev: 1.8.0
rev: 1.8.2
hooks:
- id: bandit
args: [-c, pyproject.toml, -ll]
Expand Down Expand Up @@ -83,7 +83,7 @@ repos:
exclude: ^vizro-core/src/vizro/static/css/.+\.min.*|^vizro-core/src/vizro/static/css/mantine_dates.css

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.21
rev: 0.7.22
hooks:
- id: mdformat
args:
Expand Down
6 changes: 3 additions & 3 deletions tools/check_for_datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def check_for_data_files():
whitelisted_files = {files for dir in whitelist_dir for files in found_files if files.startswith(dir)}
to_be_removed_files = found_files - whitelisted_files

assert (
len(to_be_removed_files) == 0
), f"Caution! Please remove your data files {to_be_removed_files} before merging!"
assert len(to_be_removed_files) == 0, (
f"Caution! Please remove your data files {to_be_removed_files} before merging!"
)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
6 changes: 3 additions & 3 deletions vizro-ai/src/vizro_ai/plot/_response_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ def _test_execute_chart_code(v, values):
f"Produced code execution failed the following error: <{e}>. Please check the code and try again, "
f"alternatively try with a more powerful model."
)
assert isinstance(
fig, go.Figure
), f"Expected chart code to return a plotly go.Figure object, but got {type(fig)}"
assert isinstance(fig, go.Figure), (
f"Expected chart code to return a plotly go.Figure object, but got {type(fig)}"
)
return v

return create_model(
Expand Down
2 changes: 1 addition & 1 deletion vizro-ai/src/vizro_ai/plot/_utils/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
".loadtxt",
".genfromtxt",
".load",
".fromfile" ".save",
".fromfile.save",
".savetxt",
".tofile",
".loadmat",
Expand Down
6 changes: 3 additions & 3 deletions vizro-ai/tests/e2e/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def logic( # noqa: PLR0912, PLR0913, PLR0915
pages_exist = [1 if dashboard.pages else 0][0]
pages_exist_report = bool(pages_exist)
pages_num = [1 if len(dashboard.pages) == len(config["pages"]) else 0]
pages_num_report = [f'{len(config["pages"])} page(s) for dashboard is {bool(pages_num[0])}']
pages_num_report = [f"{len(config['pages'])} page(s) for dashboard is {bool(pages_num[0])}"]

components_num = []
components_num_report = []
Expand All @@ -105,7 +105,7 @@ def logic( # noqa: PLR0912, PLR0913, PLR0915
components = 0
components_num.append(components)
components_num_report.append(
f'{len(config["pages"][page]["components"])} component(s) for page {page} is {bool(components)}'
f"{len(config['pages'][page]['components'])} component(s) for page {page} is {bool(components)}"
)

controls_num = []
Expand All @@ -117,7 +117,7 @@ def logic( # noqa: PLR0912, PLR0913, PLR0915
controls = 0
controls_num.append(controls)
controls_num_report.append(
f'{len(config["pages"][page]["controls"])} control(s) for page {page} is {bool(controls)}'
f"{len(config['pages'][page]['controls'])} control(s) for page {page} is {bool(controls)}"
)

components_types_names = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->

### Changed

- Increase lower bound for `plotly` to `plotly>=5.24.0`. ([#984](https://github.com/mckinsey/vizro/pull/984))


<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->

### Fixed

- Fix flickering scroll bars when using new Plotly map figures with `plotly==6.0.0`. ([#984](https://github.com/mckinsey/vizro/pull/984))


<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Fixed
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Highlights ✨
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Removed
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Added
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Changed
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
<!--
### Deprecated
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
### Fixed

- Remove flash of unstyled text before Google Material icons font is loaded. ([#987](https://github.com/mckinsey/vizro/pull/987))
<!--
### Security
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX. ([#1](https://github.com/mckinsey/vizro/pull/1))
-->
44 changes: 29 additions & 15 deletions vizro-core/examples/scratch_dev/app.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
"""Dev app to try things out."""

import pandas as pd
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
from vizro.actions import export_data
from vizro.figures import kpi_card_reference

df = px.data.iris()
df_kpi = pd.DataFrame({"Actual": [100, 200, 700], "Reference": [100, 300, 500], "Category": ["A", "B", "C"]})


# Create a layout with five rows and four columns. The KPI card is positioned in the first cell, while the remaining cells are empty.
page = vm.Page(
title="Page 1",
title="KPI card I",
components=[
vm.Figure(
figure=kpi_card_reference(
data_frame=df_kpi,
value_column="Actual",
reference_column="Reference",
title="KPI reference with icon",
icon="folder_check_2",
)
)
],
)

page_two = vm.Page(
title="KPI card II",
components=[
vm.Graph(figure=px.bar(df, x="sepal_width", y="sepal_length")),
vm.Button(
text="Export data",
actions=[
vm.Action(function=export_data()),
vm.Action(function=export_data()),
],
),
vm.Figure(
figure=kpi_card_reference(
data_frame=df_kpi,
value_column="Actual",
reference_column="Reference",
title="KPI reference with icon",
icon="folder_check",
)
)
],
)

dashboard = vm.Dashboard(pages=[page])
dashboard = vm.Dashboard(pages=[page, page_two], navigation=vm.Navigation(nav_selector=vm.NavBar()))

if __name__ == "__main__":
Vizro().build(dashboard).run()
2 changes: 1 addition & 1 deletion vizro-core/examples/visual-vocabulary/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
autoflake==2.3.1
black==24.4.2
isort==5.13.2
plotly==5.24.1
plotly==6.0.0
vizro==0.1.28
gunicorn
Loading

0 comments on commit b640aa8

Please sign in to comment.