Import yaml file in Python

Touchpad Registered Posts: 2 ✭✭✭✭

Hi Everyone,

I am trying to migrate a model from GitHub repo to Dataiku, where part of the repo contains a Python script calling a yaml file.

I have used the import from GIT feature from the Library Editor. However my python script have no issue calling other .py files. But when trying to call the .yaml file, I get the error message "xxx.yaml not found."

Does anyone know how do I configure this?

Best Answer

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    Answer ✓

    Python will find .py files using its source paths mechanism, but that'll obviously won't apply when trying to access a file with open() (which is what I'm assuming you're doing with the yaml file). If the yaml file is in the source code along the py files, you could try building its full path from the relative path to the py file where you read it from, since you can have the full path of the python with the __file__ variable.

Setup Info
      Help me…