Source code for thesis.workflows.hcp.config.values
"""HCP configuration value resolution."""
from typing import Optional
from thesis.core.config import PipelineConfig
[docs]
def resolve_hcp_value(config: PipelineConfig, key: str, default: Optional[str] = None) -> str:
"""
Get HCP config value from PipelineConfig (supports extra dict fields).
PipelineConfig uses extra="allow" so protocol-specific keys like "hcp"
may be available as an attribute (dict) or not present.
Args:
config: PipelineConfig object
key: Configuration key to retrieve
default: Default value if key not found
Returns:
Configuration value as string
"""
hcp_cfg = getattr(config, "hcp", None)
if isinstance(hcp_cfg, dict):
value = hcp_cfg.get(key)
elif hcp_cfg is not None:
value = getattr(hcp_cfg, key, None)
else:
value = None
if value is not None:
return str(value)
return str(default) if default is not None else ""