Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assets to work when hosted at subdirectory #151

Merged
merged 11 commits into from
Nov 9, 2023
2 changes: 1 addition & 1 deletion .github/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pre-commit
coverage[toml]>=6.5
pytest
dash[testing]
chromedriver-autoinstaller
chromedriver-autoinstaller-fix
toml
pyyaml
openpyxl
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
antonymilne marked this conversation as resolved.
Show resolved Hide resolved

- 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))

-->
12 changes: 4 additions & 8 deletions vizro-core/docs/pages/user_guides/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ a result, when a dashboard user now clicks the button, all data on the page will

dashboard = vm.Dashboard(pages=[page])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
antonymilne marked this conversation as resolved.
Show resolved Hide resolved
```
=== "app.yaml"
```yaml
Expand Down Expand Up @@ -167,8 +166,7 @@ Here is an example of how to configure a chart interaction when the source is a
]
)

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.yaml"
```yaml
Expand Down Expand Up @@ -250,8 +248,7 @@ Here is an example of how to configure a chart interaction when the source is a
]
)

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.yaml"
```yaml
Expand Down Expand Up @@ -343,8 +340,7 @@ The order of action execution is guaranteed, and the next action in the list wil

dashboard = vm.Dashboard(pages=[page])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.yaml"
```yaml
Expand Down
6 changes: 2 additions & 4 deletions vizro-core/docs/pages/user_guides/custom_charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ Building on the above, there are several routes one can take. The following exam
)
dashboard = vm.Dashboard(pages=[page_0])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.yaml"
```yaml
Expand Down Expand Up @@ -142,8 +141,7 @@ The below examples shows a more involved use-case. We create and style a waterfa
)
dashboard = vm.Dashboard(pages=[page_0])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.yaml"
```yaml
Expand Down
6 changes: 2 additions & 4 deletions vizro-core/docs/pages/user_guides/custom_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ vm.Parameter.add_type("selector", TooltipNonCrossRangeSlider)

dashboard = vm.Dashboard(pages=[page])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```

1. Here we provide a new type for the new component, so it can be distinguished in the discriminated union.
Expand Down Expand Up @@ -330,8 +329,7 @@ vm.Page.add_type("components", Jumbotron)

dashboard = vm.Dashboard(pages=[page])

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()

```

Expand Down
6 changes: 2 additions & 4 deletions vizro-core/docs/pages/user_guides/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ To create a dashboard, do the following steps:
dashboard = yaml.safe_load(Path("dashboard.yaml").read_text(encoding="utf-8"))
dashboard = Dashboard(**dashboard)

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```
=== "app.py for json"
```py
Expand All @@ -185,8 +184,7 @@ To create a dashboard, do the following steps:
dashboard = json.loads(Path("dashboard.json").read_text(encoding="utf-8"))
dashboard = Dashboard(**dashboard)

if __name__ == "__main__":
Vizro().build(dashboard).run()
Vizro().build(dashboard).run()
```

After running the dashboard, you can access the dashboard via `localhost:8050`.
Expand Down
4 changes: 1 addition & 3 deletions vizro-core/examples/default/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Example to show dashboard configuration."""
import os

import pandas as pd

Expand Down Expand Up @@ -532,5 +531,4 @@ def create_home_page():
)

if __name__ == "__main__":
Vizro._user_assets_folder = os.path.abspath("../assets")
Vizro().build(dashboard).run()
Vizro(assets_folder="../assets").build(dashboard).run()
5 changes: 2 additions & 3 deletions vizro-core/examples/from_dict/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Example to show dashboard configuration specified as a dictionary."""
import os

import pandas as pd

Expand Down Expand Up @@ -580,8 +579,8 @@ def retrieve_avg_gapminder_year(year: int):
}
},
}

dashboard = Dashboard(**dashboard)

if __name__ == "__main__":
Vizro._user_assets_folder = os.path.abspath("../assets")
Vizro().build(dashboard).run()
Vizro(assets_folder="../assets").build(dashboard).run()
4 changes: 1 addition & 3 deletions vizro-core/examples/from_json/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Example to show dashboard configuration specified as a JSON file."""
import json
import os
from pathlib import Path

import pandas as pd
Expand Down Expand Up @@ -63,5 +62,4 @@ def retrieve_avg_gapminder_year(year: int):
dashboard = Dashboard(**dashboard)

if __name__ == "__main__":
Vizro._user_assets_folder = os.path.abspath("../assets")
Vizro().build(dashboard).run()
Vizro(assets_folder="../assets").build(dashboard).run()
4 changes: 1 addition & 3 deletions vizro-core/examples/from_yaml/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Example to show dashboard configuration specified as a YAML file."""
import os
from pathlib import Path

import pandas as pd
Expand Down Expand Up @@ -63,5 +62,4 @@ def retrieve_avg_gapminder_year(year: int):
dashboard = Dashboard(**dashboard)

if __name__ == "__main__":
Vizro._user_assets_folder = os.path.abspath("../assets")
Vizro().build(dashboard).run()
Vizro(assets_folder="../assets").build(dashboard).run()
2 changes: 1 addition & 1 deletion vizro-core/hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"pytest",
"pytest-mock",
"dash[testing]",
"chromedriver-autoinstaller",
"chromedriver-autoinstaller-fix",
"toml",
"pyyaml",
"openpyxl"
Expand Down
Loading
Loading