Closed
Description
Hi, I'm using Configuration.from_yaml()
to read template strings in a yaml file like below:
template_string: |-
Hi! My name is ${name}.
I'm ${age} years old.
I'm living in ${country}.
And When I read the yaml file, the variables string in the yaml file disappear.
class Container(DeclarativeContainer):
config = Configuration()
config.from_yaml(yaml_dir / "introduce.yaml")
...
container = Container()
print(container.config.template_string())
# Hi! My name is .\nI'm years old.\nI'm living in .
But when I use pyyaml
directly, it doesn't have any problem.
class Container(DeclarativeContainer):
config = Configuration()
config.from_pydantic(PydanticConfig())
# config.from_yaml(yaml_dir / "introduce.yaml")
introduce_yaml_path = yaml_dir / "introduce.yaml"
with open(introduce_yaml_path, "r") as f:
loaded = yaml.safe_load(f)
config.from_dict(loaded)
print(container.config.template_string())
# Hi! My name is ${name}.\nI'm ${age} years old.\nI'm living in ${country}.
Could you guys clear up what happens in from_yaml()
?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels