Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
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
I'm able to access a file that I uploaded to the resources directory of a code env, as shown below:
## 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
I can then access the cert using the following code in a notebook with the kernel set to my code env:
cert_path = os.environ["MY_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:
If you're still not able to get it working, please provide provide the following information:
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.