refactor: fix some imports
This commit is contained in:
@@ -3,6 +3,8 @@ from __future__ import annotations
|
||||
from functools import lru_cache
|
||||
from typing import Any
|
||||
|
||||
from wasmtime import Config, Engine
|
||||
|
||||
from .loader import WasmExtension
|
||||
|
||||
|
||||
@@ -12,14 +14,6 @@ def warm_wasm_extension(extension: WasmExtension) -> None:
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _wasm_engine() -> Any:
|
||||
try:
|
||||
from wasmtime import Config, Engine
|
||||
except ImportError as exc:
|
||||
raise RuntimeError(
|
||||
"WASM extension runtime is not installed. Install the 'wasmtime' "
|
||||
"Python package to run WASM extensions."
|
||||
) from exc
|
||||
|
||||
config = Config()
|
||||
config.wasm_component_model = True
|
||||
return Engine(config)
|
||||
|
||||
@@ -5,6 +5,8 @@ import re
|
||||
from collections.abc import Mapping
|
||||
from typing import Any
|
||||
|
||||
from wasmtime import component
|
||||
|
||||
from ..api.models import EmptyRequest
|
||||
from ..api.registry import list_extension_api_methods
|
||||
from ..api.runtime import ExtensionAPIHost
|
||||
@@ -73,7 +75,6 @@ def _component_payload_to_dict(value: Any) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _dict_to_component_record(value: Mapping[str, Any]) -> Any:
|
||||
from wasmtime import component
|
||||
|
||||
record = component.Record()
|
||||
for key, item in value.items():
|
||||
|
||||
Reference in New Issue
Block a user