Code
Was this helpful?
Was this helpful?
The /code
folder contains all the scripts used in a Capsule. You can add files or folders to the /code
folder in the following ways:
Add via File Navigator: Use the plus signs at the top of the File Navigator.
Upload from Local System: Use the drop-down menu to drag and drop code files or folders from your local computer into the /code
folder.
For reproducibility purposes, files written to the /code
folder during a Reproducible Run are deleted once the run is completed.
A run
file (i.e., driver script) is the entry point into the Capsule during a Reproducible Run, and automates an end-to-end workflow.
Use Relative Paths:
Simplify portability by using relative paths (e.g., ../data
or ../results
) wherever possible. This ensures ease of use for those running the code locally.
Working Directory:
The initial working directory is /code
when your code is executed. Avoid referencing /code
explicitly by relying on relative paths instead.
Subfolders:
When referencing files in subfolders, use relative paths such as:
This example navigates up two parent directories to locate ./data/my_data.csv
.
Code Ocean supports multi-line editing for efficient code management.
To create a multi-line cursor:
Mac: Hold Option and click to place additional cursors.
Windows: Hold Ctrl+Alt and click to place additional cursors.
To return to a single cursor: Press Escape.