Submit your use case or success story to the 2023 edition of the Dataiku Frontrunner Awards ENTER YOUR SUBMISSION

Use file from code env resources directory with API Test queries

Level 3
Use file from code env resources directory with API Test queries

I've built a python API endpoint that uses a certain code environment.

In the resources folder of that code environment is a file.

If I run the API code in a notebook using that code env, I'm able to access that file. But when I run Test queries in the API Designer, the file cannot be found. The code used is the same in both instances.

It seems when you run Test Queries, a temporary API node is created which the queries are then run against. However the file from the code env resource directory seems to not be copied to that temp instance.

What am I doing wrong?

I store the path to the resource directory in an environment variable in the code env using a resource script, which stores the relative path. I have "Run resources initialization script on API node." checked.

# Set data cache directory
set_env_path("CERT_CACHE", "certificate")

# Grant everyone read access to files in folder

When I read that variable from a notebook using the code env by running os.getenv("CERT_CACHE") it reads 


and when I run Test Queries in the API Designer it reads as



Operating system used: Windows


0 Kudos
1 Reply
Level 3

I managed to find a workaround.

Still interested to know if it's possible for APIs to "inherit" files in the code env resource directory if they were manually added.

0 Kudos


Labels (2)

Setup info

A banner prompting to get Dataiku