|
|
@@ -1,5 +1,6 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
+from dataclasses import dataclass
|
|
|
import sys
|
|
|
from pathlib import Path
|
|
|
from typing import Any
|
|
|
@@ -8,6 +9,32 @@ from typing import Any
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
|
|
|
+@dataclass(frozen=True)
|
|
|
+class ServiceImportConfig:
|
|
|
+ service_name: str
|
|
|
+ libs: tuple[str, ...]
|
|
|
+
|
|
|
+
|
|
|
+SERVICE_IMPORT_CONFIGS: dict[str, ServiceImportConfig] = {
|
|
|
+ "agent-service": ServiceImportConfig(
|
|
|
+ service_name="agent-service",
|
|
|
+ libs=("core-domain", "core-shared", "core-db", "core-events"),
|
|
|
+ ),
|
|
|
+ "knowledge-service": ServiceImportConfig(
|
|
|
+ service_name="knowledge-service",
|
|
|
+ libs=("core-domain", "core-shared", "core-db"),
|
|
|
+ ),
|
|
|
+ "runtime-service": ServiceImportConfig(
|
|
|
+ service_name="runtime-service",
|
|
|
+ libs=("core-domain", "core-shared", "core-db", "core-events", "core-dsl"),
|
|
|
+ ),
|
|
|
+ "workflow-service": ServiceImportConfig(
|
|
|
+ service_name="workflow-service",
|
|
|
+ libs=("core-domain", "core-shared", "core-db", "core-dsl"),
|
|
|
+ ),
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
def prepare_service_import(
|
|
|
service_name: str,
|
|
|
*,
|
|
|
@@ -23,6 +50,15 @@ def prepare_service_import(
|
|
|
_prepend_sys_path(REPO_ROOT / "services" / service_name)
|
|
|
|
|
|
|
|
|
+def prepare_known_service_import(service_name: str) -> None:
|
|
|
+ config = SERVICE_IMPORT_CONFIGS[service_name]
|
|
|
+ prepare_service_import(config.service_name, libs=config.libs)
|
|
|
+
|
|
|
+
|
|
|
+def build_sqlite_database_url(tmp_path: Path, filename: str) -> str:
|
|
|
+ return f"sqlite:///{tmp_path / filename}"
|
|
|
+
|
|
|
+
|
|
|
def _prepend_sys_path(path: Path) -> None:
|
|
|
path_text = str(path)
|
|
|
if path_text in sys.path:
|