obkit 0.0.1__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.
obkit/__init__.py ADDED
File without changes
@@ -0,0 +1,63 @@
1
+ import json
2
+ import os
3
+ import socket
4
+ import sys
5
+ from datetime import datetime, timezone
6
+
7
+ _state = {
8
+ "log_file": None,
9
+ "warned_uninit": False,
10
+ }
11
+
12
+
13
+ def init_logger(path):
14
+ if not isinstance(path, str) or not path:
15
+ raise ValueError("init_logger(): 'path' must be a non-empty string")
16
+ os.makedirs(path, exist_ok=True)
17
+ log_file = os.path.join(os.path.realpath(path), "omnibench-events.jsonl")
18
+ _state["log_file"] = log_file
19
+ _state["warned_uninit"] = False
20
+ return log_file
21
+
22
+
23
+ def _iso_ts():
24
+ now = datetime.now(timezone.utc)
25
+ return now.strftime("%Y-%m-%dT%H:%M:%S.") + f"{now.microsecond // 1000:03d}Z"
26
+
27
+
28
+ def emit(event, phase, attrs=None):
29
+ if not isinstance(event, str) or not event:
30
+ raise ValueError("emit(): 'event' must be a non-empty string")
31
+ if phase not in ("start", "end"):
32
+ raise ValueError('emit(): \'phase\' must be "start" or "end"')
33
+
34
+ log_file = _state["log_file"]
35
+ if log_file is None:
36
+ if not _state["warned_uninit"]:
37
+ print(
38
+ "obkit: emit() called before init_logger(); events discarded.",
39
+ file=sys.stderr,
40
+ )
41
+ _state["warned_uninit"] = True
42
+ return False
43
+
44
+ rec = {
45
+ "ts": _iso_ts(),
46
+ "event": event,
47
+ "phase": phase,
48
+ "pid": os.getpid(),
49
+ "host": socket.gethostname(),
50
+ }
51
+ if attrs is not None:
52
+ if not isinstance(attrs, dict):
53
+ raise ValueError("emit(): 'attrs' must be a dict")
54
+ rec["attrs"] = attrs
55
+
56
+ try:
57
+ line = json.dumps(rec, separators=(",", ":"))
58
+ with open(log_file, "a", encoding="utf-8") as f:
59
+ f.write(line + "\n")
60
+ return True
61
+ except Exception as e:
62
+ print(f"obkit: emit() write failed: {e}", file=sys.stderr)
63
+ return False
obkit/prof/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ # prof — parse and align profiling outputs (denet, Snakemake bench files)
2
+ # with logger events for per-phase resource attribution.
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: obkit
3
+ Version: 0.0.1
4
+ Summary: Utility toolkit for omnibenchmark modules and Snakemake workflows
5
+ Author: Omnibenchmark Contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Omnibenchmark Contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://omnibenchmark.org
29
+ Project-URL: Repository, https://github.com/omnibenchmark/obkit
30
+ Project-URL: Issues, https://github.com/omnibenchmark/obkit/issues
31
+ Keywords: omnibenchmark,snakemake,benchmarking,logging,profiling
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3 :: Only
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Topic :: Scientific/Engineering
45
+ Classifier: Topic :: System :: Logging
46
+ Classifier: Typing :: Typed
47
+ Requires-Python: >=3.9
48
+ Description-Content-Type: text/markdown
49
+ License-File: LICENSE
50
+ Provides-Extra: dev
51
+ Requires-Dist: pytest>=7; extra == "dev"
52
+ Requires-Dist: ruff>=0.6; extra == "dev"
53
+ Dynamic: license-file
54
+
55
+ # obkit
56
+
57
+ Utility toolkit for [omnibenchmark](https://omnibenchmark.org) modules and
58
+ Snakemake workflows. Pure stdlib, zero runtime dependencies.
59
+
60
+ The R implementation lives in the same repository under `r/obkit`.
61
+
62
+ ## Install
63
+
64
+ ```bash
65
+ pip install obkit
66
+ ```
67
+
68
+ ## Modules
69
+
70
+ | module | purpose |
71
+ |---------------|---------|
72
+ | `obkit.logger` | Structured JSONL lifecycle event logging — drop phase-boundary anchors into a log file so downstream tooling can attribute profiler samples to named phases of a rule. |
73
+ | `obkit.prof` | Parse and align profiler output (denet, Snakemake bench files) with logger events for per-phase resource attribution. *(in progress)* |
74
+
75
+ ## Usage
76
+
77
+ ```python
78
+ from obkit.logger import init_logger, emit
79
+
80
+ init_logger("/path/to/logdir")
81
+ emit("align", "start")
82
+ # ... do work ...
83
+ emit("align", "end", attrs={"reads": 12345})
84
+ ```
85
+
86
+ Events are written to `omnibench-events.jsonl` inside the directory passed to
87
+ `init_logger`. See the [wire format spec](https://github.com/omnibenchmark/obkit/blob/main/docs/spec-logger.md)
88
+ for the record schema.
89
+
90
+ ## Status
91
+
92
+ v0.1, pre-release. Wire format is stable; API may still shift.
93
+
94
+ ## License
95
+
96
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,8 @@
1
+ obkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ obkit/logger/__init__.py,sha256=9ExDkAaJJAvjyTAq61jFJTQbDPEjyz_CYo4UNoaCe3Q,1821
3
+ obkit/prof/__init__.py,sha256=4pGgvh2ADjrrTNdH413Z5TQJvbwjhnWYsfXeSUEvMXY,133
4
+ obkit-0.0.1.dist-info/licenses/LICENSE,sha256=KYG7nDC4AIYT_mPatOTcJkxehjqMy49J8EopFNTLEmo,1083
5
+ obkit-0.0.1.dist-info/METADATA,sha256=joOgvRDMSGZrHsIYFimCcRGQUy2O9VCkxnk2o4u4-7g,3770
6
+ obkit-0.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ obkit-0.0.1.dist-info/top_level.txt,sha256=V7XLMpBruFPihHCZvjhMZmcJ6A27RpM-Tbv6iyvuft4,6
8
+ obkit-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Omnibenchmark Contributors
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.
@@ -0,0 +1 @@
1
+ obkit