Survey banner
Switching to Dataiku - a new area to help users who are transitioning from other tools and diving into Dataiku! CHECK IT OUT

How to load a file to Resources directory and have available at run time

Level 3
How to load a file to Resources directory and have available at run time

How can I simply upload a zipped certificate file to the resources directory and then update the code environment and have that certificate file available at run time?

I upload the file, change the script to include a Environment Variable to point to the folder, and give permissions to the folder.  Then at run time, the environment variable does contain the path to the runtime Resources folder, but there is nothing in the resources folder. 

Where is a documented example of how to upload a file to the Code Environment Resources Directory and make it available at runtime?

Operating system used: centos

0 Kudos
3 Replies

Hi @clayms,

I'm able to access a file that I uploaded to the resources directory of a code env, as shown below:


Initialization script:


## Base imports
from dataiku.code_env_resources import clear_all_env_vars
from dataiku.code_env_resources import set_env_path
from dataiku.code_env_resources import set_env_var

# Clears all environment variables defined by previously run script

# Set the path to the cert file
set_env_path("MY_CERT_PATH", "cert/cert.crt")


I can then access the cert using the following code in a notebook with the kernel set to my code env:

import os

cert_path = os.environ["MY_CERT_PATH"]
print("cert_path:", cert_path)

with open(cert_path, "r") as file:


Could you please double check that the path to the file is correct? For example, in my above test, the cert is located in a subdirectory called "cert", so I set the relative path to "cert/cert.crt".

Please also make sure that you've updated the code env after changing the init script and uploading the file. If you're trying to access the cert from a notebook, please also make sure that you've restarted the kernel after updating the code env.

Additionally, per our documentation, please make sure that your code env meets the following requirements:

  • Code environment resources require the core packages to be installed.
  • Code environment resources are not supported on external conda code environments.
  • Code environment resources are not made available to Spark executors.


If you're still not able to get it working, please provide provide the following information:

  • A screenshot of the Resources tab of your code env similar to my screenshot above.
  • The code that you're using to access the cert file, as well as the error message you're getting.
  • How you're accessing the resources script. For example, are you accessing it from a Python recipe, or a notebook?
  • Are you using containerized execution, or is your Python code running locally?




0 Kudos
Level 3

Code-Env for containers is missing the path

ENV points me to this location:



But files are located in this other location:


0 Kudos
Level 3

See my answer to a question posted 12 or so hours after mine here :


The documentation is poor.  Also, I was told by Dataiku to check the  "Rebuild env", then rebuild.  This was the issue.  That said, I did have to rebuild the environment for the file to be available in a container.  I already had the "copy" option selected in the containerized so that was not the issue.

The interplay between the "rebuild env" and "Run resources init script" and the options in Code Env > Containerized Execution > Resources initialization  and when files get downloaded, when what you uploaded gets removed, and when those files gets put into a container and poorly documented and should be revised.