Personalized, basic structure of a Code Ocean capsule.
Based on aind-capsule-template with the following customizations:
- /LICENSE: Allen Institute custom license (AIND uses MIT license)
- /environment/postInstall_template: contains code to install an updated version of code-server (open source VS Code) + a set of useful VS Code extensions (e.g. Python, Jupyter, autoDocstring, Git Graph)
- /code/vscode_settings_template.json: contains a few key settings to configure your VS Code sessions (e.g. color theme, git askpass, ruler)
Instructions for how to use this GitHub template to create a new Code Ocean capsule.
- On this template's homepage, https://github.com/meghanaturner/code-ocean-capsule-template/, click on the green
Use this template
button in the upper right and selectCreate new repository
from the dropdown menu. - Give your repo a name & description. Decide whether the owner will be your personal account or the AllenInstitute organization.
- If you make the owner the AllenInstitute organization, then you also need to decide if it will be public, internal, or private. For most capsules, I default to private & share it directly with any collaborators I want to have access so I don't clog up the AllenInstitute repo list with a bunch of abandoned exploratory analysis capsules.
- Edit metadata to reflect your new repo's details in the following files:
/metadata/metadata.yml
- edit name, description, authors (this will make sure your new CO capsule starts with the correct metadata info)/README.md
- edit title & to remove these instructions
- In Code Ocean (https://codeocean.allenneuraldynamics.org/), create a new capsule:
Create
(circled plus ⊕ symbol in lefthand menu)- Use the
Capsule: Clone from Git
option - copy+paste the URL to the new repo you created in (A) into the box (Note: you might need to add
.git
to the end of the URL in order for this to work) -> clickConfirm
- In order to create a CO capsule from a repo, you must have your GitHub credentials added to your CO account:
- Go to
Account
(person symbol at bottom of lefthand menu) ->Credentials
-> ⊕Add Credentials
(blue button, upper right) - Select
GitHub Credentials
from dropdown menu & follow instructions in the pop-up window
- Go to
- In the
Environment
GUI of your capsule, scroll down to thePost-Install Script
section and click the blue hyperlinkEdit Post-Install Script
- Copy the contents of the
Environment > postInstall_template
file into thepostInstall
file that was just created by the GUI - Start up a VS Code cloud workstation. postInstall will run as part of the environment build and should install the newer code-server version & extensions.
Since the postInstall
file includes instructions to store the code-server installation in our /capsule/code/
directory, which is stored in your new GitHub repo, you should only have to do these steps once; your preferences will persist across any subsequent workstation sessions.
-
To quickly add a few key preferences in a single step, while in your VS Code cloud workstation:
- Copy the contents of
/code/vscode_settings_template.json
into/capsule/code/.vscode/User/settings.json
- You may need to reload the CO window for this change to take effect.
- Copy the contents of
-
Alternatively, you can set any preferences you'd like manually. For example, three preferences that are set in
/code/vscode_settings_template.json
are described in detail below:- Change Color Theme:
F1
-> start typingPreferences: Color Theme
& select when it pops up via autocomplete -> e.g. select “Dark (Visual Studio)” for dark theme - Add a 80 character Ruler to all text editor windows (including Jupyter notebooks):
- Open the Settings UI (
File
->Preferences
->Settings
, ORCtrl+,
) - Search for “Editor: Rulers” > click on
Edit in settings.json
- Add the item:
"editor.rulers": [80]
- Open the Settings UI (
- Stop VS Code from making you sign in to GitHub every. single. session.
- Open the Settings UI (
File
->Preferences
->Settings
, ORCtrl+,
) - Search for “Git: Use Integrated Ask Pass"
- Uncheck the box for “Git: Use Integrated Ask Pass / Controls whether GIT_ASKPASS should be overwritten to tuse the integrated version" (This setting is checked by default and is telling code-server to override the intended mount code-ocean behavior where your GitHub credentials are stored as a token credential.)
- You may need to reload the CO window for this change to take effect
- Open the Settings UI (
- Install any additional Extensions not specified in the
postInstall
script
- Change Color Theme:
-
(Optional) Install GitHub Copilot
- See the relevant section in AIND's Code Ocean Best Practices doc (can be found in the Code Ocean Teams channel under the Files tab) for details