tnfr 6.0.0__py3-none-any.whl → 7.0.0__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.

Potentially problematic release.


This version of tnfr might be problematic. Click here for more details.

Files changed (176) hide show
  1. tnfr/__init__.py +50 -5
  2. tnfr/__init__.pyi +0 -7
  3. tnfr/_compat.py +0 -1
  4. tnfr/_generated_version.py +34 -0
  5. tnfr/_version.py +44 -2
  6. tnfr/alias.py +14 -13
  7. tnfr/alias.pyi +5 -37
  8. tnfr/cache.py +9 -729
  9. tnfr/cache.pyi +8 -224
  10. tnfr/callback_utils.py +16 -31
  11. tnfr/callback_utils.pyi +3 -29
  12. tnfr/cli/__init__.py +17 -11
  13. tnfr/cli/__init__.pyi +0 -21
  14. tnfr/cli/arguments.py +175 -14
  15. tnfr/cli/arguments.pyi +5 -11
  16. tnfr/cli/execution.py +434 -48
  17. tnfr/cli/execution.pyi +14 -24
  18. tnfr/cli/utils.py +20 -3
  19. tnfr/cli/utils.pyi +5 -5
  20. tnfr/config/__init__.py +2 -1
  21. tnfr/config/__init__.pyi +2 -0
  22. tnfr/config/feature_flags.py +83 -0
  23. tnfr/config/init.py +1 -1
  24. tnfr/config/operator_names.py +1 -14
  25. tnfr/config/presets.py +6 -26
  26. tnfr/constants/__init__.py +10 -13
  27. tnfr/constants/__init__.pyi +10 -22
  28. tnfr/constants/aliases.py +31 -0
  29. tnfr/constants/core.py +4 -3
  30. tnfr/constants/init.py +1 -1
  31. tnfr/constants/metric.py +3 -3
  32. tnfr/dynamics/__init__.py +64 -10
  33. tnfr/dynamics/__init__.pyi +3 -4
  34. tnfr/dynamics/adaptation.py +79 -13
  35. tnfr/dynamics/aliases.py +10 -9
  36. tnfr/dynamics/coordination.py +77 -35
  37. tnfr/dynamics/dnfr.py +575 -274
  38. tnfr/dynamics/dnfr.pyi +1 -10
  39. tnfr/dynamics/integrators.py +47 -33
  40. tnfr/dynamics/integrators.pyi +0 -1
  41. tnfr/dynamics/runtime.py +489 -129
  42. tnfr/dynamics/sampling.py +2 -0
  43. tnfr/dynamics/selectors.py +101 -62
  44. tnfr/execution.py +15 -8
  45. tnfr/execution.pyi +5 -25
  46. tnfr/flatten.py +7 -3
  47. tnfr/flatten.pyi +1 -8
  48. tnfr/gamma.py +22 -26
  49. tnfr/gamma.pyi +0 -6
  50. tnfr/glyph_history.py +37 -26
  51. tnfr/glyph_history.pyi +1 -19
  52. tnfr/glyph_runtime.py +16 -0
  53. tnfr/glyph_runtime.pyi +9 -0
  54. tnfr/immutable.py +20 -15
  55. tnfr/immutable.pyi +4 -7
  56. tnfr/initialization.py +5 -7
  57. tnfr/initialization.pyi +1 -9
  58. tnfr/io.py +6 -305
  59. tnfr/io.pyi +13 -8
  60. tnfr/mathematics/__init__.py +81 -0
  61. tnfr/mathematics/backend.py +426 -0
  62. tnfr/mathematics/dynamics.py +398 -0
  63. tnfr/mathematics/epi.py +254 -0
  64. tnfr/mathematics/generators.py +222 -0
  65. tnfr/mathematics/metrics.py +119 -0
  66. tnfr/mathematics/operators.py +233 -0
  67. tnfr/mathematics/operators_factory.py +71 -0
  68. tnfr/mathematics/projection.py +78 -0
  69. tnfr/mathematics/runtime.py +173 -0
  70. tnfr/mathematics/spaces.py +247 -0
  71. tnfr/mathematics/transforms.py +292 -0
  72. tnfr/metrics/__init__.py +10 -10
  73. tnfr/metrics/coherence.py +123 -94
  74. tnfr/metrics/common.py +22 -13
  75. tnfr/metrics/common.pyi +42 -11
  76. tnfr/metrics/core.py +72 -14
  77. tnfr/metrics/diagnosis.py +48 -57
  78. tnfr/metrics/diagnosis.pyi +3 -7
  79. tnfr/metrics/export.py +3 -5
  80. tnfr/metrics/glyph_timing.py +41 -31
  81. tnfr/metrics/reporting.py +13 -6
  82. tnfr/metrics/sense_index.py +884 -114
  83. tnfr/metrics/trig.py +167 -11
  84. tnfr/metrics/trig.pyi +1 -0
  85. tnfr/metrics/trig_cache.py +112 -15
  86. tnfr/node.py +400 -17
  87. tnfr/node.pyi +55 -38
  88. tnfr/observers.py +111 -8
  89. tnfr/observers.pyi +0 -15
  90. tnfr/ontosim.py +9 -6
  91. tnfr/ontosim.pyi +0 -5
  92. tnfr/operators/__init__.py +529 -42
  93. tnfr/operators/__init__.pyi +14 -0
  94. tnfr/operators/definitions.py +350 -18
  95. tnfr/operators/definitions.pyi +0 -14
  96. tnfr/operators/grammar.py +760 -0
  97. tnfr/operators/jitter.py +28 -22
  98. tnfr/operators/registry.py +7 -12
  99. tnfr/operators/registry.pyi +0 -2
  100. tnfr/operators/remesh.py +38 -61
  101. tnfr/rng.py +17 -300
  102. tnfr/schemas/__init__.py +8 -0
  103. tnfr/schemas/grammar.json +94 -0
  104. tnfr/selector.py +3 -4
  105. tnfr/selector.pyi +1 -1
  106. tnfr/sense.py +22 -24
  107. tnfr/sense.pyi +0 -7
  108. tnfr/structural.py +504 -21
  109. tnfr/structural.pyi +41 -18
  110. tnfr/telemetry/__init__.py +23 -1
  111. tnfr/telemetry/cache_metrics.py +226 -0
  112. tnfr/telemetry/nu_f.py +423 -0
  113. tnfr/telemetry/nu_f.pyi +123 -0
  114. tnfr/tokens.py +1 -4
  115. tnfr/tokens.pyi +1 -6
  116. tnfr/trace.py +20 -53
  117. tnfr/trace.pyi +9 -37
  118. tnfr/types.py +244 -15
  119. tnfr/types.pyi +200 -14
  120. tnfr/units.py +69 -0
  121. tnfr/units.pyi +16 -0
  122. tnfr/utils/__init__.py +107 -48
  123. tnfr/utils/__init__.pyi +80 -11
  124. tnfr/utils/cache.py +1705 -65
  125. tnfr/utils/cache.pyi +370 -58
  126. tnfr/utils/chunks.py +104 -0
  127. tnfr/utils/chunks.pyi +21 -0
  128. tnfr/utils/data.py +95 -5
  129. tnfr/utils/data.pyi +8 -17
  130. tnfr/utils/graph.py +2 -4
  131. tnfr/utils/init.py +31 -7
  132. tnfr/utils/init.pyi +4 -11
  133. tnfr/utils/io.py +313 -14
  134. tnfr/{helpers → utils}/numeric.py +50 -24
  135. tnfr/utils/numeric.pyi +21 -0
  136. tnfr/validation/__init__.py +92 -4
  137. tnfr/validation/__init__.pyi +77 -17
  138. tnfr/validation/compatibility.py +79 -43
  139. tnfr/validation/compatibility.pyi +4 -6
  140. tnfr/validation/grammar.py +55 -133
  141. tnfr/validation/grammar.pyi +37 -8
  142. tnfr/validation/graph.py +138 -0
  143. tnfr/validation/graph.pyi +17 -0
  144. tnfr/validation/rules.py +161 -74
  145. tnfr/validation/rules.pyi +55 -18
  146. tnfr/validation/runtime.py +263 -0
  147. tnfr/validation/runtime.pyi +31 -0
  148. tnfr/validation/soft_filters.py +170 -0
  149. tnfr/validation/soft_filters.pyi +37 -0
  150. tnfr/validation/spectral.py +159 -0
  151. tnfr/validation/spectral.pyi +46 -0
  152. tnfr/validation/syntax.py +28 -139
  153. tnfr/validation/syntax.pyi +7 -4
  154. tnfr/validation/window.py +39 -0
  155. tnfr/validation/window.pyi +1 -0
  156. tnfr/viz/__init__.py +9 -0
  157. tnfr/viz/matplotlib.py +246 -0
  158. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/METADATA +63 -19
  159. tnfr-7.0.0.dist-info/RECORD +185 -0
  160. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/licenses/LICENSE.md +1 -1
  161. tnfr/constants_glyphs.py +0 -16
  162. tnfr/constants_glyphs.pyi +0 -12
  163. tnfr/grammar.py +0 -25
  164. tnfr/grammar.pyi +0 -13
  165. tnfr/helpers/__init__.py +0 -151
  166. tnfr/helpers/__init__.pyi +0 -66
  167. tnfr/helpers/numeric.pyi +0 -12
  168. tnfr/presets.py +0 -15
  169. tnfr/presets.pyi +0 -7
  170. tnfr/utils/io.pyi +0 -10
  171. tnfr/utils/validators.py +0 -130
  172. tnfr/utils/validators.pyi +0 -19
  173. tnfr-6.0.0.dist-info/RECORD +0 -157
  174. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/WHEEL +0 -0
  175. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/entry_points.txt +0 -0
  176. {tnfr-6.0.0.dist-info → tnfr-7.0.0.dist-info}/top_level.txt +0 -0
tnfr/cache.pyi CHANGED
@@ -1,232 +1,16 @@
1
- import logging
2
- import threading
3
- from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping
4
- from dataclasses import dataclass
5
- from typing import Any, ClassVar, Generic, Hashable, TypeVar
1
+ """Compatibility stub removed; import from :mod:`tnfr.utils.cache` instead."""
6
2
 
7
- from cachetools import LRUCache
3
+ from __future__ import annotations
8
4
 
9
- from .types import TimingContext
5
+ from typing import NoReturn
10
6
 
11
- __all__ = [
12
- "CacheManager",
13
- "CacheCapacityConfig",
14
- "CacheStatistics",
15
- "InstrumentedLRUCache",
16
- "ManagedLRUCache",
17
- "prune_lock_mapping",
18
- ]
7
+ __all__ = ()
19
8
 
20
- K = TypeVar("K", bound=Hashable)
21
- V = TypeVar("V")
22
9
 
10
+ def __getattr__(name: str) -> NoReturn:
11
+ """Indicate that :mod:`tnfr.cache` no longer exports cache helpers."""
23
12
 
24
- @dataclass(frozen=True)
25
- class CacheCapacityConfig:
26
- default_capacity: int | None
27
- overrides: dict[str, int | None]
28
13
 
14
+ def __dir__() -> tuple[str, ...]:
15
+ """Return an empty set of exports to mirror the removed shim."""
29
16
 
30
- @dataclass(frozen=True)
31
- class CacheStatistics:
32
- hits: int = ...
33
- misses: int = ...
34
- evictions: int = ...
35
- total_time: float = ...
36
- timings: int = ...
37
-
38
- def merge(self, other: CacheStatistics) -> CacheStatistics: ...
39
-
40
-
41
- class CacheManager:
42
- _MISSING: ClassVar[object]
43
-
44
- def __init__(
45
- self,
46
- storage: MutableMapping[str, Any] | None = ...,
47
- *,
48
- default_capacity: int | None = ...,
49
- overrides: Mapping[str, int | None] | None = ...,
50
- ) -> None: ...
51
-
52
- @staticmethod
53
- def _normalise_capacity(value: int | None) -> int | None: ...
54
-
55
- def register(
56
- self,
57
- name: str,
58
- factory: Callable[[], Any],
59
- *,
60
- lock_factory: Callable[[], threading.Lock | threading.RLock] | None = ...,
61
- reset: Callable[[Any], Any] | None = ...,
62
- create: bool = ...,
63
- ) -> None: ...
64
-
65
- def configure(
66
- self,
67
- *,
68
- default_capacity: int | None | object = ...,
69
- overrides: Mapping[str, int | None] | None = ...,
70
- replace_overrides: bool = ...,
71
- ) -> None: ...
72
-
73
- def configure_from_mapping(self, config: Mapping[str, Any]) -> None: ...
74
-
75
- def export_config(self) -> CacheCapacityConfig: ...
76
-
77
- def get_capacity(
78
- self,
79
- name: str,
80
- *,
81
- requested: int | None = ...,
82
- fallback: int | None = ...,
83
- use_default: bool = ...,
84
- ) -> int | None: ...
85
-
86
- def has_override(self, name: str) -> bool: ...
87
-
88
- def get_lock(self, name: str) -> threading.Lock | threading.RLock: ...
89
-
90
- def names(self) -> Iterator[str]: ...
91
-
92
- def get(self, name: str, *, create: bool = ...) -> Any: ...
93
-
94
- def peek(self, name: str) -> Any: ...
95
-
96
- def store(self, name: str, value: Any) -> None: ...
97
-
98
- def update(
99
- self,
100
- name: str,
101
- updater: Callable[[Any], Any],
102
- *,
103
- create: bool = ...,
104
- ) -> Any: ...
105
-
106
- def clear(self, name: str | None = ...) -> None: ...
107
-
108
- def increment_hit(
109
- self,
110
- name: str,
111
- *,
112
- amount: int = ...,
113
- duration: float | None = ...,
114
- ) -> None: ...
115
-
116
- def increment_miss(
117
- self,
118
- name: str,
119
- *,
120
- amount: int = ...,
121
- duration: float | None = ...,
122
- ) -> None: ...
123
-
124
- def increment_eviction(self, name: str, *, amount: int = ...) -> None: ...
125
-
126
- def record_timing(self, name: str, duration: float) -> None: ...
127
-
128
- def timer(self, name: str) -> TimingContext: ...
129
-
130
- def get_metrics(self, name: str) -> CacheStatistics: ...
131
-
132
- def iter_metrics(self) -> Iterator[tuple[str, CacheStatistics]]: ...
133
-
134
- def aggregate_metrics(self) -> CacheStatistics: ...
135
-
136
- def register_metrics_publisher(
137
- self, publisher: Callable[[str, CacheStatistics], None]
138
- ) -> None: ...
139
-
140
- def publish_metrics(
141
- self,
142
- *,
143
- publisher: Callable[[str, CacheStatistics], None] | None = ...,
144
- ) -> None: ...
145
-
146
- def log_metrics(
147
- self, logger: logging.Logger, *, level: int = ...
148
- ) -> None: ...
149
-
150
-
151
- class InstrumentedLRUCache(MutableMapping[K, V], Generic[K, V]):
152
- _MISSING: ClassVar[object]
153
-
154
- def __init__(
155
- self,
156
- maxsize: int,
157
- *,
158
- manager: CacheManager | None = ...,
159
- metrics_key: str | None = ...,
160
- telemetry_callbacks: Iterable[Callable[[K, V], None]]
161
- | Callable[[K, V], None]
162
- | None = ...,
163
- eviction_callbacks: Iterable[Callable[[K, V], None]]
164
- | Callable[[K, V], None]
165
- | None = ...,
166
- locks: MutableMapping[K, Any] | None = ...,
167
- getsizeof: Callable[[V], int] | None = ...,
168
- count_overwrite_hit: bool = ...,
169
- ) -> None: ...
170
-
171
- @property
172
- def telemetry_callbacks(self) -> tuple[Callable[[K, V], None], ...]: ...
173
-
174
- @property
175
- def eviction_callbacks(self) -> tuple[Callable[[K, V], None], ...]: ...
176
-
177
- def set_telemetry_callbacks(
178
- self,
179
- callbacks: Iterable[Callable[[K, V], None]]
180
- | Callable[[K, V], None]
181
- | None,
182
- *,
183
- append: bool = ...,
184
- ) -> None: ...
185
-
186
- def set_eviction_callbacks(
187
- self,
188
- callbacks: Iterable[Callable[[K, V], None]]
189
- | Callable[[K, V], None]
190
- | None,
191
- *,
192
- append: bool = ...,
193
- ) -> None: ...
194
-
195
- def pop(self, key: K, default: Any = ...) -> V: ...
196
-
197
- def popitem(self) -> tuple[K, V]: ...
198
-
199
- def clear(self) -> None: ...
200
-
201
- @property
202
- def maxsize(self) -> int: ...
203
-
204
- @property
205
- def currsize(self) -> int: ...
206
-
207
- def get(self, key: K, default: V | None = ...) -> V | None: ...
208
-
209
-
210
- class ManagedLRUCache(LRUCache[K, V], Generic[K, V]):
211
- def __init__(
212
- self,
213
- maxsize: int,
214
- *,
215
- manager: CacheManager | None = ...,
216
- metrics_key: str | None = ...,
217
- eviction_callbacks: Iterable[Callable[[K, V], None]]
218
- | Callable[[K, V], None]
219
- | None = ...,
220
- telemetry_callbacks: Iterable[Callable[[K, V], None]]
221
- | Callable[[K, V], None]
222
- | None = ...,
223
- locks: MutableMapping[K, Any] | None = ...,
224
- ) -> None: ...
225
-
226
- def popitem(self) -> tuple[K, V]: ...
227
-
228
-
229
- def prune_lock_mapping(
230
- cache: Mapping[K, Any] | MutableMapping[K, Any] | None,
231
- locks: MutableMapping[K, Any] | None,
232
- ) -> None: ...
tnfr/callback_utils.py CHANGED
@@ -9,21 +9,20 @@ modify shared state.
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
-
13
- from typing import Any, TypedDict
14
- from enum import Enum
12
+ import threading
13
+ import traceback
15
14
  from collections import defaultdict, deque
16
- from collections.abc import Callable, Mapping, Iterable
15
+ from collections.abc import Callable, Iterable, Mapping
16
+ from enum import Enum
17
+ from typing import Any
18
+
19
+ import networkx as nx
17
20
 
18
- import traceback
19
- import threading
20
- from .utils import get_logger, is_non_string_sequence
21
21
  from .constants import DEFAULTS
22
22
  from .locking import get_lock
23
-
24
23
  from .trace import CallbackSpec
25
-
26
- import networkx as nx
24
+ from .utils import get_logger, is_non_string_sequence
25
+ from .types import CallbackError
27
26
 
28
27
  __all__ = (
29
28
  "CallbackEvent",
@@ -41,6 +40,7 @@ class CallbackEvent(str, Enum):
41
40
  BEFORE_STEP = "before_step"
42
41
  AFTER_STEP = "after_step"
43
42
  ON_REMESH = "on_remesh"
43
+ CACHE_METRICS = "cache_metrics"
44
44
 
45
45
 
46
46
  class CallbackManager:
@@ -130,9 +130,7 @@ class CallbackManager:
130
130
  cb_name = name or getattr(func, "__name__", None)
131
131
  spec = CallbackSpec(cb_name, func)
132
132
  existing_map = cbs[event]
133
- strict = bool(
134
- G.graph.get("CALLBACKS_STRICT", DEFAULTS["CALLBACKS_STRICT"])
135
- )
133
+ strict = bool(G.graph.get("CALLBACKS_STRICT", DEFAULTS["CALLBACKS_STRICT"]))
136
134
  key = _reconcile_callback(event, existing_map, spec, strict)
137
135
 
138
136
  existing_map[key] = spec
@@ -151,9 +149,7 @@ class CallbackManager:
151
149
  event = _normalize_event(event)
152
150
  with self._lock:
153
151
  cbs = dict(self._ensure_callbacks_nolock(G).get(event, {}))
154
- strict = bool(
155
- G.graph.get("CALLBACKS_STRICT", DEFAULTS["CALLBACKS_STRICT"])
156
- )
152
+ strict = bool(G.graph.get("CALLBACKS_STRICT", DEFAULTS["CALLBACKS_STRICT"]))
157
153
  if ctx is None:
158
154
  ctx = {}
159
155
  for spec in cbs.values():
@@ -184,17 +180,6 @@ Callback = Callable[["nx.Graph", dict[str, Any]], None]
184
180
  CallbackRegistry = dict[str, dict[str, "CallbackSpec"]]
185
181
 
186
182
 
187
- class CallbackError(TypedDict):
188
- """Metadata for a failed callback invocation."""
189
-
190
- event: str
191
- step: int | None
192
- error: str
193
- traceback: str
194
- fn: str
195
- name: str | None
196
-
197
-
198
183
  def _func_id(fn: Callable[..., Any]) -> str:
199
184
  """Return a deterministic identifier for ``fn``.
200
185
 
@@ -210,9 +195,7 @@ def _func_id(fn: Callable[..., Any]) -> str:
210
195
  return f"{module}.{qualname}"
211
196
 
212
197
 
213
- def _validate_registry(
214
- G: "nx.Graph", cbs: Any, dirty: set[str]
215
- ) -> CallbackRegistry:
198
+ def _validate_registry(G: "nx.Graph", cbs: Any, dirty: set[str]) -> CallbackRegistry:
216
199
  """Validate and normalise the callback registry.
217
200
 
218
201
  ``cbs`` is coerced to a ``defaultdict(dict)`` and any events listed in
@@ -249,7 +232,9 @@ def _normalize_callbacks(entries: Any) -> dict[str, CallbackSpec]:
249
232
  """Return ``entries`` normalised into a callback mapping."""
250
233
  if isinstance(entries, Mapping):
251
234
  entries_iter = entries.values()
252
- elif isinstance(entries, Iterable) and not isinstance(entries, (str, bytes, bytearray)):
235
+ elif isinstance(entries, Iterable) and not isinstance(
236
+ entries, (str, bytes, bytearray)
237
+ ):
253
238
  entries_iter = entries
254
239
  else:
255
240
  return {}
tnfr/callback_utils.pyi CHANGED
@@ -5,13 +5,14 @@ import traceback
5
5
  from collections import defaultdict, deque
6
6
  from collections.abc import Callable, Iterable, Mapping
7
7
  from enum import Enum
8
- from typing import Any, TypedDict
8
+ from typing import Any
9
9
 
10
10
  import networkx as nx
11
11
 
12
12
  from .constants import DEFAULTS
13
13
  from .locking import get_lock
14
14
  from .trace import CallbackSpec
15
+ from .types import CallbackError
15
16
  from .utils import get_logger, is_non_string_sequence
16
17
 
17
18
  __all__ = (
@@ -23,33 +24,19 @@ __all__ = (
23
24
 
24
25
  logger: Any
25
26
 
26
-
27
27
  class CallbackEvent(str, Enum):
28
28
  BEFORE_STEP = "before_step"
29
29
  AFTER_STEP = "after_step"
30
30
  ON_REMESH = "on_remesh"
31
-
31
+ CACHE_METRICS = "cache_metrics"
32
32
 
33
33
  Callback = Callable[[nx.Graph, dict[str, Any]], None]
34
34
  CallbackRegistry = dict[str, dict[str, CallbackSpec]]
35
35
 
36
-
37
- class CallbackError(TypedDict):
38
- event: str
39
- step: int | None
40
- error: str
41
- traceback: str
42
- fn: str
43
- name: str | None
44
-
45
-
46
36
  class CallbackManager:
47
37
  def __init__(self) -> None: ...
48
-
49
38
  def get_callback_error_limit(self) -> int: ...
50
-
51
39
  def set_callback_error_limit(self, limit: int) -> int: ...
52
-
53
40
  def register_callback(
54
41
  self,
55
42
  G: nx.Graph,
@@ -58,14 +45,12 @@ class CallbackManager:
58
45
  *,
59
46
  name: str | None = ...,
60
47
  ) -> Callback: ...
61
-
62
48
  def invoke_callbacks(
63
49
  self,
64
50
  G: nx.Graph,
65
51
  event: CallbackEvent | str,
66
52
  ctx: dict[str, Any] | None = ...,
67
53
  ) -> None: ...
68
-
69
54
  def _record_callback_error(
70
55
  self,
71
56
  G: nx.Graph,
@@ -74,29 +59,18 @@ class CallbackManager:
74
59
  spec: CallbackSpec,
75
60
  err: Exception,
76
61
  ) -> None: ...
77
-
78
62
  def _ensure_callbacks_nolock(self, G: nx.Graph) -> CallbackRegistry: ...
79
-
80
63
  def _ensure_callbacks(self, G: nx.Graph) -> CallbackRegistry: ...
81
64
 
82
-
83
65
  callback_manager: CallbackManager
84
66
 
85
-
86
67
  def _func_id(fn: Callable[..., Any]) -> str: ...
87
-
88
68
  def _validate_registry(G: nx.Graph, cbs: Any, dirty: set[str]) -> CallbackRegistry: ...
89
-
90
69
  def _normalize_callbacks(entries: Any) -> dict[str, CallbackSpec]: ...
91
-
92
70
  def _normalize_event(event: CallbackEvent | str) -> str: ...
93
-
94
71
  def _is_known_event(event: str) -> bool: ...
95
-
96
72
  def _ensure_known_event(event: str) -> None: ...
97
-
98
73
  def _normalize_callback_entry(entry: Any) -> CallbackSpec | None: ...
99
-
100
74
  def _reconcile_callback(
101
75
  event: str,
102
76
  existing_map: dict[str, CallbackSpec],
tnfr/cli/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
+ """Command-line interface entry points for TNFR."""
2
+
1
3
  from __future__ import annotations
2
4
 
3
5
  import argparse
@@ -5,25 +7,27 @@ import logging
5
7
  import sys
6
8
  from typing import Optional
7
9
 
10
+ from .. import __version__
11
+ from ..utils import _configure_root, get_logger
8
12
  from .arguments import (
13
+ _add_metrics_parser,
14
+ _add_profile_parser,
15
+ _add_profile_pipeline_parser,
16
+ _add_run_parser,
17
+ _add_sequence_parser,
18
+ add_canon_toggle,
9
19
  add_common_args,
10
20
  add_grammar_args,
11
21
  add_grammar_selector_args,
12
22
  add_history_export_args,
13
- add_canon_toggle,
14
- _add_run_parser,
15
- _add_sequence_parser,
16
- _add_metrics_parser,
17
23
  )
18
24
  from .execution import (
19
- build_basic_graph,
20
25
  apply_cli_config,
26
+ build_basic_graph,
21
27
  register_callbacks_and_observer,
22
- run_program,
23
28
  resolve_program,
29
+ run_program,
24
30
  )
25
- from .. import __version__
26
- from ..utils import _configure_root, get_logger
27
31
 
28
32
  logger = get_logger(__name__)
29
33
 
@@ -43,6 +47,8 @@ __all__ = (
43
47
 
44
48
 
45
49
  def main(argv: Optional[list[str]] = None) -> int:
50
+ """Entry point for the ``tnfr`` CLI returning the exit status."""
51
+
46
52
  _configure_root()
47
53
 
48
54
  root = logging.getLogger()
@@ -69,15 +75,15 @@ def main(argv: Optional[list[str]] = None) -> int:
69
75
  p.add_argument(
70
76
  "--version",
71
77
  action="store_true",
72
- help=(
73
- "show the actual version and exit (reads pyproject.toml in development)"
74
- ),
78
+ help=("show the actual version and exit (reads pyproject.toml in development)"),
75
79
  )
76
80
  sub = p.add_subparsers(dest="cmd")
77
81
 
78
82
  _add_run_parser(sub)
79
83
  _add_sequence_parser(sub)
80
84
  _add_metrics_parser(sub)
85
+ _add_profile_parser(sub)
86
+ _add_profile_pipeline_parser(sub)
81
87
 
82
88
  args = p.parse_args(argv)
83
89
  if args.version:
tnfr/cli/__init__.pyi CHANGED
@@ -7,39 +7,18 @@ from ..types import ProgramTokens, TNFRGraph
7
7
 
8
8
  __all__: tuple[str, ...]
9
9
 
10
-
11
10
  def main(argv: Optional[list[str]] = None) -> int: ...
12
-
13
-
14
11
  def add_common_args(parser: argparse.ArgumentParser) -> None: ...
15
-
16
-
17
12
  def add_grammar_args(parser: argparse.ArgumentParser) -> None: ...
18
-
19
-
20
13
  def add_grammar_selector_args(parser: argparse.ArgumentParser) -> None: ...
21
-
22
-
23
14
  def add_history_export_args(parser: argparse.ArgumentParser) -> None: ...
24
-
25
-
26
15
  def add_canon_toggle(parser: argparse.ArgumentParser) -> None: ...
27
-
28
-
29
16
  def build_basic_graph(args: argparse.Namespace) -> TNFRGraph: ...
30
-
31
-
32
17
  def apply_cli_config(G: TNFRGraph, args: argparse.Namespace) -> None: ...
33
-
34
-
35
18
  def register_callbacks_and_observer(G: TNFRGraph) -> None: ...
36
-
37
-
38
19
  def resolve_program(
39
20
  args: argparse.Namespace, default: Optional[ProgramTokens] = None
40
21
  ) -> Optional[ProgramTokens]: ...
41
-
42
-
43
22
  def run_program(
44
23
  G: Optional[TNFRGraph],
45
24
  program: Optional[ProgramTokens],