Tutorial: publishing a library/package on Code Ocean

With reference to R and Python packages.

Written by Shahar Zaks Updated over a week ago

Background:

Many published capsules on Code Ocean present the results of a published or forthcoming journal article. Some capsules, however, present a suite of functions and/or datasets intended for general use (and some accompany journal articles that are primarily about a package). This tutorial walks through readying a software library for sharing or publication on Code Ocean.

Third, begin a new run script. You can do so by either following the instructions here or by creating a new file in the /code directory called run .

We recommend that you begin your run script with the shebang#!/usr/bin/env bash and the set -exflag on lines 1 and 2. This will happen automatically if you hover over a file and select 'Set as File to Run'.

Fourth, if needed,write the needed commands to install the package locally.

In Python, this will look something like pip install -v . ;

in R, something like Rscript -e "devtools::install() . (The specific flags you set, as well as any path-related details, will be unique to your capsule).

Note: we recommend strongly (and require for publication) that your capsule not access any internet resources during runtime. All dependencies should already be installed through the environment, and any datasets should be uploaded to the capsule itself.

Fifth, if you have any sample scripts -- such as an .Rmd vignette or a representative Jupyter notebook -- that walk users through how to use the included functions, you can add a line to the run script to execute it.