Files changed (6) hide show
  1. .gitignore +0 -144
  2. Dockerfile +14 -5
  3. app.py +6 -16
  4. assets/css/custom.css +2 -27
  5. requirements.in +1 -2
  6. requirements.txt +24 -32
.gitignore DELETED
@@ -1,144 +0,0 @@
1
- # npm node_modules
2
- node_modules/
3
-
4
- # Ipynb
5
- ipynb_checkpoints
6
- */.ipynb_checkpoints/*
7
-
8
- # IPython
9
- profile_default/
10
- ipython_config.py
11
-
12
- # Byte-compiled / optimized / DLL files
13
- __pycache__/
14
- *.py[cod]
15
- *$py.class
16
-
17
- # C extensions
18
- *.so
19
-
20
- # Distribution / packaging
21
- .Python
22
- build/
23
- develop-eggs/
24
- dist/
25
- downloads/
26
- eggs/
27
- .eggs/
28
- lib/
29
- lib64/
30
- parts/
31
- sdist/
32
- var/
33
- wheels/
34
- share/python-wheels/
35
- *.egg-info/
36
- .installed.cfg
37
- *.egg
38
- MANIFEST
39
-
40
- # macOS
41
- *.DS_Store
42
- .DS_Store
43
- .AppleDouble
44
- .LSOverride
45
- .Trashes
46
-
47
- # PyInstaller
48
- *.manifest
49
- *.spec
50
-
51
- # Installer logs
52
- pip-log.txt
53
- pip-delete-this-directory.txt
54
-
55
- # Unit test / coverage reports
56
- htmlcov/
57
- .tox/
58
- .nox/
59
- .coverage
60
- .coverage.*
61
- .cache
62
- nosetests.xml
63
- coverage.xml
64
- *.cover
65
- *.py,cover
66
- .hypothesis/
67
- .pytest_cache/
68
- cover/
69
-
70
- # Translations
71
- *.mo
72
- *.pot
73
-
74
- # Django
75
- *.log
76
- local_settings.py
77
- db.sqlite3
78
- db.sqlite3-journal
79
-
80
- # Flask
81
- instance/
82
- .webassets-cache
83
-
84
- # Scrapy
85
- .scrapy
86
-
87
- # PyBuilder
88
- .pybuilder/
89
- target/
90
-
91
- # IntelliJ
92
- .idea/
93
- *.iml
94
- out/
95
- .idea_modules/
96
-
97
- # Vscode
98
- .vscode/
99
-
100
- # PEP 582
101
- __pypackages__/
102
-
103
- # Celery
104
- celerybeat-schedule
105
- celerybeat.pid
106
-
107
- # SageMath
108
- *.sage.py
109
-
110
- # Environments
111
- .env
112
- .venv
113
- env/
114
- venv/
115
- ENV/
116
- env.bak/
117
- venv.bak/
118
-
119
- # Spyder
120
- .spyderproject
121
- .spyproject
122
-
123
- # Rope
124
- .ropeproject
125
-
126
- # Mkdocs
127
- /site
128
-
129
- # Mypy
130
- .mypy_cache/
131
- .dmypy.json
132
- dmypy.json
133
-
134
- # Pyre
135
- .pyre/
136
-
137
- # Pytype
138
- .pytype/
139
-
140
- # Cython
141
- cython_debug/
142
-
143
- # Ruff
144
- .ruff_cache/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Dockerfile CHANGED
@@ -1,9 +1,18 @@
1
- FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
- COPY requirements.txt .
6
- RUN uv pip sync --system requirements.txt
7
- COPY . .
 
 
 
 
8
 
9
- ENTRYPOINT ["gunicorn", "app:app", "--workers", "4", "--bind", "0.0.0.0:7860"]
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.12
5
+
6
+ RUN useradd -m -u 1000 user
7
 
8
  WORKDIR /app
9
 
10
+ COPY --chown=user ./requirements.txt requirements.txt
11
+
12
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
13
+
14
+ COPY --chown=user . /app
15
+
16
+ EXPOSE 7860
17
 
18
+ CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:server"]
app.py CHANGED
@@ -3,8 +3,6 @@
3
  from typing import Optional
4
 
5
  import pandas as pd
6
- from dash import html, get_asset_url
7
- import dash_bootstrap_components as dbc
8
  import vizro.models as vm
9
  import vizro.plotly.express as px
10
  from vizro import Vizro
@@ -158,7 +156,7 @@ def create_variable_analysis():
158
  page_variable = vm.Page(
159
  title="Variable Analysis",
160
  description="Analyzing population, GDP per capita and life expectancy on country and continent level",
161
- layout=vm.Grid(
162
  grid=[
163
  # fmt: off
164
  [0, 1, 1, 1],
@@ -275,7 +273,7 @@ def create_relation_analysis():
275
  page_relation_analysis = vm.Page(
276
  title="Relationship Analysis",
277
  description="Investigating the interconnection between population, GDP per capita and life expectancy",
278
- layout=vm.Grid(
279
  grid=[[0, 0, 0, 0, 0]] + [[1, 1, 1, 1, 1]] * 4,
280
  row_min_height="100px",
281
  row_gap="24px",
@@ -318,7 +316,7 @@ def create_continent_summary():
318
  page_summary = vm.Page(
319
  title="Continent Summary",
320
  description="Summarizing the main findings for each continent",
321
- layout=vm.Grid(grid=[[i] for i in range(5)], row_min_height="190px", row_gap="25px"),
322
  components=[
323
  vm.Card(
324
  text="""
@@ -431,7 +429,7 @@ def create_benchmark_analysis():
431
  page_country = vm.Page(
432
  title="Benchmark Analysis",
433
  description="Discovering how the metrics differ for each country and export data for further investigation",
434
- layout=vm.Grid(grid=[[0, 1]] * 5 + [[2, -1]]),
435
  components=[
436
  vm.AgGrid(
437
  title="Click on a cell in country column:",
@@ -473,7 +471,7 @@ def create_home_page():
473
  page_home = vm.Page(
474
  title="Homepage",
475
  description="Vizro demo app for studying gapminder data",
476
- layout=vm.Grid(grid=[[0, 1], [2, 3]]),
477
  components=[
478
  vm.Card(
479
  text="""
@@ -546,15 +544,7 @@ dashboard = vm.Dashboard(
546
  )
547
 
548
  app = Vizro().build(dashboard)
549
- app.dash.layout.children.append(
550
- dbc.NavLink(
551
- ["Made with ", html.Img(src=get_asset_url("images/logo.svg"), id="banner", alt="Vizro logo"), "vizro"],
552
- href="https://github.com/mckinsey/vizro",
553
- target="_blank",
554
- external_link=True,
555
- className="anchor-container",
556
- )
557
- )
558
 
559
  if __name__ == "__main__":
560
  app.run()
 
3
  from typing import Optional
4
 
5
  import pandas as pd
 
 
6
  import vizro.models as vm
7
  import vizro.plotly.express as px
8
  from vizro import Vizro
 
156
  page_variable = vm.Page(
157
  title="Variable Analysis",
158
  description="Analyzing population, GDP per capita and life expectancy on country and continent level",
159
+ layout=vm.Layout(
160
  grid=[
161
  # fmt: off
162
  [0, 1, 1, 1],
 
273
  page_relation_analysis = vm.Page(
274
  title="Relationship Analysis",
275
  description="Investigating the interconnection between population, GDP per capita and life expectancy",
276
+ layout=vm.Layout(
277
  grid=[[0, 0, 0, 0, 0]] + [[1, 1, 1, 1, 1]] * 4,
278
  row_min_height="100px",
279
  row_gap="24px",
 
316
  page_summary = vm.Page(
317
  title="Continent Summary",
318
  description="Summarizing the main findings for each continent",
319
+ layout=vm.Layout(grid=[[i] for i in range(5)], row_min_height="190px", row_gap="25px"),
320
  components=[
321
  vm.Card(
322
  text="""
 
429
  page_country = vm.Page(
430
  title="Benchmark Analysis",
431
  description="Discovering how the metrics differ for each country and export data for further investigation",
432
+ layout=vm.Layout(grid=[[0, 1]] * 5 + [[2, -1]]),
433
  components=[
434
  vm.AgGrid(
435
  title="Click on a cell in country column:",
 
471
  page_home = vm.Page(
472
  title="Homepage",
473
  description="Vizro demo app for studying gapminder data",
474
+ layout=vm.Layout(grid=[[0, 1], [2, 3]]),
475
  components=[
476
  vm.Card(
477
  text="""
 
544
  )
545
 
546
  app = Vizro().build(dashboard)
547
+ server = app.dash.server
 
 
 
 
 
 
 
 
548
 
549
  if __name__ == "__main__":
550
  app.run()
assets/css/custom.css CHANGED
@@ -5,31 +5,6 @@ img[src*="#my-image"] {
5
  width: 100px;
6
  }
7
 
8
- #header {
9
- padding-left: 0;
10
- }
11
-
12
- .anchor-container {
13
- align-items: center;
14
- background: var(--text-primary);
15
- border-top-left-radius: 8px;
16
- bottom: 0;
17
- color: var(--text-primary-inverted) !important;
18
- display: flex;
19
- font-size: 0.8rem;
20
- font-weight: 500;
21
- height: 24px;
22
- padding: 0 12px;
23
- position: fixed;
24
- right: 0;
25
- }
26
-
27
- .anchor-container:focus,
28
- .anchor-container:hover {
29
- background: var(--text-secondary);
30
- color: var(--text-primary-inverted);
31
- }
32
-
33
- img#banner {
34
- height: 16px;
35
  }
 
5
  width: 100px;
6
  }
7
 
8
+ #page-header {
9
+ padding-left: 8px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  }
requirements.in CHANGED
@@ -1,3 +1,2 @@
1
  gunicorn
2
- vizro==0.1.44
3
- numpy!=2.0.2 # there is an issue with this specific version that the whl can't be built
 
1
  gunicorn
2
+ vizro
 
requirements.txt CHANGED
@@ -2,10 +2,6 @@
2
  # uv pip compile requirements.in -o requirements.txt
3
  annotated-types==0.7.0
4
  # via pydantic
5
- autoflake==2.3.1
6
- # via vizro
7
- black==24.10.0
8
- # via vizro
9
  blinker==1.8.2
10
  # via flask
11
  cachelib==0.9.0
@@ -15,21 +11,24 @@ certifi==2024.7.4
15
  charset-normalizer==3.3.2
16
  # via requests
17
  click==8.1.7
18
- # via
19
- # black
20
- # flask
21
- dash==3.1.1
22
  # via
23
  # dash-ag-grid
24
  # dash-bootstrap-components
25
- # dash-mantine-components
26
  # vizro
27
- dash-ag-grid==32.3.0
28
  # via vizro
29
- dash-bootstrap-components==2.0.3
30
  # via vizro
31
- dash-mantine-components==2.1.0
 
 
 
 
32
  # via vizro
 
 
33
  flask==3.0.3
34
  # via
35
  # dash
@@ -50,38 +49,24 @@ markupsafe==2.1.5
50
  # via
51
  # jinja2
52
  # werkzeug
53
- mypy-extensions==1.0.0
54
- # via black
55
- narwhals==2.0.1
56
- # via plotly
57
  nest-asyncio==1.6.0
58
  # via dash
59
- numpy==2.3.2
60
  # via
61
- # -r requirements.in
62
  # pandas
 
63
  packaging==24.1
64
  # via
65
- # black
66
  # gunicorn
67
  # plotly
68
- # vizro
69
  pandas==2.2.2
70
  # via vizro
71
- pathspec==0.12.1
72
- # via black
73
- platformdirs==4.3.6
74
- # via black
75
- plotly==6.2.0
76
- # via
77
- # dash
78
- # vizro
79
  pydantic==2.8.2
80
  # via vizro
81
  pydantic-core==2.20.1
82
  # via pydantic
83
- pyflakes==3.2.0
84
- # via autoflake
85
  python-dateutil==2.9.0.post0
86
  # via pandas
87
  pytz==2024.1
@@ -90,12 +75,18 @@ requests==2.32.3
90
  # via dash
91
  retrying==1.3.4
92
  # via dash
 
 
93
  setuptools==73.0.1
94
- # via dash
 
 
95
  six==1.16.0
96
  # via
97
  # python-dateutil
98
  # retrying
 
 
99
  typing-extensions==4.12.2
100
  # via
101
  # dash
@@ -105,12 +96,13 @@ tzdata==2024.1
105
  # via pandas
106
  urllib3==2.2.2
107
  # via requests
108
- vizro==0.1.44
109
  # via -r requirements.in
110
  werkzeug==3.0.4
111
  # via
112
  # dash
113
  # flask
 
114
  wrapt==1.16.0
115
  # via vizro
116
  zipp==3.20.0
 
2
  # uv pip compile requirements.in -o requirements.txt
3
  annotated-types==0.7.0
4
  # via pydantic
 
 
 
 
5
  blinker==1.8.2
6
  # via flask
7
  cachelib==0.9.0
 
11
  charset-normalizer==3.3.2
12
  # via requests
13
  click==8.1.7
14
+ # via flask
15
+ dash==2.17.1
 
 
16
  # via
17
  # dash-ag-grid
18
  # dash-bootstrap-components
 
19
  # vizro
20
+ dash-ag-grid==31.2.0
21
  # via vizro
22
+ dash-bootstrap-components==1.6.0
23
  # via vizro
24
+ dash-core-components==2.0.0
25
+ # via dash
26
+ dash-html-components==2.0.0
27
+ # via dash
28
+ dash-mantine-components==0.12.1
29
  # via vizro
30
+ dash-table==5.0.0
31
+ # via dash
32
  flask==3.0.3
33
  # via
34
  # dash
 
49
  # via
50
  # jinja2
51
  # werkzeug
 
 
 
 
52
  nest-asyncio==1.6.0
53
  # via dash
54
+ numpy==2.1.0
55
  # via
 
56
  # pandas
57
+ # vizro
58
  packaging==24.1
59
  # via
 
60
  # gunicorn
61
  # plotly
 
62
  pandas==2.2.2
63
  # via vizro
64
+ plotly==5.23.0
65
+ # via dash
 
 
 
 
 
 
66
  pydantic==2.8.2
67
  # via vizro
68
  pydantic-core==2.20.1
69
  # via pydantic
 
 
70
  python-dateutil==2.9.0.post0
71
  # via pandas
72
  pytz==2024.1
 
75
  # via dash
76
  retrying==1.3.4
77
  # via dash
78
+ ruff==0.6.1
79
+ # via vizro
80
  setuptools==73.0.1
81
+ # via
82
+ # dash
83
+ # vizro
84
  six==1.16.0
85
  # via
86
  # python-dateutil
87
  # retrying
88
+ tenacity==9.0.0
89
+ # via plotly
90
  typing-extensions==4.12.2
91
  # via
92
  # dash
 
96
  # via pandas
97
  urllib3==2.2.2
98
  # via requests
99
+ vizro==0.1.20
100
  # via -r requirements.in
101
  werkzeug==3.0.4
102
  # via
103
  # dash
104
  # flask
105
+ # vizro
106
  wrapt==1.16.0
107
  # via vizro
108
  zipp==3.20.0