feat: load neutral workflow config

This commit is contained in:
lda
2026-06-03 08:33:33 +07:00 Verified
parent a071ba1085
commit 1a3fe5916e
3 changed files with 78 additions and 0 deletions
+2
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
from .loader import load_workflow_config
from .models import (
ClientConfig,
FilesystemStoreConfig,
@@ -12,6 +13,7 @@ from .models import (
)
__all__ = [
"load_workflow_config",
"ClientConfig",
"FilesystemStoreConfig",
"LocalTargetConfig",
+32
View File
@@ -0,0 +1,32 @@
from __future__ import annotations
import json
from pathlib import Path
from .models import FilesystemStoreConfig, WorkflowConfigFile
def load_workflow_config(path: str | Path) -> WorkflowConfigFile:
"""Load neutral workflow config and resolve local filesystem paths.
Relative filesystem store roots are config-file relative so `wf --config`
behaves the same regardless of the caller's current working directory.
"""
config_path = Path(path)
data = json.loads(config_path.read_text(encoding="utf-8"))
config = WorkflowConfigFile.model_validate(data)
store = config.server.store
if isinstance(store, FilesystemStoreConfig) and not store.root.is_absolute():
config = config.model_copy(
update={
"server": config.server.model_copy(
update={
"store": store.model_copy(
update={"root": (config_path.parent / store.root).resolve()}
)
}
)
}
)
return config