Purpose: provide service access with dependency enforcement.
Service properties (each returns the corresponding engine service; when locked, access is allowed only if the service type is listed in module_dependencies.services)
services: a collection of allowed service types (e.g., ObjectStorageService)
modules: a collection of module names (strings), optionally suffixed with #soft
Usage
from naas_abi_core.engine.EngineProxy import EngineProxyfrom naas_abi_core.services.object_storage.ObjectStorageService import ObjectStorageService# engine: IEngine (provided by your runtime)# deps: ModuleDependencies (provided by your module system)proxy = EngineProxy( engine=engine, module_name="my_module", module_dependencies=deps,)# Access allowed services (raises ValueError if not declared in deps.services)obj_store = proxy.services.object_storage # requires ObjectStorageService in deps.services# Access allowed modules (filtered by deps.modules)other_modules = proxy.modules
Caveats
When unlocked=False (default):
Accessing a service not declared in module_dependencies.services raises ValueError.
Accessing a module not present in module_dependencies.modules is not possible via EngineProxy.modules.
#soft module dependency behavior:
If a dependency is listed as "some_module#soft" and that module is not present in engine.modules, it is silently skipped.
Without #soft, missing modules will result in a KeyError when building the returned mapping.