datamuo 1.1.24__tar.gz

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,368 @@
1
+ ## Ignore Visual Studio temporary files, build results, and
2
+ ## files generated by popular Visual Studio add-ons.
3
+ ##
4
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5
+
6
+ # User-specific files
7
+ *.rsuser
8
+ *.suo
9
+ *.user
10
+ *.userosscache
11
+ *.sln.docstates
12
+
13
+ nuget.exe
14
+ BlazorApp/published
15
+ Enterprise.Reporting/lib/*
16
+ ConfuserEx/*
17
+
18
+ # User-specific files (MonoDevelop/Xamarin Studio)
19
+ *.userprefs
20
+
21
+ # Mono auto generated files
22
+ mono_crash.*
23
+
24
+ # Build results
25
+ [Dd]ebug/
26
+ [Dd]ebugPublic/
27
+ [Rr]elease/
28
+ [Rr]eleases/
29
+ x64/
30
+ x86/
31
+ [Ww][Ii][Nn]32/
32
+ [Aa][Rr][Mm]/
33
+ [Aa][Rr][Mm]64/
34
+ bld/
35
+ [Bb]in/
36
+ [Oo]bj/
37
+ [Oo]ut/
38
+ [Ll]og/
39
+ [Ll]ogs/
40
+
41
+ # Visual Studio 2015/2017 cache/options directory
42
+ .vs/
43
+ # Uncomment if you have tasks that create the project's static files in wwwroot
44
+ #wwwroot/
45
+
46
+ # Visual Studio 2017 auto generated files
47
+ Generated\ Files/
48
+
49
+ # MSTest test Results
50
+ [Tt]est[Rr]esult*/
51
+ [Bb]uild[Ll]og.*
52
+
53
+ # NUnit
54
+ *.VisualState.xml
55
+ TestResult.xml
56
+ nunit-*.xml
57
+
58
+ # Build Results of an ATL Project
59
+ [Dd]ebugPS/
60
+ [Rr]eleasePS/
61
+ dlldata.c
62
+
63
+ # Benchmark Results
64
+ BenchmarkDotNet.Artifacts/
65
+
66
+ # .NET Core
67
+ project.lock.json
68
+ project.fragment.lock.json
69
+ artifacts/
70
+
71
+ # ASP.NET Scaffolding
72
+ ScaffoldingReadMe.txt
73
+
74
+ # StyleCop
75
+ StyleCopReport.xml
76
+
77
+ # Files built by Visual Studio
78
+ *_i.c
79
+ *_p.c
80
+ *_h.h
81
+ *.ilk
82
+ *.meta
83
+ *.obj
84
+ *.iobj
85
+ *.pch
86
+ *.pdb
87
+ *.ipdb
88
+ *.pgc
89
+ *.pgd
90
+ *.rsp
91
+ *.sbr
92
+ *.tlb
93
+ *.tli
94
+ *.tlh
95
+ *.tmp
96
+ *.tmp_proj
97
+ *_wpftmp.csproj
98
+ *.log
99
+ *.vspscc
100
+ *.vssscc
101
+ .builds
102
+ *.pidb
103
+ *.svclog
104
+ *.scc
105
+
106
+ # Chutzpah Test files
107
+ _Chutzpah*
108
+
109
+ # Visual C++ cache files
110
+ ipch/
111
+ *.aps
112
+ *.ncb
113
+ *.opendb
114
+ *.opensdf
115
+ *.sdf
116
+ *.cachefile
117
+ *.VC.db
118
+ *.VC.VC.opendb
119
+
120
+ # Visual Studio profiler
121
+ *.psess
122
+ *.vsp
123
+ *.vspx
124
+ *.sap
125
+
126
+ # Visual Studio Trace Files
127
+ *.e2e
128
+
129
+ # TFS 2012 Local Workspace
130
+ $tf/
131
+
132
+ # Guidance Automation Toolkit
133
+ *.gpState
134
+
135
+ # ReSharper is a .NET coding add-in
136
+ _ReSharper*/
137
+ *.[Rr]e[Ss]harper
138
+ *.DotSettings.user
139
+
140
+ # TeamCity is a build add-in
141
+ _TeamCity*
142
+
143
+ # DotCover is a Code Coverage Tool
144
+ *.dotCover
145
+
146
+ # AxoCover is a Code Coverage Tool
147
+ .axoCover/*
148
+ !.axoCover/settings.json
149
+
150
+ # Coverlet is a free, cross platform Code Coverage Tool
151
+ coverage*.json
152
+ coverage*.xml
153
+ coverage*.info
154
+
155
+ # Visual Studio code coverage results
156
+ *.coverage
157
+ *.coveragexml
158
+
159
+ # NCrunch
160
+ _NCrunch_*
161
+ .*crunch*.local.xml
162
+ nCrunchTemp_*
163
+
164
+ # MightyMoose
165
+ *.mm.*
166
+ AutoTest.Net/
167
+
168
+ # Web workbench (sass)
169
+ .sass-cache/
170
+
171
+ # Installshield output folder
172
+ [Ee]xpress/
173
+
174
+ # DocProject is a documentation generator add-in
175
+ DocProject/buildhelp/
176
+ DocProject/Help/*.HxT
177
+ DocProject/Help/*.HxC
178
+ DocProject/Help/*.hhc
179
+ DocProject/Help/*.hhk
180
+ DocProject/Help/*.hhp
181
+ DocProject/Help/Html2
182
+ DocProject/Help/html
183
+
184
+ # Click-Once directory
185
+ publish/
186
+
187
+ # Publish Web Output
188
+ *.[Pp]ublish.xml
189
+ *.azurePubxml
190
+ # Note: Comment the next line if you want to checkin your web deploy settings,
191
+ # but database connection strings (with potential passwords) will be unencrypted
192
+ *.pubxml
193
+ *.publishproj
194
+
195
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
196
+ # checkin your Azure Web App publish settings, but sensitive information contained
197
+ # in these scripts will be unencrypted
198
+ PublishScripts/
199
+
200
+ # NuGet Packages
201
+ *.nupkg
202
+ # NuGet Symbol Packages
203
+ *.snupkg
204
+ # The packages folder can be ignored because of Package Restore
205
+ **/[Pp]ackages/*
206
+ # except build/, which is used as an MSBuild target.
207
+ !**/[Pp]ackages/build/
208
+ # Uncomment if necessary however generally it will be regenerated when needed
209
+ #!**/[Pp]ackages/repositories.config
210
+ # NuGet v3's project.json files produces more ignorable files
211
+ *.nuget.props
212
+ *.nuget.targets
213
+
214
+ # Microsoft Azure Build Output
215
+ csx/
216
+ *.build.csdef
217
+
218
+ # Microsoft Azure Emulator
219
+ ecf/
220
+ rcf/
221
+
222
+ # Windows Store app package directories and files
223
+ AppPackages/
224
+ BundleArtifacts/
225
+ Package.StoreAssociation.xml
226
+ _pkginfo.txt
227
+ *.appx
228
+ *.appxbundle
229
+ *.appxupload
230
+
231
+ # Visual Studio cache files
232
+ # files ending in .cache can be ignored
233
+ *.[Cc]ache
234
+ # but keep track of directories ending in .cache
235
+ !?*.[Cc]ache/
236
+
237
+ # Others
238
+ ClientBin/
239
+ ~$*
240
+ *~
241
+ *.dbmdl
242
+ *.dbproj.schemaview
243
+ *.jfm
244
+ *.pfx
245
+ *.publishsettings
246
+ orleans.codegen.cs
247
+
248
+ # Including strong name files can present a security risk
249
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
250
+ #*.snk
251
+
252
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
253
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
254
+ #bower_components/
255
+
256
+ # RIA/Silverlight projects
257
+ Generated_Code/
258
+
259
+ # Backup & report files from converting an old project file
260
+ # to a newer Visual Studio version. Backup files are not needed,
261
+ # because we have git ;-)
262
+ _UpgradeReport_Files/
263
+ Backup*/
264
+ UpgradeLog*.XML
265
+ UpgradeLog*.htm
266
+ ServiceFabricBackup/
267
+ *.rptproj.bak
268
+
269
+ # SQL Server files
270
+ *.mdf
271
+ *.ldf
272
+ *.ndf
273
+
274
+ # Business Intelligence projects
275
+ *.rdl.data
276
+ *.bim.layout
277
+ *.bim_*.settings
278
+ *.rptproj.rsuser
279
+ *- [Bb]ackup.rdl
280
+ *- [Bb]ackup ([0-9]).rdl
281
+ *- [Bb]ackup ([0-9][0-9]).rdl
282
+
283
+ # Microsoft Fakes
284
+ FakesAssemblies/
285
+
286
+ # GhostDoc plugin setting file
287
+ *.GhostDoc.xml
288
+
289
+ # Node.js Tools for Visual Studio
290
+ .ntvs_analysis.dat
291
+ node_modules/
292
+
293
+ # Visual Studio 6 build log
294
+ *.plg
295
+
296
+ # Visual Studio 6 workspace options file
297
+ *.opt
298
+
299
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
300
+ *.vbw
301
+
302
+ # Visual Studio LightSwitch build output
303
+ **/*.HTMLClient/GeneratedArtifacts
304
+ **/*.DesktopClient/GeneratedArtifacts
305
+ **/*.DesktopClient/ModelManifest.xml
306
+ **/*.Server/GeneratedArtifacts
307
+ **/*.Server/ModelManifest.xml
308
+ _Pvt_Extensions
309
+
310
+ # Paket dependency manager
311
+ .paket/paket.exe
312
+ paket-files/
313
+
314
+ # FAKE - F# Make
315
+ .fake/
316
+
317
+ # CodeRush personal settings
318
+ .cr/personal
319
+
320
+ # Python Tools for Visual Studio (PTVS)
321
+ __pycache__/
322
+ *.pyc
323
+
324
+ # Cake - Uncomment if you are using it
325
+ # tools/**
326
+ # !tools/packages.config
327
+
328
+ # Tabs Studio
329
+ *.tss
330
+
331
+ # Telerik's JustMock configuration file
332
+ *.jmconfig
333
+
334
+ # BizTalk build output
335
+ *.btp.cs
336
+ *.btm.cs
337
+ *.odx.cs
338
+ *.xsd.cs
339
+
340
+ # OpenCover UI analysis results
341
+ OpenCover/
342
+
343
+ # Azure Stream Analytics local run output
344
+ ASALocalRun/
345
+
346
+ # MSBuild Binary and Structured Log
347
+ *.binlog
348
+
349
+ # NVidia Nsight GPU debugger configuration file
350
+ *.nvuser
351
+
352
+ # MFractors (Xamarin productivity tool) working folder
353
+ .mfractor/
354
+
355
+ # Local History for Visual Studio
356
+ .localhistory/
357
+
358
+ # BeatPulse healthcheck temp database
359
+ healthchecksdb
360
+
361
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
362
+ MigrationBackup/
363
+
364
+ # Ionide (cross platform F# VS Code tools) working folder
365
+ .ionide/
366
+
367
+ # Fody - auto-generated XML schema
368
+ FodyWeavers.xsd
@@ -0,0 +1,69 @@
1
+ <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
2
+ <PropertyGroup>
3
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
4
+ <SchemaVersion>2.0</SchemaVersion>
5
+ <ProjectGuid>caeb2355-3377-4b2c-89a4-8dd0058fa590</ProjectGuid>
6
+ <ProjectHome>.</ProjectHome>
7
+ <StartupFile>
8
+ </StartupFile>
9
+ <SearchPath>
10
+ </SearchPath>
11
+ <WorkingDirectory>.</WorkingDirectory>
12
+ <OutputPath>.</OutputPath>
13
+ <Name>Datamuo</Name>
14
+ <RootNamespace>Datamuo</RootNamespace>
15
+ </PropertyGroup>
16
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
17
+ <DebugSymbols>true</DebugSymbols>
18
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
19
+ </PropertyGroup>
20
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
21
+ <DebugSymbols>true</DebugSymbols>
22
+ <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
23
+ </PropertyGroup>
24
+ <ItemGroup>
25
+ <Content Include="pyproject.toml" />
26
+ <Content Include="README.md" />
27
+ <Content Include="src\datamuo\actions.js" />
28
+ <Content Include="src\datamuo\bin\Enterprise.DataTensor.dll" />
29
+ <Content Include="src\datamuo\bin\Enterprise.Fragments.dll" />
30
+ <Content Include="src\datamuo\bin\Enterprise.Reporting.dll" />
31
+ <Content Include="src\datamuo\bin\Enterprise.Utils.dll" />
32
+ <Content Include="src\datamuo\py.typed" />
33
+ <Content Include="src\datamuo\runtimeconfig.json" />
34
+ <Content Include="src\datamuo\__pycache__\_reports.cpython-312.pyc" />
35
+ <Content Include="src\datamuo\__pycache__\_runtime.cpython-312.pyc" />
36
+ <Content Include="src\datamuo\__pycache__\__init__.cpython-312.pyc" />
37
+ <Content Include="tests\__pycache__\test_actions.cpython-312-pytest-9.0.3.pyc" />
38
+ <Content Include="tests\__pycache__\test_actions.cpython-312-pytest-9.2.0.pyc" />
39
+ <Content Include="tests\__pycache__\test_reports.cpython-312-pytest-9.0.3.pyc" />
40
+ <Content Include="tests\__pycache__\test_reports.cpython-312-pytest-9.2.0.pyc" />
41
+ <Content Include="tests\__pycache__\test_runtime.cpython-312-pytest-9.0.3.pyc" />
42
+ <Content Include="tests\__pycache__\test_runtime.cpython-312-pytest-9.2.0.pyc" />
43
+ </ItemGroup>
44
+ <ItemGroup>
45
+ <Folder Include="src\" />
46
+ <Folder Include="src\datamuo\bin\" />
47
+ <Folder Include="src\datamuo\" />
48
+ <Folder Include="src\datamuo\__pycache__\" />
49
+ <Folder Include="tests\" />
50
+ <Folder Include="tests\__pycache__\" />
51
+ </ItemGroup>
52
+ <ItemGroup>
53
+ <Compile Include="src\datamuo\_reports.py" />
54
+ <Compile Include="src\datamuo\_runtime.py" />
55
+ <Compile Include="src\datamuo\__init__.py" />
56
+ <Compile Include="tests\test_actions.py" />
57
+ <Compile Include="tests\test_reports.py" />
58
+ <Compile Include="tests\test_runtime.py" />
59
+ </ItemGroup>
60
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets" />
61
+ <!-- Uncomment the CoreCompile target to enable the Build command in
62
+ Visual Studio and specify your pre- and post-build commands in
63
+ the BeforeBuild and AfterBuild targets below. -->
64
+ <!--<Target Name="CoreCompile" />-->
65
+ <Target Name="BeforeBuild">
66
+ </Target>
67
+ <Target Name="AfterBuild">
68
+ </Target>
69
+ </Project>
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2025 Andrea Muolo
2
+
3
+ This software is licensed under the terms of this agreement. By using this software, you agree to the following terms:
4
+
5
+ 1. Ownership: The software and all associated intellectual property rights are owned by Andrea Muolo.
6
+ You are granted a non-exclusive, non-transferable, revocable license to use the software.
7
+
8
+ 2. Restrictions: You may not:
9
+    a. Reverse engineer, decompile, or disassemble the software.
10
+    b. Modify, adapt, or create derivative works based on the software.
11
+    c. Redistribute, sublicense, or transfer the software to any third party.
12
+
13
+ 3. Termination: This license will terminate automatically if you fail to comply with any of the terms.
14
+ Upon termination, you must cease all use of the software and destroy all copies.
15
+
16
+ 4. The software is provided "as is" without warranty of any kind, express or implied,
17
+ including but not limited to the warranties of mechantability, fitness for a particular purpose
18
+ and noninfringment. In no event shall the owner or the author or the copyright holder be liable for any claim,
19
+ damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection
20
+ with the software or the use or other dealings in the software.
21
+
22
+
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.5
2
+ Name: datamuo
3
+ Version: 1.1.24
4
+ Summary: Data tensors, interactive (pivot) tables.
5
+ License: Copyright (c) 2025 Andrea Muolo
6
+
7
+ This software is licensed under the terms of this agreement. By using this software, you agree to the following terms:
8
+
9
+ 1. Ownership: The software and all associated intellectual property rights are owned by Andrea Muolo.
10
+ You are granted a non-exclusive, non-transferable, revocable license to use the software.
11
+
12
+ 2. Restrictions: You may not:
13
+    a. Reverse engineer, decompile, or disassemble the software.
14
+    b. Modify, adapt, or create derivative works based on the software.
15
+    c. Redistribute, sublicense, or transfer the software to any third party.
16
+
17
+ 3. Termination: This license will terminate automatically if you fail to comply with any of the terms.
18
+ Upon termination, you must cease all use of the software and destroy all copies.
19
+
20
+ 4. The software is provided "as is" without warranty of any kind, express or implied,
21
+ including but not limited to the warranties of mechantability, fitness for a particular purpose
22
+ and noninfringment. In no event shall the owner or the author or the copyright holder be liable for any claim,
23
+ damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection
24
+ with the software or the use or other dealings in the software.
25
+
26
+
27
+ License-File: LICENSE.txt
28
+ Classifier: License :: Other/Proprietary License
29
+ Classifier: Programming Language :: Python :: 3
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.12
32
+ Requires-Dist: pythonnet<4,>=3.0.3
33
+ Description-Content-Type: text/markdown
34
+
35
+ # datamuo
36
+
37
+ Data tensors from plain records, interactive tables and pivot tables as HTML, and comments on data points.
38
+
39
+ ## Install
40
+
41
+ Requires Python 3.12+ and the ASP.NET Core Runtime 10
42
+ (`dotnet --list-runtimes` lists `Microsoft.AspNetCore.App 10.x`; the SDK is not needed).
43
+ The package bundles the [Muoland.Reporting](https://www.nuget.org/packages/Muoland.Reporting)
44
+ assemblies of its version.
45
+
46
+ ```bash
47
+ pip install datamuo
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ```python
53
+ from datamuo import Tensor
54
+
55
+ systems = Tensor("System", records) # records: mappings; dimensions default to ("id",), values to the other properties
56
+ roadmap = Tensor("RoadmapItem", items, dimensions=["id", "status"], aggregations={"end_date": max})
57
+
58
+ # options: order, hidden, page_size, height, width, cell_width, table_style, theme, centered
59
+ table = systems.table(order=["name", "owner"], page_size=50, height="65vh")
60
+ pivot = roadmap.pivot(rows=["id"], columns=["status"], theme="minimalist")
61
+
62
+ fragments = table.render() # Fragments(main, filter, comments, dialogs, view, slice) as HTML
63
+ fragments = table.render(action) # after a user interaction, see below
64
+
65
+ systems.add_comment(record, "Owner missing", author="validator", priority=1) # lower priorities are more critical
66
+ systems.comments(record) # history, oldest first: [Comment(tag, author, text, priority, created, view)]
67
+ ```
68
+
69
+ `None`, NaN and infinite values become `""`, and engine failures raise `ReportingError`. Tensors are thread-safe and shared by all users, while a report keeps its user's UI state (paging, filters, open dialogs), so web apps keep one per session, stored as they see fit:
70
+
71
+ ```python
72
+ from datamuo import Assets, Fragments, Report, assets
73
+
74
+ reports: dict[tuple[str, str], Report] = {}
75
+
76
+ @app.post("/reports/{name}")
77
+ def render(name: str, session: str, action: str = "") -> Fragments:
78
+ if (session, name) not in reports:
79
+ reports[session, name] = tensors[name].table()
80
+ return reports[session, name].render(action)
81
+
82
+ @app.get("/reports/assets")
83
+ def report_assets() -> Assets:
84
+ return assets()
85
+ ```
86
+
87
+ ### Data entry, custom views and persistence
88
+
89
+ ```python
90
+ from datamuo import Comment, DimensionMember, Record, Report, Tensor, UiTreeBuilder, View, deserialize
91
+
92
+ def badge(ui: UiTreeBuilder, status: str) -> None: # draws each cell of a property; markup is inserted as is
93
+ ui.open_element("b")
94
+ ui.add_attribute("class", "badge")
95
+ ui.add_markup_content(html.escape(status))
96
+ ui.close_element()
97
+
98
+ table = systems.table(
99
+ editable=["name", "owner"], # all properties by default
100
+ validate=lambda report, record: [] if record["name"] else ["Name required"], # errors reject the edit
101
+ on_submit=lambda report, record: save(record), # each valid edit
102
+ on_row_click=lambda report, record: select(record), # replaces the record dialog
103
+ custom_views={"status": badge},
104
+ )
105
+
106
+ systems = Tensor(
107
+ "System", records,
108
+ dimension_data={"status": [DimensionMember("live", "Live"), DimensionMember("eol", "End of life", parent="live")]},
109
+ comments=load_comments(), on_comment=save_comment, # list[Comment], (Comment) -> None
110
+ views=load_views(), on_view=save_view, # list[View], (View) -> None
111
+ )
112
+
113
+ deserialize(json_lines) # JSON records as dicts sharing all keys, the missing ones None
114
+ ```
115
+
116
+ Callbacks get the report and plain Python records. `on_comment` and `on_view` also receive the comments and views users add in reports, on another thread.
117
+
118
+ ## Frontend
119
+
120
+ Load `assets().css` and run `assets().js` once per page, then inject the fragments' HTML. Each user interaction with it dispatches a bubbling `mlu-action` event: send its `detail.action` to `Report.render` and apply the returned HTML unless `detail.silent`. Process a report's actions one at a time, in order.
121
+
122
+ ```js
123
+ container.addEventListener("mlu-action", ({ detail: { action, silent } }) => queue(action, silent));
124
+ ```
125
+
126
+ ## Development
127
+
128
+ Copy the `lib/net10.0/*.dll` of a `dotnet pack` output into `src/datamuo/bin/`, then:
129
+
130
+ ```bash
131
+ pip install -e python pytest playwright
132
+ python -m playwright install chromium # or set PLAYWRIGHT_CHANNEL=msedge to use an installed Edge
133
+ pytest python/tests # browser tests of actions.js skip without Playwright
134
+ ```
@@ -0,0 +1,100 @@
1
+ # datamuo
2
+
3
+ Data tensors from plain records, interactive tables and pivot tables as HTML, and comments on data points.
4
+
5
+ ## Install
6
+
7
+ Requires Python 3.12+ and the ASP.NET Core Runtime 10
8
+ (`dotnet --list-runtimes` lists `Microsoft.AspNetCore.App 10.x`; the SDK is not needed).
9
+ The package bundles the [Muoland.Reporting](https://www.nuget.org/packages/Muoland.Reporting)
10
+ assemblies of its version.
11
+
12
+ ```bash
13
+ pip install datamuo
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```python
19
+ from datamuo import Tensor
20
+
21
+ systems = Tensor("System", records) # records: mappings; dimensions default to ("id",), values to the other properties
22
+ roadmap = Tensor("RoadmapItem", items, dimensions=["id", "status"], aggregations={"end_date": max})
23
+
24
+ # options: order, hidden, page_size, height, width, cell_width, table_style, theme, centered
25
+ table = systems.table(order=["name", "owner"], page_size=50, height="65vh")
26
+ pivot = roadmap.pivot(rows=["id"], columns=["status"], theme="minimalist")
27
+
28
+ fragments = table.render() # Fragments(main, filter, comments, dialogs, view, slice) as HTML
29
+ fragments = table.render(action) # after a user interaction, see below
30
+
31
+ systems.add_comment(record, "Owner missing", author="validator", priority=1) # lower priorities are more critical
32
+ systems.comments(record) # history, oldest first: [Comment(tag, author, text, priority, created, view)]
33
+ ```
34
+
35
+ `None`, NaN and infinite values become `""`, and engine failures raise `ReportingError`. Tensors are thread-safe and shared by all users, while a report keeps its user's UI state (paging, filters, open dialogs), so web apps keep one per session, stored as they see fit:
36
+
37
+ ```python
38
+ from datamuo import Assets, Fragments, Report, assets
39
+
40
+ reports: dict[tuple[str, str], Report] = {}
41
+
42
+ @app.post("/reports/{name}")
43
+ def render(name: str, session: str, action: str = "") -> Fragments:
44
+ if (session, name) not in reports:
45
+ reports[session, name] = tensors[name].table()
46
+ return reports[session, name].render(action)
47
+
48
+ @app.get("/reports/assets")
49
+ def report_assets() -> Assets:
50
+ return assets()
51
+ ```
52
+
53
+ ### Data entry, custom views and persistence
54
+
55
+ ```python
56
+ from datamuo import Comment, DimensionMember, Record, Report, Tensor, UiTreeBuilder, View, deserialize
57
+
58
+ def badge(ui: UiTreeBuilder, status: str) -> None: # draws each cell of a property; markup is inserted as is
59
+ ui.open_element("b")
60
+ ui.add_attribute("class", "badge")
61
+ ui.add_markup_content(html.escape(status))
62
+ ui.close_element()
63
+
64
+ table = systems.table(
65
+ editable=["name", "owner"], # all properties by default
66
+ validate=lambda report, record: [] if record["name"] else ["Name required"], # errors reject the edit
67
+ on_submit=lambda report, record: save(record), # each valid edit
68
+ on_row_click=lambda report, record: select(record), # replaces the record dialog
69
+ custom_views={"status": badge},
70
+ )
71
+
72
+ systems = Tensor(
73
+ "System", records,
74
+ dimension_data={"status": [DimensionMember("live", "Live"), DimensionMember("eol", "End of life", parent="live")]},
75
+ comments=load_comments(), on_comment=save_comment, # list[Comment], (Comment) -> None
76
+ views=load_views(), on_view=save_view, # list[View], (View) -> None
77
+ )
78
+
79
+ deserialize(json_lines) # JSON records as dicts sharing all keys, the missing ones None
80
+ ```
81
+
82
+ Callbacks get the report and plain Python records. `on_comment` and `on_view` also receive the comments and views users add in reports, on another thread.
83
+
84
+ ## Frontend
85
+
86
+ Load `assets().css` and run `assets().js` once per page, then inject the fragments' HTML. Each user interaction with it dispatches a bubbling `mlu-action` event: send its `detail.action` to `Report.render` and apply the returned HTML unless `detail.silent`. Process a report's actions one at a time, in order.
87
+
88
+ ```js
89
+ container.addEventListener("mlu-action", ({ detail: { action, silent } }) => queue(action, silent));
90
+ ```
91
+
92
+ ## Development
93
+
94
+ Copy the `lib/net10.0/*.dll` of a `dotnet pack` output into `src/datamuo/bin/`, then:
95
+
96
+ ```bash
97
+ pip install -e python pytest playwright
98
+ python -m playwright install chromium # or set PLAYWRIGHT_CHANNEL=msedge to use an installed Edge
99
+ pytest python/tests # browser tests of actions.js skip without Playwright
100
+ ```