Getting streamlit code studio to use the project code environment

info-rchitect
info-rchitect Registered Posts: 186 ✭✭✭✭✭✭

Hi,

I made a Python 3.8 code environment in dataiku that mimics the code environement I sue to run my streamlit app on my PC. However, the Streamlit app on dataiku seems to use a hard-coded code environment. Is there any way to configure this by the project owner?

thx


Operating system used: Windows 10

Tagged:

Best Answer

Answers

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker

    Hi @info-rchitect
    ,
    You can't configure a code env for the Streamlit Code Studio.
    You can, however add an additional package to the Streamlit block in the Code Studio template.

    Screenshot 2023-05-17 at 8.25.16 PM.png

    Hope that helps!

  • info-rchitect
    info-rchitect Registered Posts: 186 ✭✭✭✭✭✭

    @AlexT
    thx for the reply. Unfortunately fixing us to Python 3.7 is a non-starter as we need at least 3.81 to take full advantage of our Snowflake Python ecosystem. Can the default Python version for the Streamlit code studio be changed by our system admin?

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker

    Currently, there is no supported way to change Python3.7 for streamlit block, but we are actively working on making this available in a upcomming release.

  • raniachk
    raniachk Dataiku DSS Core Designer, Registered Posts: 3

    Hello @info-rchitect
    @AlexT
    ,

    Can't we solve this problem by appending the following lines in the Dockerfile of the Code Studio templates? We can delete the default version of python which is 3.7 and reinstall python3.10 for example here.

    USER root

    WORKDIR /opt/dataiku

    # Custom streamlit env with python 3.10

    RUN rm -rf /opt/dataiku/python-code-envs/pyenv-streamlit

    RUN python3.10 -m venv /opt/dataiku/python-code-envs/pyenv-streamlit

    RUN source /opt/dataiku/python-code-envs/pyenv-streamlit/bin/activate && pip install streamlit numpy==1.23.5 pandas

    USER dataiku

    WORKDIR /home/dataiku

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker

    Hi,
    You could try, but this would void support, and we wouldn't be able to provide any support around Streamlit.

    We plan on releasing a more robust way to include a custom code env for streamlit in upcoming releases.

    If you check INSTALL_DIR/resources/plugins/code-studio-blocks/python-code-studio-blocks/streamlit/codeStudioBlock.py this is hardcoded to Python37 right now.

    Thanks

  • importthepandas
    importthepandas Dataiku DSS Core Designer, Dataiku DSS & SQL, Dataiku DSS Core Concepts, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 115 Neuron

    @AlexT
    thanks for letting us know code studios are getting some attention. They are wonderful in general but could be much more flexible. The hack above works well for now to get 3.9 installed.

  • MyNamesJames
    MyNamesJames Registered Posts: 5

    I have tried to use a custom code env, but get the following error when trying to build the code studio template. It's not very helpful, so I have no way of knowing what went wrong.

    `Failed to build images for template streamlit_LLM : Failed to apply block : <class 'NameError'> : name 'name' is not defined`


    image.png
  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker

    @MyNamesJames

    Have you also added the code env block in the code studio template for the code env you plan on using?

    This is also required

    Also make sure you add altair<5 in the code requirements?

  • MyNamesJames
    MyNamesJames Registered Posts: 5

    Thanks @AlexT
    . That's what I was missing!

Setup Info
    Tags
      Help me…