Making Python code safe for file paths

Options
info-rchitect
info-rchitect Registered Posts: 169 ✭✭✭✭✭✭
edited July 16 in Using Dataiku

Hi,

When running code that uses the `Pathlib` library in a dataiku jupyter notebook, I am getting errors because it cannot find the files as it can when I run in regular Python.

# self.controller.config is a Path instance
self.credentials_file = self.controller.config_dir / 'snowflake_credentials.yaml'

Operating system used: Windows 10

Tagged:

Answers

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker
    Options

    Hi @info-rchitect
    ,

    I've done some experimenting with pathlib on my end, but I haven't experienced any errors.

    Could you please provide a complete code example and the error message that you're getting so that I can better help you?

    Thanks,

    Zach

  • info-rchitect
    info-rchitect Registered Posts: 169 ✭✭✭✭✭✭
    edited July 17
    Options

    ZachM,

    The issue is when trying to debug code in Jupyter notebook vs running in a webapp or a recipe. I solved the problem by ditching `Pathlib` and just using `os`:

    os.path.dirname(os.path.realpath(__file__))
Setup Info
    Tags
      Help me…