Terra provides infrastructure for running interactive analyses with Jupyter Notebooks, which are files that contain analysis code and embedded documentation. This article is to help enhance your ability to do interactive analyses with a deeper understanding of key components (i.e. Billing Projects) in Terra's notebooks environment.
To learn more about second article addresses key operations and how they impact your work, for example the amount of flexibility you have to customize the environment, how you will access data, and how to then save your analysis results.
|Content for this article was contributed by Matt Bookman from Verily Life Sciences based on work done in Terra for AMP PD, a public/private partnership collaborating toward biomarker discovery to advance the development of Parkinson’s Disease therapies.|
Glossary of Key Notebook Components
This section defines terms, and explains where notebook files and their output live -- both when you are working with the files and when you are not.
The kernel is the computer program that runs while you have a Jupyter notebook open. The kernel process maintains the runtime state of the Jupyter notebook.
Terra supports R and Python kernels. When cells in the notebook are executed, they are interpreted by this language-specific kernel. Note that Terra generally selects the kernel automatically, though it is always a good idea to check.
Notebook Service (aka Leonardo)
The Notebook Service manages the cloud environment (Compute Engine instance) you use to edit and run your notebook. In Terra, the notebook service is called "Leonardo," and the two terms are often used interchangeably.
Cloud Environment (aka "Cluster"; aka "Compute Engine VM")
When you interact with your notebook in a web browser on your own computer, the characters you type and code you execute are all sent to the Jupyter kernel process running on a Google Compute Engine virtual machine (VM) or Cloud Environment. Much of the discussion in this document involves understanding the Cloud Environment as a host for your notebooks.
In the rest of this article, your "Cloud Environment" refers to the Compute Engine VM running your notebooks as well as the VM boot disk and Persistent Disk.
When you create your Cloud Environment, by default you create a single VM. However, the Terra environment supports more powerful clusters of VMs using Google Cloud Dataproc. Use of a VM cluster is an advanced topic that is outside of the scope of this document.
VM boot disk
A virtual machine needs a disk ( the "boot disk") for storing data files, the operating system, or other software. Google Compute Engine's block storage option - the boot disk of the VM - is Persistent Disk. It is called "persistent" because the disk itself can persist even when the VM to which it is attached is paused. However, information on the boot disk is lost if you delete or update the cloud environment. For this reason, we try to avoid the (somewhat misleading) term "persistent disk."
Detachable Persistent Disk
When you create a Cloud Environment, Terra automatically creates a Persistent Disk to store libraries and packages, input files and generated outputs, even if you delete the Cloud Environment. This persistent disk is automatically detached from a VM prior to its deletion, and reattached to a newly created VM.
|Save any files you want to keep to your mounted Persistent Disk at /home/jupyter/notebooks. You only need to actively check that files are saved there when you are about to delete your Cloud Environment as well as the Persistent Disk, not when you pause and resume.
To learn how to copy data from a notebook to your workspace bucket, see this article
Docker is a (branded) container technology for packaging software for rapid deployment and reproducibility. Like a sandboxed virtual machine, Docker containers exist wholly inside the Compute Engine Virtual Machine. Docker images include all the software and tools needed for an analysis and can be quickly deployed on a Cloud Environment. To learn more about using Dockers, including custom Docker images, in Terra, see this article.
Every Terra Workspace has an associated Google Cloud Storage bucket for long-term storage of notebooks and other files. In "edit" mode, notebook files (i.e. only ".ipynb" files) are automatically saved to your workspace bucket. You can save other generated files to your workspace bucket manually (see this article for more details on how to do this).