engin 0.1.0rc1__py3-none-any.whl → 0.1.0rc3__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.
- engin/_assembler.py +5 -7
- engin/_cli/_check.py +2 -17
- engin/_cli/_graph.html +878 -73
- engin/_cli/_graph.py +122 -63
- engin/_cli/_inspect.py +6 -3
- engin/_engin.py +6 -3
- engin/_supervisor.py +18 -4
- engin/exceptions.py +21 -6
- {engin-0.1.0rc1.dist-info → engin-0.1.0rc3.dist-info}/METADATA +28 -15
- {engin-0.1.0rc1.dist-info → engin-0.1.0rc3.dist-info}/RECORD +13 -13
- {engin-0.1.0rc1.dist-info → engin-0.1.0rc3.dist-info}/WHEEL +0 -0
- {engin-0.1.0rc1.dist-info → engin-0.1.0rc3.dist-info}/entry_points.txt +0 -0
- {engin-0.1.0rc1.dist-info → engin-0.1.0rc3.dist-info}/licenses/LICENSE +0 -0
engin/_assembler.py
CHANGED
@@ -10,7 +10,7 @@ from typing import Any, Generic, TypeVar, cast
|
|
10
10
|
|
11
11
|
from engin._dependency import Dependency, Provide, Supply
|
12
12
|
from engin._type_utils import TypeId
|
13
|
-
from engin.exceptions import NotInScopeError, ProviderError
|
13
|
+
from engin.exceptions import NotInScopeError, ProviderError, TypeNotProvidedError
|
14
14
|
|
15
15
|
LOG = logging.getLogger("engin")
|
16
16
|
|
@@ -111,7 +111,7 @@ class Assembler:
|
|
111
111
|
type_: the type of the desired value to build.
|
112
112
|
|
113
113
|
Raises:
|
114
|
-
|
114
|
+
TypeNotProvidedError: When no provider is found for the given type.
|
115
115
|
ProviderError: When a provider errors when trying to construct the type or
|
116
116
|
any of its dependent types.
|
117
117
|
|
@@ -123,7 +123,7 @@ class Assembler:
|
|
123
123
|
return cast("T", self._assembled_outputs[type_id])
|
124
124
|
if type_id.multi:
|
125
125
|
if type_id not in self._multiproviders:
|
126
|
-
raise
|
126
|
+
raise TypeNotProvidedError(type_id)
|
127
127
|
|
128
128
|
out = []
|
129
129
|
for provider in self._multiproviders[type_id]:
|
@@ -142,7 +142,7 @@ class Assembler:
|
|
142
142
|
return out # type: ignore[return-value]
|
143
143
|
else:
|
144
144
|
if type_id not in self._providers:
|
145
|
-
raise
|
145
|
+
raise TypeNotProvidedError(type_id)
|
146
146
|
|
147
147
|
provider = self._providers[type_id]
|
148
148
|
if provider.scope and provider.scope not in _get_scope():
|
@@ -226,9 +226,7 @@ class Assembler:
|
|
226
226
|
# store default to prevent the warning appearing multiple times
|
227
227
|
self._multiproviders[type_id] = root_providers
|
228
228
|
else:
|
229
|
-
|
230
|
-
msg = f"Missing Provider for type '{type_id}', available: {available}"
|
231
|
-
raise LookupError(msg)
|
229
|
+
raise TypeNotProvidedError(type_id)
|
232
230
|
|
233
231
|
# providers that must be satisfied to satisfy the root level providers
|
234
232
|
resolved_providers = [
|
engin/_cli/_check.py
CHANGED
@@ -4,6 +4,7 @@ import typer
|
|
4
4
|
from rich.console import Console
|
5
5
|
|
6
6
|
from engin._cli._common import COMMON_HELP, get_engin_instance
|
7
|
+
from engin.exceptions import TypeNotProvidedError
|
7
8
|
|
8
9
|
cli = typer.Typer()
|
9
10
|
|
@@ -35,20 +36,11 @@ def check_dependencies(
|
|
35
36
|
assembler = instance.assembler
|
36
37
|
missing_providers = set()
|
37
38
|
|
38
|
-
# Check dependencies for all invocations
|
39
39
|
for invocation in instance._invocations:
|
40
40
|
for param_type_id in invocation.parameter_type_ids:
|
41
41
|
try:
|
42
42
|
assembler._resolve_providers(param_type_id, set())
|
43
|
-
except
|
44
|
-
missing_providers.add(param_type_id)
|
45
|
-
|
46
|
-
# Check dependencies for all providers
|
47
|
-
for provider in assembler.providers:
|
48
|
-
for param_type_id in provider.parameter_type_ids:
|
49
|
-
try:
|
50
|
-
assembler._resolve_providers(param_type_id, set())
|
51
|
-
except LookupError:
|
43
|
+
except TypeNotProvidedError:
|
52
44
|
missing_providers.add(param_type_id)
|
53
45
|
|
54
46
|
if missing_providers:
|
@@ -58,13 +50,6 @@ def check_dependencies(
|
|
58
50
|
for missing_type in sorted_missing:
|
59
51
|
console.print(f" • {missing_type}", style="red")
|
60
52
|
|
61
|
-
available_providers = sorted(
|
62
|
-
str(provider.return_type_id) for provider in assembler.providers
|
63
|
-
)
|
64
|
-
console.print("\nAvailable providers:", style="yellow")
|
65
|
-
for available_type in available_providers:
|
66
|
-
console.print(f" • {available_type}", style="yellow")
|
67
|
-
|
68
53
|
raise typer.Exit(code=1)
|
69
54
|
else:
|
70
55
|
console.print("✅ All dependencies are satisfied!", style="green bold")
|