Share R notebooks

Two collaborating researchers with access to the same environment can share code in R (not currently supported in Python).

To share a notebook, follow this procedure:

Step 1:

If you have not already done so, import the R library into your Notebook workspace:

# This command imports the Facebook Research R Library
library(reticulate)
use_python('/opt/conda/bin/python', required = TRUE)
library(fbrir)

Step 2:

Invoke the R library function that initiates the notebook upload workflow:

# This is the S3 library that we are invoking to upload notebooks
facade = S3Facade$new()

Step 3:

Run the command to prompt the uploader, which displays the Upload Agreement:

facade$PromptUserUploadAgreement()

The Upload Agreement is followed by a prompt (shown below) to either agree to or reject the agreement. To continue, type Agree (case sensitive) and press Return.

Step 4:

Upload the notebook to the shared S3 bucket with the following command:

facade$PutFileInGlobalShareBucket("relative_key", "file")
# Replace relative_key with the name you want this notebook to have when uploaded
# Replace file with the relative path to where the notebook is located

Example:

facade$PutFileInGlobalShareBucket("sample_notebook_by_kiran.ipynb", "notebook_to_share.ipynb")

Step 5:

View the list of notebooks that are in the shared bucket:

facade$ListGlobalShareBucket()

You should see the notebook you uploaded in the list:

Step 6:

Download a shared notebook to the local Elastic Block Store (EBS) Jupyter folder:

# Add the filename, whether you want to overwrite an existing notebook, and the name you want for the file in your folder 
facade$SaveGlobalShareObject("user/10158633909214868/sample_notebook_by_kiran.ipynb", overwrite=FALSE, file="copy_of_shared_notebook.ipynb")