Thread
#data-tricks-and-tips
    Falk

    Falk

    2 months ago
    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:
    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:
    with open(f"{file_name}.yaml", "r") as file:
        return yaml.safe_load(file)
    but also no luck. I always get
    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?
    Dominik Wagner

    Dominik Wagner

    2 months ago
    you might be able to do something like
    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)
    Falk

    Falk

    2 months ago
    That works, thank you @Dominik Wagner 🙏