exonware-xwlazy 0.1.0.21__py3-none-any.whl → 0.1.0.23__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.
- exonware/__init__.py +22 -6
- exonware/xwlazy/__init__.py +14 -2
- exonware/xwlazy/common/__init__.py +8 -0
- exonware/xwlazy/common/base.py +11 -2
- exonware/xwlazy/common/cache.py +5 -5
- exonware/xwlazy/common/logger.py +5 -5
- exonware/xwlazy/common/services/dependency_mapper.py +31 -13
- exonware/xwlazy/common/services/install_async_utils.py +5 -0
- exonware/xwlazy/common/services/install_cache_utils.py +4 -4
- exonware/xwlazy/common/services/spec_cache.py +2 -2
- exonware/xwlazy/common/services/state_manager.py +4 -4
- exonware/xwlazy/common/strategies/caching_dict.py +2 -2
- exonware/xwlazy/common/strategies/caching_lfu.py +2 -2
- exonware/xwlazy/common/strategies/caching_ttl.py +2 -2
- exonware/xwlazy/common/utils.py +142 -0
- exonware/xwlazy/config.py +1 -1
- exonware/xwlazy/contracts.py +162 -25
- exonware/xwlazy/defs.py +15 -15
- exonware/xwlazy/facade.py +175 -29
- exonware/xwlazy/host/__init__.py +8 -0
- exonware/xwlazy/host/conf.py +16 -0
- exonware/xwlazy/module/base.py +61 -4
- exonware/xwlazy/module/facade.py +1 -1
- exonware/xwlazy/module/importer_engine.py +1017 -170
- exonware/xwlazy/module/partial_module_detector.py +275 -0
- exonware/xwlazy/module/strategies/module_helper_lazy.py +3 -3
- exonware/xwlazy/package/base.py +106 -41
- exonware/xwlazy/package/conf.py +6 -6
- exonware/xwlazy/package/services/config_manager.py +20 -16
- exonware/xwlazy/package/services/discovery.py +81 -16
- exonware/xwlazy/package/services/host_packages.py +41 -6
- exonware/xwlazy/package/services/install_async.py +16 -2
- exonware/xwlazy/package/services/install_cache.py +4 -4
- exonware/xwlazy/package/services/install_policy.py +14 -14
- exonware/xwlazy/package/services/install_registry.py +3 -3
- exonware/xwlazy/package/services/install_sbom.py +1 -1
- exonware/xwlazy/package/services/installer_engine.py +3 -3
- exonware/xwlazy/package/services/lazy_installer.py +102 -17
- exonware/xwlazy/package/services/manifest.py +43 -36
- exonware/xwlazy/package/services/strategy_registry.py +150 -12
- exonware/xwlazy/package/strategies/package_discovery_file.py +2 -2
- exonware/xwlazy/package/strategies/package_discovery_hybrid.py +2 -2
- exonware/xwlazy/package/strategies/package_discovery_manifest.py +2 -2
- exonware/xwlazy/package/strategies/package_execution_async.py +3 -3
- exonware/xwlazy/package/strategies/package_execution_cached.py +2 -2
- exonware/xwlazy/package/strategies/package_execution_pip.py +2 -2
- exonware/xwlazy/package/strategies/package_execution_wheel.py +2 -2
- exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +2 -2
- exonware/xwlazy/package/strategies/package_mapping_hybrid.py +2 -2
- exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +2 -2
- exonware/xwlazy/package/strategies/package_policy_allow_list.py +4 -4
- exonware/xwlazy/package/strategies/package_policy_deny_list.py +4 -4
- exonware/xwlazy/package/strategies/package_policy_permissive.py +3 -3
- exonware/xwlazy/package/strategies/package_timing_clean.py +2 -2
- exonware/xwlazy/package/strategies/package_timing_full.py +2 -2
- exonware/xwlazy/package/strategies/package_timing_smart.py +2 -2
- exonware/xwlazy/package/strategies/package_timing_temporary.py +2 -2
- exonware/xwlazy/runtime/adaptive_learner.py +7 -7
- exonware/xwlazy/runtime/base.py +14 -14
- exonware/xwlazy/runtime/facade.py +7 -7
- exonware/xwlazy/runtime/intelligent_selector.py +6 -6
- exonware/xwlazy/runtime/metrics.py +6 -6
- exonware/xwlazy/runtime/performance.py +5 -5
- exonware/xwlazy/version.py +2 -2
- {exonware_xwlazy-0.1.0.21.dist-info → exonware_xwlazy-0.1.0.23.dist-info}/METADATA +2 -6
- exonware_xwlazy-0.1.0.23.dist-info/RECORD +93 -0
- xwlazy/__init__.py +14 -0
- xwlazy/lazy.py +30 -0
- exonware_xwlazy-0.1.0.21.dist-info/RECORD +0 -87
- {exonware_xwlazy-0.1.0.21.dist-info → exonware_xwlazy-0.1.0.23.dist-info}/WHEEL +0 -0
- {exonware_xwlazy-0.1.0.21.dist-info → exonware_xwlazy-0.1.0.23.dist-info}/licenses/LICENSE +0 -0
|
@@ -14,7 +14,7 @@ Uses shared utilities from common/services/install_async_utils.
|
|
|
14
14
|
import sys
|
|
15
15
|
import asyncio
|
|
16
16
|
import subprocess
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Any
|
|
18
18
|
from ...package.base import AInstallExecutionStrategy
|
|
19
19
|
from ...package.services.install_result import InstallResult, InstallStatus
|
|
20
20
|
from ...common.services.install_async_utils import async_install_package
|
|
@@ -27,7 +27,7 @@ class AsyncExecution(AInstallExecutionStrategy):
|
|
|
27
27
|
Uses shared utilities from common/services/install_async_utils.
|
|
28
28
|
"""
|
|
29
29
|
|
|
30
|
-
def execute_install(self, package_name: str, policy_args:
|
|
30
|
+
def execute_install(self, package_name: str, policy_args: list[str]) -> Any:
|
|
31
31
|
"""
|
|
32
32
|
Execute installation asynchronously.
|
|
33
33
|
|
|
@@ -62,7 +62,7 @@ class AsyncExecution(AInstallExecutionStrategy):
|
|
|
62
62
|
error=str(e)
|
|
63
63
|
)
|
|
64
64
|
|
|
65
|
-
async def _async_install(self, package_name: str, policy_args:
|
|
65
|
+
async def _async_install(self, package_name: str, policy_args: list[str]) -> InstallResult:
|
|
66
66
|
"""
|
|
67
67
|
Async installation implementation.
|
|
68
68
|
|
|
@@ -14,7 +14,7 @@ Uses shared utilities from common/services/install_cache_utils.
|
|
|
14
14
|
import sys
|
|
15
15
|
import subprocess
|
|
16
16
|
from pathlib import Path
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Any, Optional
|
|
18
18
|
from ...package.base import AInstallExecutionStrategy
|
|
19
19
|
from ...package.services.install_result import InstallResult, InstallStatus
|
|
20
20
|
from ...common.services.install_cache_utils import (
|
|
@@ -39,7 +39,7 @@ class CachedExecution(AInstallExecutionStrategy):
|
|
|
39
39
|
"""
|
|
40
40
|
self._cache_dir = cache_dir
|
|
41
41
|
|
|
42
|
-
def execute_install(self, package_name: str, policy_args:
|
|
42
|
+
def execute_install(self, package_name: str, policy_args: list[str]) -> Any:
|
|
43
43
|
"""
|
|
44
44
|
Execute installation from cached tree.
|
|
45
45
|
|
|
@@ -12,7 +12,7 @@ Pip execution strategy - direct pip install.
|
|
|
12
12
|
|
|
13
13
|
import sys
|
|
14
14
|
import subprocess
|
|
15
|
-
from typing import
|
|
15
|
+
from typing import Any
|
|
16
16
|
from ...package.base import AInstallExecutionStrategy
|
|
17
17
|
from ...package.services.install_result import InstallResult, InstallStatus
|
|
18
18
|
|
|
@@ -23,7 +23,7 @@ class PipExecution(AInstallExecutionStrategy):
|
|
|
23
23
|
This is the default execution strategy that uses pip install.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
def execute_install(self, package_name: str, policy_args:
|
|
26
|
+
def execute_install(self, package_name: str, policy_args: list[str]) -> Any:
|
|
27
27
|
"""
|
|
28
28
|
Execute installation using pip.
|
|
29
29
|
|
|
@@ -14,7 +14,7 @@ Uses shared utilities from common/services/install_cache_utils.
|
|
|
14
14
|
import sys
|
|
15
15
|
import subprocess
|
|
16
16
|
from pathlib import Path
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Any, Optional
|
|
18
18
|
from ...package.base import AInstallExecutionStrategy
|
|
19
19
|
from ...package.services.install_result import InstallResult, InstallStatus
|
|
20
20
|
from ...common.services.install_cache_utils import (
|
|
@@ -40,7 +40,7 @@ class WheelExecution(AInstallExecutionStrategy):
|
|
|
40
40
|
"""
|
|
41
41
|
self._cache_dir = cache_dir
|
|
42
42
|
|
|
43
|
-
def execute_install(self, package_name: str, policy_args:
|
|
43
|
+
def execute_install(self, package_name: str, policy_args: list[str]) -> Any:
|
|
44
44
|
"""
|
|
45
45
|
Execute installation from wheel file.
|
|
46
46
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Discovery-first mapping strategy - discovery takes precedence over manifest.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import Optional
|
|
13
|
+
from typing import Optional
|
|
14
14
|
from ...package.base import AMappingStrategy
|
|
15
15
|
from ...package.services.manifest import get_manifest_loader
|
|
16
16
|
|
|
@@ -72,7 +72,7 @@ class DiscoveryFirstMapping(AMappingStrategy):
|
|
|
72
72
|
common_mappings = discovery.COMMON_MAPPINGS
|
|
73
73
|
return common_mappings.get(import_name)
|
|
74
74
|
|
|
75
|
-
def map_package_to_imports(self, package_name: str) ->
|
|
75
|
+
def map_package_to_imports(self, package_name: str) -> list[str]:
|
|
76
76
|
"""
|
|
77
77
|
Map package name to possible import names.
|
|
78
78
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Hybrid mapping strategy - tries both manifest and discovery, uses best match.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import Optional
|
|
13
|
+
from typing import Optional
|
|
14
14
|
from ...package.base import AMappingStrategy
|
|
15
15
|
from ...package.services.manifest import get_manifest_loader
|
|
16
16
|
|
|
@@ -74,7 +74,7 @@ class HybridMapping(AMappingStrategy):
|
|
|
74
74
|
common_mappings = discovery.COMMON_MAPPINGS
|
|
75
75
|
return common_mappings.get(import_name)
|
|
76
76
|
|
|
77
|
-
def map_package_to_imports(self, package_name: str) ->
|
|
77
|
+
def map_package_to_imports(self, package_name: str) -> list[str]:
|
|
78
78
|
"""
|
|
79
79
|
Map package name to possible import names.
|
|
80
80
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Manifest-first mapping strategy - manifest takes precedence over discovery.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import Optional
|
|
13
|
+
from typing import Optional
|
|
14
14
|
from ...package.base import AMappingStrategy
|
|
15
15
|
from ...package.services.manifest import get_manifest_loader
|
|
16
16
|
|
|
@@ -72,7 +72,7 @@ class ManifestFirstMapping(AMappingStrategy):
|
|
|
72
72
|
common_mappings = discovery.COMMON_MAPPINGS
|
|
73
73
|
return common_mappings.get(import_name)
|
|
74
74
|
|
|
75
|
-
def map_package_to_imports(self, package_name: str) ->
|
|
75
|
+
def map_package_to_imports(self, package_name: str) -> list[str]:
|
|
76
76
|
"""
|
|
77
77
|
Map package name to possible import names.
|
|
78
78
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Allow list policy - only allows packages in the allow list.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import
|
|
14
14
|
from ...package.base import APolicyStrategy
|
|
15
15
|
|
|
16
16
|
class AllowListPolicy(APolicyStrategy):
|
|
@@ -20,7 +20,7 @@ class AllowListPolicy(APolicyStrategy):
|
|
|
20
20
|
Only packages explicitly in the allow list can be installed.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
def __init__(self, allowed_packages:
|
|
23
|
+
def __init__(self, allowed_packages: set[str]):
|
|
24
24
|
"""
|
|
25
25
|
Initialize allow list policy.
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ class AllowListPolicy(APolicyStrategy):
|
|
|
29
29
|
"""
|
|
30
30
|
self._allowed = {pkg.lower() for pkg in allowed_packages}
|
|
31
31
|
|
|
32
|
-
def is_allowed(self, package_name: str) ->
|
|
32
|
+
def is_allowed(self, package_name: str) -> tuple[bool, str]:
|
|
33
33
|
"""
|
|
34
34
|
Check if package is allowed to be installed.
|
|
35
35
|
|
|
@@ -43,7 +43,7 @@ class AllowListPolicy(APolicyStrategy):
|
|
|
43
43
|
return (True, f"Package '{package_name}' is in allow list")
|
|
44
44
|
return (False, f"Package '{package_name}' is not in allow list")
|
|
45
45
|
|
|
46
|
-
def get_pip_args(self, package_name: str) ->
|
|
46
|
+
def get_pip_args(self, package_name: str) -> list[str]:
|
|
47
47
|
"""
|
|
48
48
|
Get pip arguments based on policy.
|
|
49
49
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Deny list policy - blocks packages in the deny list.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import
|
|
14
14
|
from ...package.base import APolicyStrategy
|
|
15
15
|
|
|
16
16
|
class DenyListPolicy(APolicyStrategy):
|
|
@@ -20,7 +20,7 @@ class DenyListPolicy(APolicyStrategy):
|
|
|
20
20
|
Packages in the deny list cannot be installed.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
def __init__(self, denied_packages:
|
|
23
|
+
def __init__(self, denied_packages: set[str]):
|
|
24
24
|
"""
|
|
25
25
|
Initialize deny list policy.
|
|
26
26
|
|
|
@@ -29,7 +29,7 @@ class DenyListPolicy(APolicyStrategy):
|
|
|
29
29
|
"""
|
|
30
30
|
self._denied = {pkg.lower() for pkg in denied_packages}
|
|
31
31
|
|
|
32
|
-
def is_allowed(self, package_name: str) ->
|
|
32
|
+
def is_allowed(self, package_name: str) -> tuple[bool, str]:
|
|
33
33
|
"""
|
|
34
34
|
Check if package is allowed to be installed.
|
|
35
35
|
|
|
@@ -43,7 +43,7 @@ class DenyListPolicy(APolicyStrategy):
|
|
|
43
43
|
return (False, f"Package '{package_name}' is in deny list")
|
|
44
44
|
return (True, f"Package '{package_name}' is not in deny list")
|
|
45
45
|
|
|
46
|
-
def get_pip_args(self, package_name: str) ->
|
|
46
|
+
def get_pip_args(self, package_name: str) -> list[str]:
|
|
47
47
|
"""
|
|
48
48
|
Get pip arguments based on policy.
|
|
49
49
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Permissive policy - allows all packages (default).
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import
|
|
14
14
|
from ...package.base import APolicyStrategy
|
|
15
15
|
|
|
16
16
|
class PermissivePolicy(APolicyStrategy):
|
|
@@ -20,7 +20,7 @@ class PermissivePolicy(APolicyStrategy):
|
|
|
20
20
|
This is the default policy that doesn't restrict any packages.
|
|
21
21
|
"""
|
|
22
22
|
|
|
23
|
-
def is_allowed(self, package_name: str) ->
|
|
23
|
+
def is_allowed(self, package_name: str) -> tuple[bool, str]:
|
|
24
24
|
"""
|
|
25
25
|
Check if package is allowed to be installed.
|
|
26
26
|
|
|
@@ -32,7 +32,7 @@ class PermissivePolicy(APolicyStrategy):
|
|
|
32
32
|
"""
|
|
33
33
|
return (True, "Permissive policy allows all packages")
|
|
34
34
|
|
|
35
|
-
def get_pip_args(self, package_name: str) ->
|
|
35
|
+
def get_pip_args(self, package_name: str) -> list[str]:
|
|
36
36
|
"""
|
|
37
37
|
Get pip arguments based on policy.
|
|
38
38
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Clean timing - install on usage + uninstall after completion.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import Any
|
|
14
14
|
from ...package.base import AInstallTimingStrategy
|
|
15
15
|
|
|
16
16
|
class CleanTiming(AInstallTimingStrategy):
|
|
@@ -51,7 +51,7 @@ class CleanTiming(AInstallTimingStrategy):
|
|
|
51
51
|
"""
|
|
52
52
|
return True
|
|
53
53
|
|
|
54
|
-
def get_install_priority(self, packages:
|
|
54
|
+
def get_install_priority(self, packages: list[str]) -> list[str]:
|
|
55
55
|
"""
|
|
56
56
|
Get priority order for installing packages.
|
|
57
57
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Full timing - install all dependencies upfront.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import Any
|
|
14
14
|
from ...package.base import AInstallTimingStrategy
|
|
15
15
|
|
|
16
16
|
class FullTiming(AInstallTimingStrategy):
|
|
@@ -50,7 +50,7 @@ class FullTiming(AInstallTimingStrategy):
|
|
|
50
50
|
"""
|
|
51
51
|
return False
|
|
52
52
|
|
|
53
|
-
def get_install_priority(self, packages:
|
|
53
|
+
def get_install_priority(self, packages: list[str]) -> list[str]:
|
|
54
54
|
"""
|
|
55
55
|
Get priority order for installing packages.
|
|
56
56
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Smart timing - install on first usage (on-demand).
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import Any
|
|
14
14
|
from ...package.base import AInstallTimingStrategy
|
|
15
15
|
from ...defs import LazyInstallMode
|
|
16
16
|
|
|
@@ -52,7 +52,7 @@ class SmartTiming(AInstallTimingStrategy):
|
|
|
52
52
|
"""
|
|
53
53
|
return False
|
|
54
54
|
|
|
55
|
-
def get_install_priority(self, packages:
|
|
55
|
+
def get_install_priority(self, packages: list[str]) -> list[str]:
|
|
56
56
|
"""
|
|
57
57
|
Get priority order for installing packages.
|
|
58
58
|
|
|
@@ -10,7 +10,7 @@ Generation Date: 15-Nov-2025
|
|
|
10
10
|
Temporary timing - always uninstall after use (more aggressive than CLEAN).
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
from typing import
|
|
13
|
+
from typing import Any
|
|
14
14
|
from ...package.base import AInstallTimingStrategy
|
|
15
15
|
|
|
16
16
|
class TemporaryTiming(AInstallTimingStrategy):
|
|
@@ -50,7 +50,7 @@ class TemporaryTiming(AInstallTimingStrategy):
|
|
|
50
50
|
"""
|
|
51
51
|
return True
|
|
52
52
|
|
|
53
|
-
def get_install_priority(self, packages:
|
|
53
|
+
def get_install_priority(self, packages: list[str]) -> list[str]:
|
|
54
54
|
"""
|
|
55
55
|
Get priority order for installing packages.
|
|
56
56
|
|
|
@@ -14,7 +14,7 @@ This module provides adaptive learning for ADAPTIVE mode.
|
|
|
14
14
|
|
|
15
15
|
import time
|
|
16
16
|
import threading
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Optional
|
|
18
18
|
from collections import defaultdict, deque
|
|
19
19
|
|
|
20
20
|
# Logger not used in this module, removed to avoid circular dependency
|
|
@@ -33,9 +33,9 @@ class AdaptiveLearner:
|
|
|
33
33
|
self._learning_window = learning_window
|
|
34
34
|
self._prediction_depth = prediction_depth
|
|
35
35
|
self._import_sequences: deque = deque(maxlen=learning_window)
|
|
36
|
-
self._access_times:
|
|
37
|
-
self._import_chains:
|
|
38
|
-
self._module_scores:
|
|
36
|
+
self._access_times: dict[str, list[float]] = defaultdict(list)
|
|
37
|
+
self._import_chains: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))
|
|
38
|
+
self._module_scores: dict[str, float] = {}
|
|
39
39
|
self._lock = threading.RLock()
|
|
40
40
|
|
|
41
41
|
def record_import(self, module_name: str, import_time: float) -> None:
|
|
@@ -82,14 +82,14 @@ class AdaptiveLearner:
|
|
|
82
82
|
# Combined score
|
|
83
83
|
self._module_scores[module_name] = frequency * 0.4 + recency * 1000 * 0.4 + chain_weight * 0.2
|
|
84
84
|
|
|
85
|
-
def predict_next_imports(self, current_module: Optional[str] = None, limit: int = 5) ->
|
|
85
|
+
def predict_next_imports(self, current_module: Optional[str] = None, limit: int = 5) -> list[str]:
|
|
86
86
|
"""Predict likely next imports based on patterns."""
|
|
87
87
|
# Lock-free check first
|
|
88
88
|
if not self._import_sequences:
|
|
89
89
|
return []
|
|
90
90
|
|
|
91
91
|
with self._lock:
|
|
92
|
-
candidates:
|
|
92
|
+
candidates: dict[str, float] = {}
|
|
93
93
|
|
|
94
94
|
# Predict based on current module chain (lock-free read of dict)
|
|
95
95
|
if current_module:
|
|
@@ -105,7 +105,7 @@ class AdaptiveLearner:
|
|
|
105
105
|
sorted_candidates = sorted(candidates.items(), key=lambda x: x[1], reverse=True)
|
|
106
106
|
return [module for module, _ in sorted_candidates[:limit]]
|
|
107
107
|
|
|
108
|
-
def get_priority_modules(self, limit: int = 10) ->
|
|
108
|
+
def get_priority_modules(self, limit: int = 10) -> list[str]:
|
|
109
109
|
"""Get modules that should be preloaded based on scores."""
|
|
110
110
|
with self._lock:
|
|
111
111
|
sorted_modules = sorted(
|
exonware/xwlazy/runtime/base.py
CHANGED
|
@@ -14,7 +14,7 @@ This module defines the abstract base class for runtime services.
|
|
|
14
14
|
|
|
15
15
|
import threading
|
|
16
16
|
from abc import ABC, abstractmethod
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Optional, Any
|
|
18
18
|
|
|
19
19
|
from ..contracts import (
|
|
20
20
|
IRuntime,
|
|
@@ -63,19 +63,19 @@ class ARuntimeHelper(IRuntime, ABC):
|
|
|
63
63
|
self._auto_state: Optional[bool] = None
|
|
64
64
|
|
|
65
65
|
# From IMetricsCollector
|
|
66
|
-
self._metrics:
|
|
66
|
+
self._metrics: dict[str, list[float]] = {}
|
|
67
67
|
|
|
68
68
|
# From IPerformanceMonitor
|
|
69
|
-
self._load_times:
|
|
70
|
-
self._access_counts:
|
|
69
|
+
self._load_times: dict[str, list[float]] = {}
|
|
70
|
+
self._access_counts: dict[str, int] = {}
|
|
71
71
|
|
|
72
72
|
# From IMultiTierCache
|
|
73
|
-
self._l1_cache:
|
|
74
|
-
self._l2_cache:
|
|
75
|
-
self._l3_cache:
|
|
73
|
+
self._l1_cache: dict[str, Any] = {}
|
|
74
|
+
self._l2_cache: dict[str, Any] = {}
|
|
75
|
+
self._l3_cache: dict[str, Any] = {}
|
|
76
76
|
|
|
77
77
|
# From IRegistry
|
|
78
|
-
self._registry:
|
|
78
|
+
self._registry: dict[str, Any] = {}
|
|
79
79
|
|
|
80
80
|
# Common
|
|
81
81
|
self._lock = threading.RLock()
|
|
@@ -112,7 +112,7 @@ class ARuntimeHelper(IRuntime, ABC):
|
|
|
112
112
|
pass
|
|
113
113
|
|
|
114
114
|
@abstractmethod
|
|
115
|
-
def predict_next_imports(self, current_module: str, count: int = 3) ->
|
|
115
|
+
def predict_next_imports(self, current_module: str, count: int = 3) -> list[str]:
|
|
116
116
|
"""Predict next likely imports based on patterns (from IAdaptiveLearner)."""
|
|
117
117
|
pass
|
|
118
118
|
|
|
@@ -137,12 +137,12 @@ class ARuntimeHelper(IRuntime, ABC):
|
|
|
137
137
|
pass
|
|
138
138
|
|
|
139
139
|
@abstractmethod
|
|
140
|
-
def get_optimal_mode(self, load_level: Any) ->
|
|
140
|
+
def get_optimal_mode(self, load_level: Any) -> tuple[Any, Any]:
|
|
141
141
|
"""Get optimal mode for a load level (from IIntelligentSelector)."""
|
|
142
142
|
pass
|
|
143
143
|
|
|
144
144
|
@abstractmethod
|
|
145
|
-
def update_mode_map(self, mode_map:
|
|
145
|
+
def update_mode_map(self, mode_map: dict[Any, tuple[Any, Any]]) -> None:
|
|
146
146
|
"""Update mode mapping with benchmark results (from IIntelligentSelector)."""
|
|
147
147
|
pass
|
|
148
148
|
|
|
@@ -158,12 +158,12 @@ class ARuntimeHelper(IRuntime, ABC):
|
|
|
158
158
|
self._metrics[name].append(value)
|
|
159
159
|
|
|
160
160
|
@abstractmethod
|
|
161
|
-
def get_metric_stats(self, name: str) ->
|
|
161
|
+
def get_metric_stats(self, name: str) -> dict[str, Any]:
|
|
162
162
|
"""Get statistics for a metric (from IMetricsCollector)."""
|
|
163
163
|
pass
|
|
164
164
|
|
|
165
165
|
@abstractmethod
|
|
166
|
-
def get_all_stats(self) ->
|
|
166
|
+
def get_all_stats(self) -> dict[str, dict[str, Any]]:
|
|
167
167
|
"""Get statistics for all metrics (from IMetricsCollector)."""
|
|
168
168
|
pass
|
|
169
169
|
|
|
@@ -189,7 +189,7 @@ class ARuntimeHelper(IRuntime, ABC):
|
|
|
189
189
|
self._access_counts[module] = self._access_counts.get(module, 0) + 1
|
|
190
190
|
|
|
191
191
|
@abstractmethod
|
|
192
|
-
def get_performance_stats(self) ->
|
|
192
|
+
def get_performance_stats(self) -> dict[str, Any]:
|
|
193
193
|
"""Get performance statistics (from IPerformanceMonitor)."""
|
|
194
194
|
pass
|
|
195
195
|
|
|
@@ -5,7 +5,7 @@ Main facade: XWRuntimeHelper extends ARuntimeHelper
|
|
|
5
5
|
Provides concrete implementation for all runtime services.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from typing import
|
|
8
|
+
from typing import Optional, Any
|
|
9
9
|
from .base import ARuntimeHelper
|
|
10
10
|
from ..defs import LazyLoadMode, LazyInstallMode
|
|
11
11
|
|
|
@@ -26,7 +26,7 @@ class XWRuntimeHelper(ARuntimeHelper):
|
|
|
26
26
|
# TODO: Implement import recording
|
|
27
27
|
pass
|
|
28
28
|
|
|
29
|
-
def predict_next_imports(self, current_module: str, count: int = 3) ->
|
|
29
|
+
def predict_next_imports(self, current_module: str, count: int = 3) -> list[str]:
|
|
30
30
|
"""Predict next likely imports based on patterns."""
|
|
31
31
|
# TODO: Implement prediction logic
|
|
32
32
|
return []
|
|
@@ -48,17 +48,17 @@ class XWRuntimeHelper(ARuntimeHelper):
|
|
|
48
48
|
from .intelligent_selector import LoadLevel
|
|
49
49
|
return LoadLevel.LIGHT
|
|
50
50
|
|
|
51
|
-
def get_optimal_mode(self, load_level) ->
|
|
51
|
+
def get_optimal_mode(self, load_level) -> tuple[LazyLoadMode, LazyInstallMode]:
|
|
52
52
|
"""Get optimal mode for a load level."""
|
|
53
53
|
# TODO: Implement mode selection
|
|
54
54
|
return LazyLoadMode.AUTO, LazyInstallMode.SMART
|
|
55
55
|
|
|
56
|
-
def update_mode_map(self, mode_map:
|
|
56
|
+
def update_mode_map(self, mode_map: dict[Any, tuple[LazyLoadMode, LazyInstallMode]]) -> None:
|
|
57
57
|
"""Update mode mapping with benchmark results."""
|
|
58
58
|
# TODO: Implement mode map update
|
|
59
59
|
pass
|
|
60
60
|
|
|
61
|
-
def get_metric_stats(self, name: str) ->
|
|
61
|
+
def get_metric_stats(self, name: str) -> dict[str, Any]:
|
|
62
62
|
"""Get statistics for a metric."""
|
|
63
63
|
with self._lock:
|
|
64
64
|
values = self._metrics.get(name, [])
|
|
@@ -72,12 +72,12 @@ class XWRuntimeHelper(ARuntimeHelper):
|
|
|
72
72
|
'max': max(values)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
def get_all_stats(self) ->
|
|
75
|
+
def get_all_stats(self) -> dict[str, dict[str, Any]]:
|
|
76
76
|
"""Get statistics for all metrics."""
|
|
77
77
|
with self._lock:
|
|
78
78
|
return {name: self.get_metric_stats(name) for name in self._metrics.keys()}
|
|
79
79
|
|
|
80
|
-
def get_performance_stats(self) ->
|
|
80
|
+
def get_performance_stats(self) -> dict[str, Any]:
|
|
81
81
|
"""Get performance statistics."""
|
|
82
82
|
with self._lock:
|
|
83
83
|
return {
|
|
@@ -12,7 +12,7 @@ Generation Date: 19-Nov-2025
|
|
|
12
12
|
This module provides intelligent mode switching based on load level.
|
|
13
13
|
"""
|
|
14
14
|
|
|
15
|
-
from typing import
|
|
15
|
+
from typing import Optional
|
|
16
16
|
|
|
17
17
|
from ..defs import LazyLoadMode, LazyInstallMode, LoadLevel
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ def _get_logger():
|
|
|
32
32
|
# Updated: 2025-11-19 - Based on 20-iteration consistency test averages
|
|
33
33
|
# Light: ultra+full (0.568ms avg), Medium: hyperparallel+full (5.134ms avg)
|
|
34
34
|
# Heavy: preload+size_aware (18.475ms avg), Enterprise: preload+full (44.742ms avg)
|
|
35
|
-
INTELLIGENT_MODE_MAP:
|
|
35
|
+
INTELLIGENT_MODE_MAP: dict[LoadLevel, tuple[LazyLoadMode, LazyInstallMode]] = {
|
|
36
36
|
LoadLevel.LIGHT: (LazyLoadMode.ULTRA, LazyInstallMode.FULL), # Winner: 0.568ms avg (±26.1% CV)
|
|
37
37
|
LoadLevel.MEDIUM: (LazyLoadMode.HYPERPARALLEL, LazyInstallMode.FULL), # Winner: 5.134ms avg (±4.7% CV)
|
|
38
38
|
LoadLevel.HEAVY: (LazyLoadMode.PRELOAD, LazyInstallMode.SIZE_AWARE), # Winner: 18.475ms avg (±10.2% CV)
|
|
@@ -42,7 +42,7 @@ INTELLIGENT_MODE_MAP: Dict[LoadLevel, Tuple[LazyLoadMode, LazyInstallMode]] = {
|
|
|
42
42
|
class IntelligentModeSelector:
|
|
43
43
|
"""Selects optimal mode based on current load characteristics."""
|
|
44
44
|
|
|
45
|
-
def __init__(self, mode_map: Optional[
|
|
45
|
+
def __init__(self, mode_map: Optional[dict[LoadLevel, tuple[LazyLoadMode, LazyInstallMode]]] = None):
|
|
46
46
|
"""
|
|
47
47
|
Initialize intelligent mode selector.
|
|
48
48
|
|
|
@@ -55,7 +55,7 @@ class IntelligentModeSelector:
|
|
|
55
55
|
self._total_import_time = 0.0
|
|
56
56
|
self._import_count = 0
|
|
57
57
|
|
|
58
|
-
def update_mode_map(self, mode_map:
|
|
58
|
+
def update_mode_map(self, mode_map: dict[LoadLevel, tuple[LazyLoadMode, LazyInstallMode]]) -> None:
|
|
59
59
|
"""Update the mode mapping with benchmark results."""
|
|
60
60
|
self._mode_map = mode_map.copy()
|
|
61
61
|
_get_logger().info(f"Updated INTELLIGENT mode mapping: {mode_map}")
|
|
@@ -111,7 +111,7 @@ class IntelligentModeSelector:
|
|
|
111
111
|
|
|
112
112
|
return self._current_load_level
|
|
113
113
|
|
|
114
|
-
def get_optimal_mode(self, load_level: Optional[LoadLevel] = None) ->
|
|
114
|
+
def get_optimal_mode(self, load_level: Optional[LoadLevel] = None) -> tuple[LazyLoadMode, LazyInstallMode]:
|
|
115
115
|
"""
|
|
116
116
|
Get optimal mode combination for given load level.
|
|
117
117
|
|
|
@@ -134,7 +134,7 @@ class IntelligentModeSelector:
|
|
|
134
134
|
|
|
135
135
|
def should_switch_mode(
|
|
136
136
|
self,
|
|
137
|
-
current_mode:
|
|
137
|
+
current_mode: tuple[LazyLoadMode, LazyInstallMode],
|
|
138
138
|
detected_level: LoadLevel
|
|
139
139
|
) -> bool:
|
|
140
140
|
"""
|
|
@@ -4,7 +4,7 @@ Performance metrics tracking for lazy loading system.
|
|
|
4
4
|
This module provides utilities for tracking and aggregating performance metrics.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Any, Optional
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
from collections import defaultdict
|
|
10
10
|
|
|
@@ -13,9 +13,9 @@ class MetricsCollector:
|
|
|
13
13
|
|
|
14
14
|
def __init__(self):
|
|
15
15
|
"""Initialize metrics collector."""
|
|
16
|
-
self._metrics:
|
|
17
|
-
self._counts:
|
|
18
|
-
self._timestamps:
|
|
16
|
+
self._metrics: dict[str, list[float]] = defaultdict(list)
|
|
17
|
+
self._counts: dict[str, int] = defaultdict(int)
|
|
18
|
+
self._timestamps: dict[str, list[datetime]] = defaultdict(list)
|
|
19
19
|
|
|
20
20
|
def record_metric(self, name: str, value: float, timestamp: Optional[datetime] = None) -> None:
|
|
21
21
|
"""Record a metric value."""
|
|
@@ -25,7 +25,7 @@ class MetricsCollector:
|
|
|
25
25
|
timestamp = datetime.now()
|
|
26
26
|
self._timestamps[name].append(timestamp)
|
|
27
27
|
|
|
28
|
-
def get_metric_stats(self, name: str) ->
|
|
28
|
+
def get_metric_stats(self, name: str) -> dict[str, Any]:
|
|
29
29
|
"""Get statistics for a specific metric."""
|
|
30
30
|
values = self._metrics.get(name, [])
|
|
31
31
|
if not values:
|
|
@@ -39,7 +39,7 @@ class MetricsCollector:
|
|
|
39
39
|
'max': max(values),
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
def get_all_stats(self) ->
|
|
42
|
+
def get_all_stats(self) -> dict[str, dict[str, Any]]:
|
|
43
43
|
"""Get statistics for all metrics."""
|
|
44
44
|
return {name: self.get_metric_stats(name) for name in self._metrics.keys()}
|
|
45
45
|
|
|
@@ -4,7 +4,7 @@ Performance monitoring for lazy loading system.
|
|
|
4
4
|
This module contains LazyPerformanceMonitor extracted from lazy_core.py Section 4.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
class LazyPerformanceMonitor:
|
|
10
10
|
"""Performance monitor for lazy loading operations."""
|
|
@@ -13,9 +13,9 @@ class LazyPerformanceMonitor:
|
|
|
13
13
|
|
|
14
14
|
def __init__(self):
|
|
15
15
|
"""Initialize performance monitor."""
|
|
16
|
-
self._load_times:
|
|
17
|
-
self._access_counts:
|
|
18
|
-
self._memory_usage:
|
|
16
|
+
self._load_times: dict[str, float] = {}
|
|
17
|
+
self._access_counts: dict[str, int] = {}
|
|
18
|
+
self._memory_usage: dict[str, Any] = {}
|
|
19
19
|
|
|
20
20
|
def record_load_time(self, module: str, load_time: float) -> None:
|
|
21
21
|
"""Record module load time."""
|
|
@@ -25,7 +25,7 @@ class LazyPerformanceMonitor:
|
|
|
25
25
|
"""Record module access."""
|
|
26
26
|
self._access_counts[module] = self._access_counts.get(module, 0) + 1
|
|
27
27
|
|
|
28
|
-
def get_stats(self) ->
|
|
28
|
+
def get_stats(self) -> dict[str, Any]:
|
|
29
29
|
"""Get performance statistics."""
|
|
30
30
|
return {
|
|
31
31
|
'load_times': self._load_times.copy(),
|
exonware/xwlazy/version.py
CHANGED
|
@@ -14,13 +14,13 @@ All version references should import from this module to ensure consistency.
|
|
|
14
14
|
# =============================================================================
|
|
15
15
|
|
|
16
16
|
# Main version - update this to change version across entire project
|
|
17
|
-
__version__ = "0.1.0.
|
|
17
|
+
__version__ = "0.1.0.23"
|
|
18
18
|
|
|
19
19
|
# Version components for programmatic access
|
|
20
20
|
VERSION_MAJOR = 0
|
|
21
21
|
VERSION_MINOR = 1
|
|
22
22
|
VERSION_PATCH = 0
|
|
23
|
-
VERSION_BUILD =
|
|
23
|
+
VERSION_BUILD = 23 # Set to None for releases, or build number for dev builds
|
|
24
24
|
|
|
25
25
|
# Version metadata
|
|
26
26
|
VERSION_SUFFIX = "" # e.g., "dev", "alpha", "beta", "rc1"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: exonware-xwlazy
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.23
|
|
4
4
|
Summary: Marker package that enables lazy install features across the eXonware suite.
|
|
5
5
|
Project-URL: Homepage, https://exonware.com
|
|
6
6
|
Project-URL: Repository, https://github.com/exonware/xwlazy
|
|
@@ -15,13 +15,9 @@ Classifier: Intended Audience :: Developers
|
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
23
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.12
|
|
25
21
|
Requires-Dist: tomli>=2.0.1; python_version < '3.11'
|
|
26
22
|
Description-Content-Type: text/markdown
|
|
27
23
|
|