mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-09-21 00:22:45 +00:00
up
This commit is contained in:
parent
e713fcd804
commit
92defa0949
2 changed files with 15 additions and 19 deletions
|
|
@ -42,7 +42,8 @@ class BaseJob(BaseComponent):
|
|||
raise ValueError(f"Unregistered backend '{config.backend}' of type '{ComponentEnum.STEP}'")
|
||||
params = config.model_dump()
|
||||
params["app_context"] = self.app_context
|
||||
self.step_components.append(step_cls(**params))
|
||||
step = step_cls(**params)
|
||||
self.step_components.append(step)
|
||||
|
||||
async def _close(self) -> None:
|
||||
self.step_components.clear()
|
||||
|
|
|
|||
|
|
@ -14,26 +14,21 @@ _SUPPORTED_EXTS = (".yaml", ".yml", ".json")
|
|||
_ENV_VAR_RE = re.compile(r"\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}")
|
||||
|
||||
|
||||
def _expand_env_vars(value: Any) -> Any:
|
||||
"""Recursively expand `${VAR}` / `${VAR:-default}` placeholders in strings.
|
||||
def _repl(m: re.Match) -> str:
|
||||
name: str = m.group(1)
|
||||
default: str = m.group(2)
|
||||
v = os.environ.get(name)
|
||||
if v is None:
|
||||
if default is not None:
|
||||
return default
|
||||
raise ValueError(f"Config references undefined env var: {name}")
|
||||
return v
|
||||
|
||||
Lets vault.yaml reference secrets / per-host settings without baking
|
||||
them into the file. Unset vars without a default raise ValueError so
|
||||
typos don't silently produce empty connection strings.
|
||||
"""
|
||||
|
||||
def _expand_env_vars(value):
|
||||
"""Recursively expand `${VAR}` / `${VAR:-default}` placeholders in strings."""
|
||||
if isinstance(value, str):
|
||||
|
||||
def repl(m: re.Match) -> str:
|
||||
name = m.group(1)
|
||||
default = m.group(2)
|
||||
v = os.environ.get(name)
|
||||
if v is None:
|
||||
if default is not None:
|
||||
return default
|
||||
raise ValueError(f"Config references undefined env var: {name}")
|
||||
return v
|
||||
|
||||
return _ENV_VAR_RE.sub(repl, value)
|
||||
return _ENV_VAR_RE.sub(_repl, value)
|
||||
if isinstance(value, dict):
|
||||
return {k: _expand_env_vars(v) for k, v in value.items()}
|
||||
if isinstance(value, list):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue