This document contains instructions for creating reproducible environments.
- If you are on the lab workstation (
cogsci-mb-lab3.win.ad.jhu.eduat IP 10.160.192.70), ensure that yourcondais initialized by running/home/shared/miniconda3/bin/conda initand restarting your shell - If you are on MARCC, load the
anacondamodule usingml anaconda
Here's a sample environment.yml file that can be used to create environments using conda env create -f environment.yml:
name: <your-environment-name>
dependencies:
- python=3.9 # change your Python version here
- pip
- pip: # preferably, use `pip` to install packages
- numpy
variables: # please use these environment variables so we can have a shared torch and dataset cache
TORCH_HOME: "/data/shared/torch"
BONNER_BRAINIO_HOME: "/data/shared/brainio"
BONNER_DATASETS_HOME: "/data/shared/datasets"If you are on MARCC, envioronment variables cannot be set in the yml file due to lower conda version. To set the envioronment variables:
- Go to the directory of your conda envioronment. (You may check the directory with
conda env list) - Create
etc/conda/, in which createactivate.danddeactivate.d. - In
activate.d, createactivate.shto set all the enviornment variables needed (examples are some shared enviorment variables for the older repos without "bonner-" prefix):
export MT_HOME="/data/mbonner5/shared/brainscore/model-tools"
export CM_HOME="/data/mbonner5/shared/brainscore/candidate-models"
export BRAINIO_HOME="/data/mbonner5/shared/brainio"
export BRAINIO_DOWNLOAD_CACHE="/data/mbonner5/shared/brainio/bonner-datasets"
export TORCH_HOME="/data/mbonner5/shared/torch"- In
deactivate.d, createdeactivate.sh, in which writeunset <variable name>for all envioronment variables set inactivate.sh.
- Avoid installing any packages in the
baseenvironment - Use an
environment.ymlfile to create reproducible environments usingconda env create -f environment.yml pipinstall any additional packages you require, preferably using arequirements.txtfile andpip install -r requirements.txt- Installing packages from a
gitrepository- Run
pip install git+https://git.example.com/<project>.git@<git ref> git refcan be a branch name, a commit hash, or a tag name
- Run
- Installing packages in editable mode
- When working on a package, it is useful to have a development environment that changes with the source code in real-time
- Run
pip install -e "git+https://<project_url.git>#egg=<project_name>" --src <source_dir> <source_dir>is the location of the source code you are working on
- Faster installation of
condapackagesmambais a drop-in replacement for thecondapackage manager that has much faster dependency resolutionmambahas been installed in bothbasecondaenvironments on the lab workstation (conda install mamba -n base -c conda-forge)- To use it, run
mamba initand replacecondawithmambain (pretty much) all commands - Prefer
pipovercondathough thecondadocumentation recommends the converse
- Request access to the Bonner-Lab GitHub organization using the web interface and ask someone in the lab to approve the request
- Create a personal access token
- In
~/.config/git/credentials, add the linehttps://<github-username>:<personal-access-token>@github.com - TODO In
~/.config/git/config, add the lines
- Our shared datasets are stored in BrainIO format on the lab storage server (
cogsci-ml.win.ad.jhu.edu:/export/data2/shared/brainio/bonner-datasetsat IP 10.99.95.227) - When using the BrainScore libraries, the datasets are downloaded to your local cache from the storage server using
rsync - This dataset-fetching backend assumes your local machine running the code has SSH access to the storage server using public key authentication
- Generate an SSH key pair on your local machine using
ssh-keygen -t ed25519- Since you want automated access to the server, don't enter a passphrase when prompted; leave it blank
- Security concern: Keep your private key safe! If compromised, you should delete the corresponding public key from
cogsci-ml.win.ad.jhu.edu:~/.ssh/authorized_keysimmediately.
- Copy your public key to the storage server using
ssh-copy-id -i ~/.ssh/id_ed25519.pub <your_JHED>@10.99.95.227