Running Node.js Notebooks in Watson Studio
How to create a custom environment for your data science notebook in Watson Studio
In an earlier blog post, Glynn Bird outlined how you can run Node.js-code Jupyter Notebooks on your local machine. With the introduction of custom environments, you can now use the same notebooks in IBM’s data science platform, Watson Studio.
When you run a Jupyter Notebook in Watson Studio, it is backed by an Anaconda-based environment. Out of the box, these environments have popular data science, visualization, and machine-learning packages pre-installed and support Python and R.
Today I’ll outline how I created a setup that enables me to run my pixiedust_node-based notebooks in the cloud.
Defining a custom environment supporting Node.js
In Watson Studio I’ve created a new project, navigated to the environment settings, and created a new environment definition.
Two parts comprise an environment definition: a hardware configuration and a software configuration.
The hardware configuration defines the resources that will be made available to notebooks that are associated with this type of environment. I typically choose the free tier (1 vCPU + 4GB RAM), but you might have to choose a more powerful setup if you are running resource-intensive code.
The software configuration defines the programming language that this environment will support, as well as packages that will be installed when the environment is started for the first time.
Keeping in mind that pixiedust_node currently only runs on Python 2.x and requires an existing Node.js installation, I’ve created a Python 2 environment and added the
nodejs conda package as a dependency to the software configuration.
Whenever a new instance of this environment is launched (e.g., by running a notebook), the listed packages will be installed.
Running notebooks in a Node.js-enabled environment
With this custom environment definition configured, I can run Node.js notebooks by associating them with it.
And there you have it, access to Node.js from the notebook cells.
In the sample above I’ve installed the
pixiedust_node package in cell number two for illustrative purposes. In a real life scenario I would add the package to the environment customization:
To learn more about pixiedust_node, take a look at the getting started notebook in this GitHub repository.