algomancy-content 0.3.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,275 @@
1
+ from dash import html, get_app
2
+ import dash
3
+ import dash_bootstrap_components as dbc
4
+
5
+ from algomancy_scenario import ScenarioStatus, ScenarioManager
6
+
7
+
8
+ class StandardHomePage:
9
+ @staticmethod
10
+ def create_content():
11
+ """
12
+ Creates the content for the home page, including logo, status indicators,
13
+ and a summary of scenario processing status.
14
+
15
+ Implements the HomePage Protocol
16
+
17
+ Returns:
18
+ html.Div: A Dash HTML component representing the home page content
19
+ """
20
+ # Get scenario information
21
+ session_manager = get_app().server.session_manager
22
+ scenario_manager: ScenarioManager = session_manager.get_scenario_manager(
23
+ session_manager.start_session_name
24
+ )
25
+ all_scenarios = scenario_manager.list_scenarios()
26
+
27
+ # Count scenarios in each status
28
+ processing_count = sum(
29
+ 1 for s in all_scenarios if s.status == ScenarioStatus.PROCESSING
30
+ )
31
+ queued_count = sum(
32
+ 1 for s in all_scenarios if s.status == ScenarioStatus.QUEUED
33
+ )
34
+ completed_count = sum(
35
+ 1 for s in all_scenarios if s.status == ScenarioStatus.COMPLETE
36
+ )
37
+ failed_count = sum(
38
+ 1 for s in all_scenarios if s.status == ScenarioStatus.FAILED
39
+ )
40
+ created_count = sum(
41
+ 1 for s in all_scenarios if s.status == ScenarioStatus.CREATED
42
+ )
43
+
44
+ # Define status indicators
45
+ status_indicators = [
46
+ StandardHomePage._create_status_card(
47
+ "Processing",
48
+ processing_count,
49
+ "primary",
50
+ "Scenarios currently being processed",
51
+ ),
52
+ StandardHomePage._create_status_card(
53
+ "Queued", queued_count, "info", "Scenarios waiting to be processed"
54
+ ),
55
+ StandardHomePage._create_status_card(
56
+ "Completed",
57
+ completed_count,
58
+ "success",
59
+ "Successfully completed scenarios",
60
+ ),
61
+ StandardHomePage._create_status_card(
62
+ "Failed", failed_count, "danger", "Scenarios that encountered errors"
63
+ ),
64
+ StandardHomePage._create_status_card(
65
+ "Created", created_count, "secondary", "Newly created scenarios"
66
+ ),
67
+ ]
68
+ logo_url = dash.get_asset_url("cqm-logo.png")
69
+
70
+ return html.Div(
71
+ [
72
+ # Header with logo
73
+ dbc.Row(
74
+ [
75
+ dbc.Col(width=4),
76
+ dbc.Col(
77
+ html.Div(
78
+ [
79
+ html.H1(
80
+ "WARP Dashboard",
81
+ className="display-4",
82
+ style={"color": "var(--text-color)"},
83
+ ),
84
+ html.P(
85
+ "Workflow Analysis and Reporting Platform",
86
+ className="lead",
87
+ style={
88
+ "color": "var(--text-color)",
89
+ "opacity": 0.8,
90
+ },
91
+ ),
92
+ ]
93
+ ),
94
+ width={"size": 6},
95
+ className="d-flex align-items-center",
96
+ ),
97
+ dbc.Col(
98
+ html.Img(src=logo_url, height="80px", className="mb-4"),
99
+ width={"size": 2},
100
+ className="d-flex align-items-center",
101
+ ),
102
+ ],
103
+ className="mb-4",
104
+ ),
105
+ # System Status Section
106
+ dbc.Card(
107
+ [
108
+ dbc.CardHeader(
109
+ html.H3("System Status", className="mb-0"),
110
+ style={
111
+ "backgroundColor": "transparent",
112
+ "color": "var(--text-color)",
113
+ },
114
+ ),
115
+ dbc.CardBody(
116
+ [
117
+ dbc.Row(
118
+ [
119
+ dbc.Col(
120
+ html.Div(
121
+ [
122
+ html.H5(
123
+ "Scenario Status Overview",
124
+ className="mb-3",
125
+ style={
126
+ "color": "var(--text-color)"
127
+ },
128
+ ),
129
+ dbc.Row(status_indicators),
130
+ ]
131
+ ),
132
+ width=12,
133
+ )
134
+ ]
135
+ )
136
+ ]
137
+ ),
138
+ ],
139
+ className="mb-4",
140
+ style={
141
+ "backgroundColor": "var(--card-surface)",
142
+ "border": "none",
143
+ "boxShadow": "0 2px 8px rgba(0,0,0,0.12)",
144
+ },
145
+ ),
146
+ # Quick Links Section
147
+ dbc.Card(
148
+ [
149
+ dbc.CardHeader(
150
+ html.H3("Quick Links", className="mb-0"),
151
+ style={
152
+ "backgroundColor": "transparent",
153
+ "color": "var(--text-color)",
154
+ },
155
+ ),
156
+ dbc.CardBody(
157
+ dbc.Row(
158
+ [
159
+ StandardHomePage._create_quick_link(
160
+ "Create Scenario",
161
+ "/scenarios/create",
162
+ "Create a new scenario",
163
+ "primary",
164
+ ),
165
+ StandardHomePage._create_quick_link(
166
+ "View Scenarios",
167
+ "/scenarios",
168
+ "View all scenarios",
169
+ "info",
170
+ ),
171
+ StandardHomePage._create_quick_link(
172
+ "Compare",
173
+ "/compare",
174
+ "Compare two scenarios",
175
+ "success",
176
+ ),
177
+ StandardHomePage._create_quick_link(
178
+ "Data Import",
179
+ "/data",
180
+ "Import or manage data",
181
+ "warning",
182
+ ),
183
+ ]
184
+ )
185
+ ),
186
+ ],
187
+ style={
188
+ "backgroundColor": "var(--card-surface)",
189
+ "border": "none",
190
+ "boxShadow": "0 2px 8px rgba(0,0,0,0.12)",
191
+ },
192
+ ),
193
+ ],
194
+ className="p-4",
195
+ style={"color": "var(--text-color)"},
196
+ )
197
+
198
+ @staticmethod
199
+ def _create_status_card(title, count, color, tooltip):
200
+ """Create a card showing a status count with appropriate styling responsive to theme."""
201
+ return dbc.Col(
202
+ dbc.Card(
203
+ [
204
+ dbc.CardBody(
205
+ [
206
+ html.H4(
207
+ f"{count}",
208
+ className="text-center",
209
+ style={"color": "var(--text-selected)"},
210
+ ),
211
+ html.P(
212
+ title,
213
+ className="text-center mb-0",
214
+ style={"color": "var(--text-selected)"},
215
+ ),
216
+ ]
217
+ )
218
+ ],
219
+ className="mb-3 text-center",
220
+ id=f"status-card-{title.lower()}",
221
+ style={
222
+ "cursor": "pointer",
223
+ "background": f"var(--status-{title.lower()})",
224
+ "border": "none",
225
+ "boxShadow": "0 2px 8px rgba(0,0,0,0.12)",
226
+ },
227
+ ),
228
+ width={"size": 2, "offset": 0},
229
+ className="mx-auto",
230
+ )
231
+
232
+ @staticmethod
233
+ def _create_quick_link(title, href, description, color):
234
+ """Create a quick link card for navigation."""
235
+ return dbc.Col(
236
+ dbc.Card(
237
+ [
238
+ dbc.CardBody(
239
+ [
240
+ html.H5(
241
+ title,
242
+ className="card-title",
243
+ style={"color": "var(--text-color)"},
244
+ ),
245
+ html.P(
246
+ description,
247
+ className="card-text",
248
+ style={"color": "var(--text-color)", "opacity": 0.9},
249
+ ),
250
+ dbc.Button(
251
+ "Go",
252
+ href=href,
253
+ className="mt-2",
254
+ style={
255
+ "backgroundColor": "var(--theme-secondary)",
256
+ "color": "var(--text-selected)",
257
+ "border": "none",
258
+ },
259
+ ),
260
+ ]
261
+ )
262
+ ],
263
+ className="h-100",
264
+ style={
265
+ "backgroundColor": "rgba(0,0,0,0.0)",
266
+ "border": "1px solid rgba(255,255,255,0.1)",
267
+ },
268
+ ),
269
+ width=3,
270
+ className="mb-4",
271
+ )
272
+
273
+ @staticmethod
274
+ def register_callbacks():
275
+ pass
@@ -0,0 +1,135 @@
1
+ from dash import html, dash_table, callback, Output, Input, get_app, State
2
+
3
+ from dash import dcc
4
+
5
+ from algomancy_gui.componentids import ACTIVE_SESSION
6
+ from algomancy_scenario import ScenarioManager
7
+
8
+ OVERVIEW_TABLE = "overview-table"
9
+ OVERVIEW_UPDATE_INTERVAL = "overview-update-interval"
10
+
11
+
12
+ class StandardOverviewPage:
13
+ @staticmethod
14
+ def create_content():
15
+ """
16
+ Creates the overview page layout with a table of completed scenarios and their KPIs.
17
+
18
+ This page displays a table where rows represent completed scenarios and columns represent KPIs.
19
+
20
+ Returns:
21
+ html.Div: A Dash HTML component representing the overview page
22
+ """
23
+ page = html.Div(
24
+ [
25
+ html.H2("Scenarios Overview"),
26
+ html.Hr(),
27
+ # Description
28
+ html.P(
29
+ "This page shows an overview of all completed scenarios and their KPIs."
30
+ ),
31
+ # Table container
32
+ html.Div(
33
+ [
34
+ # The table will be populated by a callback
35
+ dash_table.DataTable(
36
+ id=OVERVIEW_TABLE,
37
+ style_table={
38
+ "overflowX": "auto",
39
+ },
40
+ style_cell={
41
+ "textAlign": "center",
42
+ "padding": "10px",
43
+ },
44
+ style_header={
45
+ "backgroundColor": "rgb(230, 230, 230)",
46
+ "fontWeight": "bold",
47
+ "textAlign": "center",
48
+ },
49
+ style_data_conditional=[
50
+ {
51
+ "if": {"row_index": "odd"},
52
+ "backgroundColor": "rgb(248, 248, 248)",
53
+ }
54
+ ],
55
+ ),
56
+ ],
57
+ style={"marginTop": "20px"},
58
+ ),
59
+ # Interval for periodic updates
60
+ dcc.Interval(
61
+ id=OVERVIEW_UPDATE_INTERVAL,
62
+ interval=5000, # in milliseconds
63
+ n_intervals=0,
64
+ ),
65
+ ]
66
+ )
67
+
68
+ return page
69
+
70
+ @staticmethod
71
+ def register_callbacks():
72
+ @callback(
73
+ Output(OVERVIEW_TABLE, "data"),
74
+ Output(OVERVIEW_TABLE, "columns"),
75
+ Input(OVERVIEW_UPDATE_INTERVAL, "n_intervals"),
76
+ Input("url", "pathname"),
77
+ State(ACTIVE_SESSION, "data"),
78
+ )
79
+ def update_overview_table(n_intervals, pathname, session_id: str):
80
+ """
81
+ Updates the overview table with completed scenarios and their KPIs.
82
+
83
+ Args:
84
+ n_intervals (int): Number of intervals elapsed (from dcc.Interval)
85
+ pathname (str): Current URL pathname
86
+ session_id (str): ID of the active session
87
+
88
+ Returns:
89
+ tuple: (
90
+ list: Table data (rows),
91
+ list: Table columns
92
+ )
93
+ """
94
+ # Only update when on the overview page
95
+ if pathname != "/overview":
96
+ return [], []
97
+
98
+ # Get the scenario manager
99
+ scenario_manager: ScenarioManager = (
100
+ get_app().server.session_manager.get_scenario_manager(session_id)
101
+ )
102
+
103
+ # Get completed scenarios
104
+ completed_scenarios = [
105
+ s for s in scenario_manager.list_scenarios() if s.is_completed()
106
+ ]
107
+
108
+ if not completed_scenarios:
109
+ return [], [{"name": "No completed scenarios", "id": "no_data"}]
110
+
111
+ # Get the first scenario to determine KPI columns
112
+ first_scenario = completed_scenarios[0]
113
+
114
+ # Create columns for the table
115
+ columns = [{"name": "Scenario", "id": "scenario_tag"}]
116
+
117
+ # Add columns for each KPI
118
+ for kpi_id, kpi in first_scenario.kpis.items():
119
+ column_name = f"{kpi.name}"
120
+ columns.append({"name": column_name, "id": kpi_id})
121
+
122
+ # Create data for the table
123
+ data = []
124
+ for scenario in completed_scenarios:
125
+ row = {"scenario_tag": scenario.tag}
126
+
127
+ # Add KPI values
128
+ for kpi_id, kpi in scenario.kpis.items():
129
+ row[kpi_id] = kpi.pretty() + (
130
+ f" ({kpi.details()})" if kpi.details() else ""
131
+ )
132
+
133
+ data.append(row)
134
+
135
+ return data, columns
File without changes
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.3
2
+ Name: algomancy-content
3
+ Version: 0.3.12
4
+ Summary: Placeholder content for quick start to the Algomancy library
5
+ Author: Pepijn Wissing
6
+ Author-email: Pepijn Wissing <Wsg@cqm.nl>
7
+ Requires-Dist: algomancy-data
8
+ Requires-Dist: algomancy-scenario
9
+ Requires-Dist: dash
10
+ Requires-Dist: dash-bootstrap-components
11
+ Requires-Dist: dash-daq
12
+ Requires-Dist: pandas
13
+ Requires-Python: >=3.14
14
+ Description-Content-Type: text/markdown
15
+
16
+ ### algomancy-content
17
+
18
+ Reusable content blocks (pages and callbacks) for Algomancy dashboards built with Dash. This package provides ready‑made creators for home, data, and overview pages, plus placeholder content to get you started quickly.
19
+
20
+ #### Features
21
+ - Standard page content creators (home, data, overview)
22
+ - Placeholder content for instant scaffolding
23
+ - Pairs naturally with `algomancy-gui` styling and the core launcher under `src/algomancy`
24
+
25
+ #### Installation
26
+ ```
27
+ pip install -e packages/algomancy-content
28
+ ```
29
+
30
+ Requires Python >= 3.14.
31
+
32
+ #### Quick start
33
+
34
+ ```python
35
+ from algomancy_content import ShowcaseHomePage
36
+
37
+ # Plug into your AppConfiguration (see project root `example/main.py`)
38
+ home_content = ShowcaseHomePage.create_default_elements_showcase
39
+ home_callbacks = ShowcaseHomePage.register_callbacks
40
+ ```
41
+
42
+ Use the prebuilt standard home page:
43
+
44
+ ```python
45
+ from algomancy_content.pages.standardhomepage import StandardHomePage
46
+
47
+ home_content = StandardHomePage.create_content
48
+ home_callbacks = StandardHomePage.register_callbacks
49
+ ```
50
+
51
+ #### Related docs and examples
52
+ - Example application: `example/main.py`
53
+ - Root documentation: `documentation/3_dash_contents.md`
@@ -0,0 +1,20 @@
1
+ algomancy_content/__init__.py,sha256=q11Zi4b_hG192WxcxHhp0SgaBJ1feBy_uJr1gJBp4C8,972
2
+ algomancy_content/backend/__init__.py,sha256=_W5qeuGE6oCdkXQq48k3Mr2WMpkIrFPBfVj-CmNix2Q,446
3
+ algomancy_content/backend/placeholderalgorithmtemplate.py,sha256=Hy9GvkNGagN-15l1nHaGGJLWaqZCgQqcpH4ELTmYucw,712
4
+ algomancy_content/backend/placeholderetlfactory.py,sha256=o6IVo1MWvBVYEfDOobmYXKgJ5vaIMNQF_6omRsnm0YI,935
5
+ algomancy_content/backend/placeholderinputconfig.py,sha256=DoAKDMnOXBYfVISfJ66lYcD5kE7FbQWLAzAkDMYmL2Q,816
6
+ algomancy_content/backend/placeholderkpitemplate.py,sha256=H1W1aAh4t_6avzKY36vDbq_g6RGS1g1l8PAj1f0uBSw,538
7
+ algomancy_content/librarymanager.py,sha256=MubNqkSFIH3ooA71ecBFkVUA8gkiWeUkeCnLHlMpxN4,2423
8
+ algomancy_content/pages/__init__.py,sha256=rh07pnYNxrDWsZXgpZ5V0OwmtT3ngnYEKsMAh31d1bU,794
9
+ algomancy_content/pages/page.py,sha256=Hao1aXTzgTQJw4knA2n2dVZy0nPTM8CF2l5WxvHZuuE,1427
10
+ algomancy_content/pages/placeholdercomparepage.py,sha256=dbmXqLz7t1Cy1Jw5Y953E8wLW36aO6NyNJpwPPYg1Ic,1430
11
+ algomancy_content/pages/placeholderdatapage.py,sha256=PdNpphFdQpYU9hh40TGo-NnFo-6bbQclscBLisKZD6g,433
12
+ algomancy_content/pages/placeholderscenariopage.py,sha256=LFsD9pGoVLk_h_B7aKM9oI3ds8cc3yBeYBMUIWC5Jj0,603
13
+ algomancy_content/pages/showcasehomepage.py,sha256=i2UkRWA_JXSgLmXieI2uHmAHxOE6jmN1Kmuf1db-MZc,15245
14
+ algomancy_content/pages/standarddatapage.py,sha256=k50M4FRxmDldaC9C4xguFi_5-IOBAUueISRwEM4okXU,1606
15
+ algomancy_content/pages/standardhomepage.py,sha256=FcH41BaMwxuJfwLYLo2kIedeXT8LvnaUYDTy5pCi6Ps,11147
16
+ algomancy_content/pages/standardoverviewpage.py,sha256=qqpNpGA3qK0KvFJBtxJYq1vPu4cNNUt0Q51ZhNIkelE,4818
17
+ algomancy_content/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ algomancy_content-0.3.12.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
19
+ algomancy_content-0.3.12.dist-info/METADATA,sha256=_kcpszhcemJD_YX46UoMc93sGpWm4JOu0Cf5aDSAvho,1604
20
+ algomancy_content-0.3.12.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.9.28
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any