Hey everyone, I have a bit of an issue with one of...
# data-tricks-and-tips
f
Hey everyone, I have a bit of an issue with one of my flows. I'm trying to read a yaml file containing configuration like this in my `flow.py`:
Copy code
with open(f"{os.getcwd()}{file_name}.yaml", "r") as file:
    return yaml.safe_load(file)
Both
flow.py
and
file.yaml
are in the same directory. I also tried setting the path without cwd and like this:
Copy code
with open(f"{file_name}.yaml", "r") as file:
    return yaml.safe_load(file)
but also no luck. I always get
Copy code
FileNotFoundError: [Errno 2] No such file or directory: '/file.yaml'
Any ideas what is causing this? Do I have to specify files other than
.py
files for the agent somehow?
d
you might be able to do something like
Copy code
path = os.path.join(os.path.dirname(os.path.realpath(__file__))),f"{file_name}.yaml")

with open(path, "r") as file:
    return yaml.safe_load(file)
🙌 2
2
f
That works, thank you @Dominik Wagner 🙏
🎉 2