Jump to content
  • Managing Environments in Spotfire® Data Science - Team Studio


    Creating an environment is the best practice for running Python code. Managing different environments means that you can keep each environment lightweight, importing in only what you need to execute the code. It can also avoid incompatibilities with different versions of the packages, a common problem with open-source packages. Conda is used to manage the environments within Team Studio. We will look at how to specify the dependencies in an environment, and how to create and remove an environment.

    Creating an environment is the best practice for running Python code. Managing different environments means that you can keep each environment lightweight, importing in only what you need to execute the code. It can also avoid incompatibilities with different versions of the packages, a common problem with open-source packages. Conda is used to manage the environments within Team Studio.

    We will look at how to specify the dependencies in an environment, and how to create and remove an environment.

    From a notebook, type the following command:

    image.png.689d64490d3076630f993fcdbb9d4125.png

    The environments listed may look a little different depending on what is available to you.

    We will create a YAML file where we will list all the dependencies we need. This can be more or less involved, depending on what you require to run your code. From the conda documentation, this can be as little as: 

    image.png.c53631356e4363dfd91f1fe370a288b4.png

    An example shown here for a new environment with the name PythonNLP:

    image.png.7bf7aa99671459e9d8eb53173e2d0890.png

    (Side note: the alpine package is for the Team Studio API)

    image.png.6b76fcfaa59f3fb76d0067ad22833bf4.png

    You should see your working notebooks as well as the environment.yml file.

    Run the following commands, which will update the environment dependencies, remove any unused packages and create the kernel in Jupyter:

    image.png.51fe2f7359b021498f790b5037445df2.png

    From the menu at the top of the notebook, select Kernel. Change the kernel to PythonNLP .

    image.png.da084e46adcf07bc1e32d5efa457956a.png

    Remember that in Team Studio, another user will not be able to see the kernel you created above. They must first create the environment.yml file and then update their environments in the same steps as above. The error would look like this when another user is trying to open your notebook:

    image.png.612b43a4b974303f9518a39b5c01b22d.png

    Finally, to delete the environment, run:

    image.png.ce4a94271e5a48221c80f2a77602c329.png


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...