Adding a code environment to a code studio template

Solved!
samanthamarkley
Level 2
Adding a code environment to a code studio template

I have created a code studio template that allows me to run Voila within my DSS instance, but I am having issues attaching a code environment to the template.

I have tried adding the code environment block to the template but have had no success. The only way I have been able to get the Python packages into the template is by installing them via the append to dockerfile block, but this is not ideal for my use case.

Any ideas on how I can include a code environment in the code studio template?

0 Kudos
1 Solution
samanthamarkley
Level 2
Author

The solution that worked for this was to first add my code environment block to my template and then active this code environment in my entrypoint file like:

# Activate code environment
source /opt/dataiku/python-code-envs/webapp_env/bin/activate

# Run the webapp
/opt/dataiku/python-code-envs/webapp_env/bin/python -m voila --Voila.ip="$BIND_ADDR" --no-browser --Voila.tornado_settings="{'allow_origin': '*'}" --Voila.base_url="$BASE_URL/" --port=8866 /home/dataiku/workspace/code_studio-versioned/Untitled.ipynb

These steps replaced the need for the "Append to Dockerfile" block. Note of caution: make sure you carefully select the Python and package versions, conflicts will cause the code studio to fail!

View solution in original post

4 Replies
JordanB
Dataiker

Hi @samanthamarkley,

You will need to build a template for CodeStudio with VScode and select a block type "ADD Code Environment" and then select the one you want to use. For new code env, create a new template.โ€‹
 
 
Screen Shot 2023-03-24 at 5.45.12 PM.png
 
Thanks!
Jordan
0 Kudos
williamwirono
Level 2

Hi @JordanB, say that I want to change my Python version from Python 3.6 to 3.7.10, how would I do that? I know that by default, it is installing Python 3.6. How do I let Dataikh know to install Python 3.7.10 instead?

0 Kudos
JordanB
Dataiker

HI @williamwirono,

If you have the python3.7 installed on your dss host machine and it is available in the env path variable. If you try to create a code env in DSS with python3.7 and you receive an error such as:

RuntimeError: failed to find interpreter for Builtin discover of python_spec='python3.7"  
This means DSS cannot find a Python 3.7 interpreter installed in the DSS host. There could be two reasons for this:
  • This python version is not installed in the host. In that case you'll need to install it or contact your sysadmin to get it installed.
  • This version is installed in the host, but it has not been added to the env PATH variable for the DSS user.
  • Basically, the following command should be executed successfully from the cli:    which python3.7

Thanks,

Jordan

0 Kudos
samanthamarkley
Level 2
Author

The solution that worked for this was to first add my code environment block to my template and then active this code environment in my entrypoint file like:

# Activate code environment
source /opt/dataiku/python-code-envs/webapp_env/bin/activate

# Run the webapp
/opt/dataiku/python-code-envs/webapp_env/bin/python -m voila --Voila.ip="$BIND_ADDR" --no-browser --Voila.tornado_settings="{'allow_origin': '*'}" --Voila.base_url="$BASE_URL/" --port=8866 /home/dataiku/workspace/code_studio-versioned/Untitled.ipynb

These steps replaced the need for the "Append to Dockerfile" block. Note of caution: make sure you carefully select the Python and package versions, conflicts will cause the code studio to fail!