fix: add import path support for python sources

This commit is contained in:
lda
2026-06-12 09:07:05 +07:00 Verified
parent 4bd321e905
commit a0bc27b051
9 changed files with 135 additions and 2 deletions
+22
View File
@@ -5,7 +5,9 @@ from pathlib import Path
from .models import (
FilesystemStoreConfig,
PythonSourceConfig,
ServerStoresConfig,
SourceConfig,
StoreConfig,
WorkflowConfigFile,
)
@@ -49,6 +51,10 @@ def _resolve_store_paths(
update={
"store": _resolve_store(server.store, base_dir=base_dir),
"stores": resolved_stores,
"sources": _resolve_source_paths(
server.sources,
base_dir=base_dir,
),
}
)
}
@@ -63,3 +69,19 @@ def _resolve_store(
if isinstance(store, FilesystemStoreConfig) and not store.root.is_absolute():
return store.model_copy(update={"root": (base_dir / store.root).resolve()})
return store
def _resolve_source_paths(
sources: list[SourceConfig],
*,
base_dir: Path,
) -> list[SourceConfig]:
resolved: list[SourceConfig] = []
for source in sources:
if isinstance(source, PythonSourceConfig) and not source.path.is_absolute():
resolved.append(
source.model_copy(update={"path": (base_dir / source.path).resolve()})
)
else:
resolved.append(source)
return resolved
+1
View File
@@ -104,6 +104,7 @@ class PythonSourceConfig(WorkflowConfigModel):
kind: Literal["python"] = "python"
id: str
enabled: bool = True
path: Path = Path(".")
module: str = Field(min_length=1)
registry: str = Field(default="registry", min_length=1)