Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
I'm trying to load a transformer model through the env Resources but it does not work as it does not set the variables
I tried the following as a test:
import os
from dataiku.code_env_resources import clear_all_env_vars
from dataiku.code_env_resources import set_env_var
from dataiku.code_env_resources import get_env_var
# Clears all environment variables defined by previously run script
clear_all_env_vars()
# Sets a test variable in the environment
set_env_var('test', 'This is a test')
# Prints the variable to test the access
print(get_env_var('test'))
In the log I can see the variable test is kind of created and accessed.
*********************************************************
{'value': 'This is a test', 'type': 'RAW_STRING'}
*********************************************************
But if I try to access the variable in my notebook (with the correct environment selected), it's like it doesn't exist:
import os
os.environ['test']
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
/tmp/ipykernel_3089981/4148336718.py in <cell line: 0>()
1 import os
2
----> 3 os.environ['test']
/usr/lib64/python3.11/os.py in __getitem__(self, key)
677 except KeyError:
678 # raise KeyError with the original key value
--> 679 raise KeyError(key) from None
680 return self.decodevalue(value)
681
KeyError: 'test'
Does anyone know what I am doing wrong?
Thanks in advance
Hi @rump ,
Have you tried to "force reload" from the top right of the notebook after updating the code environment?
If you have and still don't see the variables, please share the exact DSS version you are using.