tboardfs 0.2.0__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.
- tboardfs-0.2.0/LICENSE +21 -0
- tboardfs-0.2.0/PKG-INFO +161 -0
- tboardfs-0.2.0/README.md +132 -0
- tboardfs-0.2.0/pyproject.toml +62 -0
- tboardfs-0.2.0/tboardfs/__init__.py +13 -0
- tboardfs-0.2.0/tboardfs/array_json.py +12 -0
- tboardfs-0.2.0/tboardfs/classify.py +232 -0
- tboardfs-0.2.0/tboardfs/cli.py +55 -0
- tboardfs-0.2.0/tboardfs/constants.py +50 -0
- tboardfs-0.2.0/tboardfs/custom_scalars.py +27 -0
- tboardfs-0.2.0/tboardfs/decode.py +43 -0
- tboardfs-0.2.0/tboardfs/errors.py +7 -0
- tboardfs-0.2.0/tboardfs/extract.py +36 -0
- tboardfs-0.2.0/tboardfs/file_cli.py +26 -0
- tboardfs-0.2.0/tboardfs/file_cli_commands.py +124 -0
- tboardfs-0.2.0/tboardfs/file_tree.py +112 -0
- tboardfs-0.2.0/tboardfs/filesystem.py +820 -0
- tboardfs-0.2.0/tboardfs/hparams.py +80 -0
- tboardfs-0.2.0/tboardfs/indexer.py +263 -0
- tboardfs-0.2.0/tboardfs/mesh.py +102 -0
- tboardfs-0.2.0/tboardfs/model/__init__.py +21 -0
- tboardfs-0.2.0/tboardfs/model/binary_entry.py +30 -0
- tboardfs-0.2.0/tboardfs/model/event_file_cache.py +36 -0
- tboardfs-0.2.0/tboardfs/model/field.py +15 -0
- tboardfs-0.2.0/tboardfs/model/graph_entry.py +20 -0
- tboardfs-0.2.0/tboardfs/model/json_entry.py +20 -0
- tboardfs-0.2.0/tboardfs/model/record.py +19 -0
- tboardfs-0.2.0/tboardfs/model/run_cache.py +20 -0
- tboardfs-0.2.0/tboardfs/model/scalar.py +16 -0
- tboardfs-0.2.0/tboardfs/model/sidecar_entry.py +16 -0
- tboardfs-0.2.0/tboardfs/npy_export.py +10 -0
- tboardfs-0.2.0/tboardfs/paths.py +101 -0
- tboardfs-0.2.0/tboardfs/plugin_files.py +166 -0
- tboardfs-0.2.0/tboardfs/proto_schema.py +218 -0
- tboardfs-0.2.0/tboardfs/py.typed +0 -0
- tboardfs-0.2.0/tboardfs/summary.py +136 -0
- tboardfs-0.2.0/tboardfs/tables.py +322 -0
- tboardfs-0.2.0/tboardfs/tensor.py +91 -0
- tboardfs-0.2.0/tboardfs/tfrecord.py +42 -0
tboardfs-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Völgyes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tboardfs-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tboardfs
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Read TensorBoard event logs as files through a FUSE filesystem.
|
|
5
|
+
Keywords: fuse,tensorboard,filesystem,machine-learning
|
|
6
|
+
Author: David Völgyes
|
|
7
|
+
Author-email: David Völgyes <dvolgyes@deepconv.ai>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Topic :: System :: Filesystems
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Dist: click>=8.4.1,<9.0
|
|
20
|
+
Requires-Dist: loguru>=0.7.3,<1.0
|
|
21
|
+
Requires-Dist: mfusepy>=3.1.1,<4.0
|
|
22
|
+
Requires-Dist: numpy>=2.4.6,<3.0
|
|
23
|
+
Requires-Dist: pandas>=3.0.3,<4.0
|
|
24
|
+
Requires-Dist: protobuf>=7.35.0,<8.0
|
|
25
|
+
Requires-Dist: python-magic>=0.4.27,<1.0
|
|
26
|
+
Requires-Dist: tqdm>=4.67.3,<5.0
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# tboardfs
|
|
31
|
+
|
|
32
|
+
Mount and inspect TensorBoard event logs as ordinary files.
|
|
33
|
+
|
|
34
|
+
`tboardfs` has two access modes:
|
|
35
|
+
|
|
36
|
+
- Filesystem mode mounts a log directory with FUSE.
|
|
37
|
+
- Command mode inspects or copies the virtual content of one event file.
|
|
38
|
+
|
|
39
|
+
Both modes use the same virtual paths for TensorBoard tabs such as `scalars`,
|
|
40
|
+
`images`, `tensors`, `meshes`, `pr_curves`, `hparams`, and `custom_scalars`.
|
|
41
|
+
|
|
42
|
+
## Filesystem Mode
|
|
43
|
+
|
|
44
|
+
Mount a TensorBoard log directory:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
tboardfs SOURCE MOUNTPOINT
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Example:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
tboardfs runs/experiment-1 mnt/tboardfs
|
|
54
|
+
ls mnt/tboardfs
|
|
55
|
+
cat mnt/tboardfs/train/scalars/loss.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Mount mode is the primary workflow for browsing full log directories. It exposes
|
|
59
|
+
run directories, FUSE cache-control files, and supported sidecars such as
|
|
60
|
+
projector/profile files.
|
|
61
|
+
|
|
62
|
+
## Command Mode
|
|
63
|
+
|
|
64
|
+
Use `tboardfs-file` when mounting is unavailable or when you need scripted
|
|
65
|
+
access to one TensorBoard event file.
|
|
66
|
+
|
|
67
|
+
List every virtual file:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
tboardfs-file list events.out.tfevents.123
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
List files below a virtual path:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
tboardfs-file list events.out.tfevents.123 /meshes
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Extract one virtual file to stdout:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
tboardfs-file get events.out.tfevents.123 /scalars/loss.json -o -
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Extract one virtual file to disk:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
tboardfs-file get events.out.tfevents.123 /images/sample/000001.png -o sample.png
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The virtual path may be written with or without the leading `/`. If `-o` points
|
|
92
|
+
to an existing directory, or to a missing path ending in `/`, `get` writes the
|
|
93
|
+
virtual file basename inside that directory.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
tboardfs-file get events.out.tfevents.123 scalars/loss.json -o exported/
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Copy the full virtual tree:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
tboardfs-file copy-all events.out.tfevents.123 exported-event
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Command mode exposes tab directories directly at the root, for example
|
|
106
|
+
`/scalars`, `/images`, and `/meshes`. It accepts a single event file, omits FUSE
|
|
107
|
+
control files, and does not include sibling sidecars.
|
|
108
|
+
|
|
109
|
+
`get` refuses to overwrite existing files unless `--force` is provided.
|
|
110
|
+
`copy-all` copies files in deterministic virtual-path order. If it reaches an
|
|
111
|
+
existing target without `--force`, it stops, reports how many files were already
|
|
112
|
+
copied, lists those virtual paths, prints the conflicting output path, and
|
|
113
|
+
suggests `--force`. After a successful copy, `copy-all` reports the number of
|
|
114
|
+
copied files.
|
|
115
|
+
|
|
116
|
+
Use `--skip-existing` to leave existing output files untouched and continue
|
|
117
|
+
copying the rest of the tree:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
tboardfs-file copy-all events.out.tfevents.123 exported-event --skip-existing
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Each skipped virtual path is reported as a warning on stderr. `--force` and
|
|
124
|
+
`--skip-existing` are mutually exclusive.
|
|
125
|
+
|
|
126
|
+
## Supported Objects
|
|
127
|
+
|
|
128
|
+
The virtual tree covers these TensorBoard objects:
|
|
129
|
+
|
|
130
|
+
- Scalars: full-series `json`, `tsv`, and `npz` exports under `/scalars`.
|
|
131
|
+
- Custom scalars: layout JSON under `/custom_scalars`.
|
|
132
|
+
- Images: encoded image files under `/images`.
|
|
133
|
+
- Audio: encoded audio files under `/audio`.
|
|
134
|
+
- Videos: encoded video/GIF outputs under `/videos`, including raw subpaths
|
|
135
|
+
when present.
|
|
136
|
+
- Histograms: per-step `json`, `tsv`, and `npz` exports under `/histograms`.
|
|
137
|
+
- Distributions: per-step distribution tables under `/distributions`.
|
|
138
|
+
- Text summaries: UTF-8 text files under `/text`.
|
|
139
|
+
- Meshes: per-step `json`, `npz`, and Wavefront `obj` exports under `/meshes`.
|
|
140
|
+
- PR curves: per-step `json`, `tsv`, and `npy` exports under `/pr_curves`.
|
|
141
|
+
- HParams: merged experiment/session/metric JSON under `/hparams`.
|
|
142
|
+
- Tensors: tensor arrays as `npy` plus compact JSON or native blob files under
|
|
143
|
+
`/tensors`.
|
|
144
|
+
- Graphs: graph protobuf files under `/graphs`.
|
|
145
|
+
- Projector and profile sidecars: available in filesystem mode under
|
|
146
|
+
`/projector` and `/profile`; command mode intentionally omits sibling
|
|
147
|
+
sidecar files because it operates on one event file.
|
|
148
|
+
- Other plugin JSON payloads: exposed under `/plugins` when no typed tab handles
|
|
149
|
+
them.
|
|
150
|
+
|
|
151
|
+
## Output Rules
|
|
152
|
+
|
|
153
|
+
`tboardfs-file list` prints virtual file paths to stdout, one per line.
|
|
154
|
+
`tboardfs-file get -o -` writes raw bytes to stdout. Extraction status,
|
|
155
|
+
warnings, errors, copied-file counts, skipped-path warnings, copied-path
|
|
156
|
+
conflict reports, and overwrite hints are written to stderr through Loguru/Click
|
|
157
|
+
so stdout remains safe for pipelines.
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT
|
tboardfs-0.2.0/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# tboardfs
|
|
2
|
+
|
|
3
|
+
Mount and inspect TensorBoard event logs as ordinary files.
|
|
4
|
+
|
|
5
|
+
`tboardfs` has two access modes:
|
|
6
|
+
|
|
7
|
+
- Filesystem mode mounts a log directory with FUSE.
|
|
8
|
+
- Command mode inspects or copies the virtual content of one event file.
|
|
9
|
+
|
|
10
|
+
Both modes use the same virtual paths for TensorBoard tabs such as `scalars`,
|
|
11
|
+
`images`, `tensors`, `meshes`, `pr_curves`, `hparams`, and `custom_scalars`.
|
|
12
|
+
|
|
13
|
+
## Filesystem Mode
|
|
14
|
+
|
|
15
|
+
Mount a TensorBoard log directory:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
tboardfs SOURCE MOUNTPOINT
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Example:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
tboardfs runs/experiment-1 mnt/tboardfs
|
|
25
|
+
ls mnt/tboardfs
|
|
26
|
+
cat mnt/tboardfs/train/scalars/loss.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Mount mode is the primary workflow for browsing full log directories. It exposes
|
|
30
|
+
run directories, FUSE cache-control files, and supported sidecars such as
|
|
31
|
+
projector/profile files.
|
|
32
|
+
|
|
33
|
+
## Command Mode
|
|
34
|
+
|
|
35
|
+
Use `tboardfs-file` when mounting is unavailable or when you need scripted
|
|
36
|
+
access to one TensorBoard event file.
|
|
37
|
+
|
|
38
|
+
List every virtual file:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
tboardfs-file list events.out.tfevents.123
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
List files below a virtual path:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
tboardfs-file list events.out.tfevents.123 /meshes
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Extract one virtual file to stdout:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
tboardfs-file get events.out.tfevents.123 /scalars/loss.json -o -
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Extract one virtual file to disk:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
tboardfs-file get events.out.tfevents.123 /images/sample/000001.png -o sample.png
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The virtual path may be written with or without the leading `/`. If `-o` points
|
|
63
|
+
to an existing directory, or to a missing path ending in `/`, `get` writes the
|
|
64
|
+
virtual file basename inside that directory.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
tboardfs-file get events.out.tfevents.123 scalars/loss.json -o exported/
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Copy the full virtual tree:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
tboardfs-file copy-all events.out.tfevents.123 exported-event
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Command mode exposes tab directories directly at the root, for example
|
|
77
|
+
`/scalars`, `/images`, and `/meshes`. It accepts a single event file, omits FUSE
|
|
78
|
+
control files, and does not include sibling sidecars.
|
|
79
|
+
|
|
80
|
+
`get` refuses to overwrite existing files unless `--force` is provided.
|
|
81
|
+
`copy-all` copies files in deterministic virtual-path order. If it reaches an
|
|
82
|
+
existing target without `--force`, it stops, reports how many files were already
|
|
83
|
+
copied, lists those virtual paths, prints the conflicting output path, and
|
|
84
|
+
suggests `--force`. After a successful copy, `copy-all` reports the number of
|
|
85
|
+
copied files.
|
|
86
|
+
|
|
87
|
+
Use `--skip-existing` to leave existing output files untouched and continue
|
|
88
|
+
copying the rest of the tree:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
tboardfs-file copy-all events.out.tfevents.123 exported-event --skip-existing
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Each skipped virtual path is reported as a warning on stderr. `--force` and
|
|
95
|
+
`--skip-existing` are mutually exclusive.
|
|
96
|
+
|
|
97
|
+
## Supported Objects
|
|
98
|
+
|
|
99
|
+
The virtual tree covers these TensorBoard objects:
|
|
100
|
+
|
|
101
|
+
- Scalars: full-series `json`, `tsv`, and `npz` exports under `/scalars`.
|
|
102
|
+
- Custom scalars: layout JSON under `/custom_scalars`.
|
|
103
|
+
- Images: encoded image files under `/images`.
|
|
104
|
+
- Audio: encoded audio files under `/audio`.
|
|
105
|
+
- Videos: encoded video/GIF outputs under `/videos`, including raw subpaths
|
|
106
|
+
when present.
|
|
107
|
+
- Histograms: per-step `json`, `tsv`, and `npz` exports under `/histograms`.
|
|
108
|
+
- Distributions: per-step distribution tables under `/distributions`.
|
|
109
|
+
- Text summaries: UTF-8 text files under `/text`.
|
|
110
|
+
- Meshes: per-step `json`, `npz`, and Wavefront `obj` exports under `/meshes`.
|
|
111
|
+
- PR curves: per-step `json`, `tsv`, and `npy` exports under `/pr_curves`.
|
|
112
|
+
- HParams: merged experiment/session/metric JSON under `/hparams`.
|
|
113
|
+
- Tensors: tensor arrays as `npy` plus compact JSON or native blob files under
|
|
114
|
+
`/tensors`.
|
|
115
|
+
- Graphs: graph protobuf files under `/graphs`.
|
|
116
|
+
- Projector and profile sidecars: available in filesystem mode under
|
|
117
|
+
`/projector` and `/profile`; command mode intentionally omits sibling
|
|
118
|
+
sidecar files because it operates on one event file.
|
|
119
|
+
- Other plugin JSON payloads: exposed under `/plugins` when no typed tab handles
|
|
120
|
+
them.
|
|
121
|
+
|
|
122
|
+
## Output Rules
|
|
123
|
+
|
|
124
|
+
`tboardfs-file list` prints virtual file paths to stdout, one per line.
|
|
125
|
+
`tboardfs-file get -o -` writes raw bytes to stdout. Extraction status,
|
|
126
|
+
warnings, errors, copied-file counts, skipped-path warnings, copied-path
|
|
127
|
+
conflict reports, and overwrite hints are written to stderr through Loguru/Click
|
|
128
|
+
so stdout remains safe for pipelines.
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
MIT
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tboardfs"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Read TensorBoard event logs as files through a FUSE filesystem."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "David Völgyes", email = "dvolgyes@deepconv.ai" }
|
|
8
|
+
]
|
|
9
|
+
license = "MIT"
|
|
10
|
+
license-files = ["LICENSE"]
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
keywords = ["fuse", "tensorboard", "filesystem", "machine-learning"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
"Topic :: System :: Filesystems",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"click>=8.4.1,<9.0",
|
|
26
|
+
"loguru>=0.7.3,<1.0",
|
|
27
|
+
"mfusepy>=3.1.1,<4.0",
|
|
28
|
+
"numpy>=2.4.6,<3.0",
|
|
29
|
+
"pandas>=3.0.3,<4.0",
|
|
30
|
+
"protobuf>=7.35.0,<8.0",
|
|
31
|
+
"python-magic>=0.4.27,<1.0",
|
|
32
|
+
"tqdm>=4.67.3,<5.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
tboardfs = "tboardfs:main"
|
|
37
|
+
tboardfs-file = "tboardfs.file_cli:main"
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["uv_build>=0.11.18,<0.12.0"]
|
|
41
|
+
build-backend = "uv_build"
|
|
42
|
+
[tool.uv.build-backend]
|
|
43
|
+
module-name = "tboardfs"
|
|
44
|
+
module-root = ""
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
dev = [
|
|
48
|
+
"coverage>=7.14.1,<8.0",
|
|
49
|
+
"imageio>=2.37.3,<3.0",
|
|
50
|
+
"matplotlib>=3.10.9,<4.0",
|
|
51
|
+
"moviepy>=2.2.1,<3.0",
|
|
52
|
+
"onnx>=1.21.0,<2.0",
|
|
53
|
+
"onnxruntime>=1.26.0,<2.0",
|
|
54
|
+
"pillow>=11.3.0,<13",
|
|
55
|
+
"pytest>=9.0.3,<10.0",
|
|
56
|
+
"pytest-cov>=7.1.0,<8.0",
|
|
57
|
+
"pytest-xdist>=3.8.0,<4.0",
|
|
58
|
+
"soundfile>=0.13.1,<1.0",
|
|
59
|
+
"tensorboard>=2.20.0,<3.0",
|
|
60
|
+
"tensorboardx>=2.6.5,<3.0",
|
|
61
|
+
"torch>=2.12.0,<3.0",
|
|
62
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from tboardfs.cli import main
|
|
2
|
+
from tboardfs.constants import FIXED_TABS
|
|
3
|
+
from tboardfs.filesystem import TensorBoardFS
|
|
4
|
+
from tboardfs.indexer import parse_file
|
|
5
|
+
from tboardfs.paths import find_tensorboard_files
|
|
6
|
+
|
|
7
|
+
__all__ = (
|
|
8
|
+
"FIXED_TABS",
|
|
9
|
+
"TensorBoardFS",
|
|
10
|
+
"find_tensorboard_files",
|
|
11
|
+
"main",
|
|
12
|
+
"parse_file",
|
|
13
|
+
)
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import struct
|
|
2
|
+
from typing import Any
|
|
3
|
+
|
|
4
|
+
import magic
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from tboardfs.constants import LARGE_TENSOR_THRESHOLD
|
|
8
|
+
from tboardfs.decode import _Decode
|
|
9
|
+
from tboardfs.model import Scalar
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def detect_extension(blob: bytes | None, kind: str) -> str:
|
|
13
|
+
"""Infer a stable file extension from encoded summary bytes."""
|
|
14
|
+
if not blob:
|
|
15
|
+
return "bin"
|
|
16
|
+
extension = _Classifier.extension_from_magic(blob)
|
|
17
|
+
if extension is not None:
|
|
18
|
+
return extension
|
|
19
|
+
extension = _Classifier.extension_from_signature(blob)
|
|
20
|
+
if extension is not None:
|
|
21
|
+
return extension
|
|
22
|
+
del kind
|
|
23
|
+
return "bin"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _Classifier:
|
|
27
|
+
"""Stateless helpers for classifying parsed TensorBoard summary values."""
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def scalar_value(value: dict[str, Any]) -> Scalar | None:
|
|
31
|
+
"""Return a scalar value from a scalar-shaped summary record."""
|
|
32
|
+
if "simple_value" in value:
|
|
33
|
+
return Scalar(value["simple_value"], np.dtype("float32"))
|
|
34
|
+
|
|
35
|
+
tensor = value.get("tensor")
|
|
36
|
+
if not tensor:
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
dtype = tensor.get("dtype")
|
|
40
|
+
values = tensor.get("values", {})
|
|
41
|
+
content = tensor.get("tensor_content")
|
|
42
|
+
if content:
|
|
43
|
+
scalar = _Classifier.tensor_content_scalar(dtype, content)
|
|
44
|
+
if scalar is not None:
|
|
45
|
+
return scalar
|
|
46
|
+
|
|
47
|
+
if dtype == 1 and values.get(5):
|
|
48
|
+
return Scalar(values[5][0], np.dtype("float32"))
|
|
49
|
+
if dtype == 2 and values.get(6):
|
|
50
|
+
return Scalar(values[6][0], np.dtype("float64"))
|
|
51
|
+
if dtype == 3 and values.get(7):
|
|
52
|
+
return Scalar(_Decode.signed_int32(values[7][0]), np.dtype("int32"))
|
|
53
|
+
if dtype == 9 and values.get(10):
|
|
54
|
+
return Scalar(_Decode.signed_int64(values[10][0]), np.dtype("int64"))
|
|
55
|
+
if dtype == 10 and values.get(11):
|
|
56
|
+
return Scalar(values[11][0], np.dtype("bool"))
|
|
57
|
+
if dtype == 22 and values.get(16):
|
|
58
|
+
return Scalar(values[16][0], np.dtype("uint32"))
|
|
59
|
+
if dtype == 23 and values.get(17):
|
|
60
|
+
return Scalar(values[17][0], np.dtype("uint64"))
|
|
61
|
+
return None
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def tensor_content_scalar(dtype: int | None, content: bytes) -> Scalar | None:
|
|
65
|
+
"""Return a scalar from fixed-width tensor content when supported."""
|
|
66
|
+
specs = {
|
|
67
|
+
1: ("<f", np.dtype("float32")),
|
|
68
|
+
2: ("<d", np.dtype("float64")),
|
|
69
|
+
3: ("<i", np.dtype("int32")),
|
|
70
|
+
9: ("<q", np.dtype("int64")),
|
|
71
|
+
10: ("<?", np.dtype("bool")),
|
|
72
|
+
22: ("<I", np.dtype("uint32")),
|
|
73
|
+
23: ("<Q", np.dtype("uint64")),
|
|
74
|
+
}
|
|
75
|
+
if dtype is None:
|
|
76
|
+
return None
|
|
77
|
+
spec = specs.get(dtype)
|
|
78
|
+
if spec is None:
|
|
79
|
+
return None
|
|
80
|
+
|
|
81
|
+
fmt, np_dtype = spec
|
|
82
|
+
if len(content) != struct.calcsize(fmt):
|
|
83
|
+
return None
|
|
84
|
+
return Scalar(struct.unpack(fmt, content)[0], np_dtype)
|
|
85
|
+
|
|
86
|
+
@staticmethod
|
|
87
|
+
def binary_kind(value: dict[str, Any]) -> str | None:
|
|
88
|
+
"""Classify summary values whose raw bytes should be exposed as files."""
|
|
89
|
+
image_blob = value.get("image", {}).get("encoded_image_string")
|
|
90
|
+
if image_blob and bytes(image_blob).startswith((b"GIF87a", b"GIF89a")):
|
|
91
|
+
return "videos"
|
|
92
|
+
if image_blob:
|
|
93
|
+
return "images"
|
|
94
|
+
if value.get("audio", {}).get("encoded_audio_string"):
|
|
95
|
+
return "audio"
|
|
96
|
+
|
|
97
|
+
plugin_name = (value.get("plugin_name") or "").lower()
|
|
98
|
+
if plugin_name in {"video", "videos"}:
|
|
99
|
+
return "videos"
|
|
100
|
+
|
|
101
|
+
tensor = value.get("tensor")
|
|
102
|
+
if tensor and _Classifier.large_tensor_like(tensor):
|
|
103
|
+
return "tensors"
|
|
104
|
+
return None
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def large_tensor_like(tensor: dict[str, Any]) -> bool:
|
|
108
|
+
"""Return true for tensor values large enough to expose as blobs."""
|
|
109
|
+
tensor_content = tensor.get("tensor_content")
|
|
110
|
+
if tensor_content and len(tensor_content) >= LARGE_TENSOR_THRESHOLD:
|
|
111
|
+
return True
|
|
112
|
+
return any(
|
|
113
|
+
len(item) >= LARGE_TENSOR_THRESHOLD for item in tensor.get("string_val", [])
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
@staticmethod
|
|
117
|
+
def binary_blob(value: dict[str, Any]) -> bytes | None:
|
|
118
|
+
"""Return raw payload bytes from a binary summary value."""
|
|
119
|
+
if value.get("image", {}).get("encoded_image_string"):
|
|
120
|
+
return bytes(value["image"]["encoded_image_string"])
|
|
121
|
+
if value.get("audio", {}).get("encoded_audio_string"):
|
|
122
|
+
return bytes(value["audio"]["encoded_audio_string"])
|
|
123
|
+
tensor = value.get("tensor") or {}
|
|
124
|
+
if tensor.get("tensor_content"):
|
|
125
|
+
return bytes(tensor["tensor_content"])
|
|
126
|
+
if tensor.get("string_val"):
|
|
127
|
+
return bytes(tensor["string_val"][0])
|
|
128
|
+
return None
|
|
129
|
+
|
|
130
|
+
@staticmethod
|
|
131
|
+
def plugin_json_payload(value: dict[str, Any]) -> dict[str, Any] | None:
|
|
132
|
+
"""Return JSON-safe plugin metadata for known TensorBoard plugin records."""
|
|
133
|
+
plugin_name = value.get("plugin_name")
|
|
134
|
+
if not plugin_name:
|
|
135
|
+
tensor = value.get("tensor") or {}
|
|
136
|
+
if tensor.get("dtype") == 7 and tensor.get("string_val"):
|
|
137
|
+
plugin_name = "text"
|
|
138
|
+
else:
|
|
139
|
+
return None
|
|
140
|
+
if str(plugin_name).lower() in {"video", "videos"} and _Classifier.binary_blob(
|
|
141
|
+
value
|
|
142
|
+
):
|
|
143
|
+
return None
|
|
144
|
+
payload = {"plugin_name": plugin_name, "tag": value.get("tag")}
|
|
145
|
+
if value.get("plugin_content"):
|
|
146
|
+
payload["plugin_content"] = value["plugin_content"]
|
|
147
|
+
tensor = value.get("tensor")
|
|
148
|
+
if tensor:
|
|
149
|
+
payload["tensor"] = tensor
|
|
150
|
+
return payload
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def json_tensor(tensor: dict[str, Any]) -> dict[str, Any]:
|
|
154
|
+
"""Return a JSON-friendly view of TensorProto fields."""
|
|
155
|
+
out = dict(tensor)
|
|
156
|
+
if "values" in out:
|
|
157
|
+
out["values"] = {str(key): value for key, value in out["values"].items()}
|
|
158
|
+
if "tensor_content" in out:
|
|
159
|
+
out["tensor_content"] = {"bytes": len(out["tensor_content"])}
|
|
160
|
+
if "string_val" in out:
|
|
161
|
+
out["string_val"] = [_Decode.text(value) for value in out["string_val"]]
|
|
162
|
+
return out
|
|
163
|
+
|
|
164
|
+
@staticmethod
|
|
165
|
+
def extension_from_magic(blob: bytes) -> str | None:
|
|
166
|
+
"""Return a native extension when libmagic recognizes the payload."""
|
|
167
|
+
mime = magic.from_buffer(blob, mime=True).lower()
|
|
168
|
+
description = magic.from_buffer(blob).lower()
|
|
169
|
+
mime_extensions = {
|
|
170
|
+
"application/json": "json",
|
|
171
|
+
"audio/flac": "flac",
|
|
172
|
+
"audio/mpeg": "mp3",
|
|
173
|
+
"audio/ogg": "ogg",
|
|
174
|
+
"audio/wav": "wav",
|
|
175
|
+
"audio/webm": "webm",
|
|
176
|
+
"audio/x-flac": "flac",
|
|
177
|
+
"audio/x-wav": "wav",
|
|
178
|
+
"image/gif": "gif",
|
|
179
|
+
"image/jpeg": "jpg",
|
|
180
|
+
"image/png": "png",
|
|
181
|
+
"image/webp": "webp",
|
|
182
|
+
"text/plain": "txt",
|
|
183
|
+
"video/mp4": "mp4",
|
|
184
|
+
"video/ogg": "ogg",
|
|
185
|
+
"video/quicktime": "mov",
|
|
186
|
+
"video/webm": "webm",
|
|
187
|
+
"video/x-msvideo": "avi",
|
|
188
|
+
}
|
|
189
|
+
if mime in mime_extensions:
|
|
190
|
+
return mime_extensions[mime]
|
|
191
|
+
return _Classifier.extension_from_magic_description(description)
|
|
192
|
+
|
|
193
|
+
@staticmethod
|
|
194
|
+
def extension_from_magic_description(description: str) -> str | None:
|
|
195
|
+
"""Map reliable libmagic descriptions when MIME is too generic."""
|
|
196
|
+
description_extensions = (
|
|
197
|
+
("json text", "json"),
|
|
198
|
+
("png image", "png"),
|
|
199
|
+
("jpeg image", "jpg"),
|
|
200
|
+
("gif image", "gif"),
|
|
201
|
+
("riff", "wav"),
|
|
202
|
+
("wave audio", "wav"),
|
|
203
|
+
("ogg data", "ogg"),
|
|
204
|
+
("web/p image", "webp"),
|
|
205
|
+
("webm", "webm"),
|
|
206
|
+
("matroska", "webm"),
|
|
207
|
+
("iso media", "mp4"),
|
|
208
|
+
("quicktime", "mov"),
|
|
209
|
+
("mpeg adts", "mp3"),
|
|
210
|
+
("flac audio", "flac"),
|
|
211
|
+
)
|
|
212
|
+
for needle, extension in description_extensions:
|
|
213
|
+
if needle in description:
|
|
214
|
+
return extension
|
|
215
|
+
return None
|
|
216
|
+
|
|
217
|
+
@staticmethod
|
|
218
|
+
def extension_from_signature(blob: bytes) -> str | None:
|
|
219
|
+
"""Recognize common encoded payloads when fixture bytes are very small."""
|
|
220
|
+
if blob.startswith(b"\x89PNG\r\n\x1a\n"):
|
|
221
|
+
return "png"
|
|
222
|
+
if blob.startswith(b"\xff\xd8\xff"):
|
|
223
|
+
return "jpg"
|
|
224
|
+
if blob.startswith(b"GIF87a") or blob.startswith(b"GIF89a"):
|
|
225
|
+
return "gif"
|
|
226
|
+
if blob.startswith(b"RIFF") and blob[8:12] == b"WAVE":
|
|
227
|
+
return "wav"
|
|
228
|
+
if blob.startswith(b"OggS"):
|
|
229
|
+
return "ogg"
|
|
230
|
+
if len(blob) >= 8 and blob[4:8] == b"ftyp":
|
|
231
|
+
return "mp4"
|
|
232
|
+
return None
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
import sys
|
|
3
|
+
from typing import cast
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
from loguru import logger
|
|
7
|
+
from mfusepy import FUSE, Operations
|
|
8
|
+
|
|
9
|
+
from tboardfs.filesystem import TensorBoardFS
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.command()
|
|
13
|
+
@click.argument("source", type=click.Path(exists=True, file_okay=False))
|
|
14
|
+
@click.argument("mountpoint", type=click.Path(file_okay=False))
|
|
15
|
+
@click.option("--step-digits", type=int, default=6, show_default=True)
|
|
16
|
+
@click.option("--refresh-age-seconds", type=float, default=60.0, show_default=True)
|
|
17
|
+
@click.option("--scalar-format", default="json,tsv,npz", show_default=True)
|
|
18
|
+
@click.option("--foreground/--background", default=True, show_default=True)
|
|
19
|
+
@click.option("--logfile", type=click.Path(dir_okay=False))
|
|
20
|
+
@click.option("--loglevel", default="INFO", show_default=True)
|
|
21
|
+
def main(
|
|
22
|
+
**params: object,
|
|
23
|
+
) -> None:
|
|
24
|
+
"""Mount TensorBoard logs as a read-only virtual filesystem."""
|
|
25
|
+
source_path = Path(cast(str, params["source"]))
|
|
26
|
+
mountpoint_path = Path(cast(str, params["mountpoint"]))
|
|
27
|
+
logfile = cast(str | None, params["logfile"])
|
|
28
|
+
logfile_path = Path(logfile) if logfile is not None else None
|
|
29
|
+
loglevel = cast(str, params["loglevel"])
|
|
30
|
+
foreground = cast(bool, params["foreground"])
|
|
31
|
+
_configure_logging(logfile_path, loglevel, foreground)
|
|
32
|
+
logger.info("mounting {} at {}", source_path, mountpoint_path)
|
|
33
|
+
|
|
34
|
+
class MountedTensorBoardFS(TensorBoardFS, Operations): # type: ignore[misc]
|
|
35
|
+
"""Concrete mfusepy operations class."""
|
|
36
|
+
|
|
37
|
+
filesystem = MountedTensorBoardFS(
|
|
38
|
+
source_path,
|
|
39
|
+
step_digits=cast(int, params["step_digits"]),
|
|
40
|
+
refresh_age_seconds=cast(float, params["refresh_age_seconds"]),
|
|
41
|
+
scalar_formats=cast(str, params["scalar_format"]),
|
|
42
|
+
log_to_screen=foreground,
|
|
43
|
+
)
|
|
44
|
+
FUSE(filesystem, str(mountpoint_path), foreground=foreground, ro=True)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _configure_logging(logfile: Path | None, loglevel: str, foreground: bool) -> None:
|
|
48
|
+
"""Configure loguru output for the CLI."""
|
|
49
|
+
logger.remove()
|
|
50
|
+
if foreground:
|
|
51
|
+
logger.add(
|
|
52
|
+
sys.stderr, level=loglevel.upper(), format="<level>{message}</level>"
|
|
53
|
+
)
|
|
54
|
+
if logfile is not None:
|
|
55
|
+
logger.add(logfile, level=loglevel.upper())
|