modeleon 0.1.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.
- modeleon/__init__.py +7 -0
- modeleon/plugins.py +65 -0
- modeleon-0.1.0.dist-info/METADATA +13 -0
- modeleon-0.1.0.dist-info/RECORD +5 -0
- modeleon-0.1.0.dist-info/WHEEL +4 -0
modeleon/__init__.py
ADDED
modeleon/plugins.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Plugin extension registry for modeleon.
|
|
2
|
+
|
|
3
|
+
Pro and other extensions register capabilities here via Python entry points.
|
|
4
|
+
Users always write `from modeleon import Model` — pro features appear automatically
|
|
5
|
+
when modeleon-pro is installed.
|
|
6
|
+
|
|
7
|
+
See ADR-006 for the design rationale.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import importlib.metadata
|
|
13
|
+
import logging
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
_registry: dict[str, Any] = {
|
|
19
|
+
# Extra kwargs accepted by Variable (e.g., control=, access=, style=)
|
|
20
|
+
"variable_kwargs": {},
|
|
21
|
+
# Additional compiler passes (run after core compilation)
|
|
22
|
+
"compiler_passes": [],
|
|
23
|
+
# Additional node validators (run on graph validation)
|
|
24
|
+
"node_validators": [],
|
|
25
|
+
# Track which plugins have loaded
|
|
26
|
+
"_loaded": [],
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_plugins_loaded = False
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def get_registry() -> dict[str, Any]:
|
|
33
|
+
"""Return the plugin registry. Read-only access for inspection and tests."""
|
|
34
|
+
return _registry
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load_plugins() -> None:
|
|
38
|
+
"""Discover and load all installed plugins from the 'modeleon.plugins' entry point group.
|
|
39
|
+
|
|
40
|
+
Called once on engine import. Safe to call multiple times (idempotent).
|
|
41
|
+
"""
|
|
42
|
+
global _plugins_loaded
|
|
43
|
+
if _plugins_loaded:
|
|
44
|
+
return
|
|
45
|
+
_plugins_loaded = True
|
|
46
|
+
|
|
47
|
+
eps = importlib.metadata.entry_points(group="modeleon.plugins")
|
|
48
|
+
for ep in eps:
|
|
49
|
+
try:
|
|
50
|
+
plugin_module = ep.load()
|
|
51
|
+
plugin_module.register(_registry)
|
|
52
|
+
_registry["_loaded"].append(ep.name)
|
|
53
|
+
logger.debug("Loaded plugin: %s", ep.name)
|
|
54
|
+
except Exception:
|
|
55
|
+
logger.warning("Failed to load plugin: %s", ep.name, exc_info=True)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def reset_registry() -> None:
|
|
59
|
+
"""Reset the registry to its initial state. For testing only."""
|
|
60
|
+
global _plugins_loaded
|
|
61
|
+
_registry["variable_kwargs"].clear()
|
|
62
|
+
_registry["compiler_passes"].clear()
|
|
63
|
+
_registry["node_validators"].clear()
|
|
64
|
+
_registry["_loaded"].clear()
|
|
65
|
+
_plugins_loaded = False
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modeleon
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Financial Model Engineering — Python code compiles to live Excel formulas
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: openpyxl>=3.1
|
|
8
|
+
Requires-Dist: pydantic>=2.0
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: hypothesis>=6.0; extra == 'dev'
|
|
11
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
12
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
13
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
modeleon/__init__.py,sha256=PlFs8TQA2_HmXkJygej-Gc8rMEXc2xwI9pE9eEHVebA,193
|
|
2
|
+
modeleon/plugins.py,sha256=AfH3ia1u0kVmFd01xfPWm68GTrPiN0SUSwfY7M6gB7E,1963
|
|
3
|
+
modeleon-0.1.0.dist-info/METADATA,sha256=0H3vKbkE-549xyNH4j7Y4RcspWFJhifaeR_sPhdDS5w,432
|
|
4
|
+
modeleon-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
5
|
+
modeleon-0.1.0.dist-info/RECORD,,
|