Getting started with oTree

To begin with, one is expected to know something about Python before starting to program in oTree. At times, Python can be intuitive to use, but it always helps to have a solid foundation of the language before diving deep into troubleshooting runtime errors.

Here are a few pointers to get started:

  1. To learn enough about Python to use oTree, it helps to go through the Python 3 Programming Specialization on Coursera.
  2. With ample Python knowledge, it helps to go through a hands-on tutorial to Learn Experiment Development with oTree. ⇽ This is a course on Udemy, created by Jonas Frey. It comes with 10-hour video tutorials and sample code for each tutorial. The tutorial uses oTree 5.

    Additionally, there are free resources on YouTube as well:

    1. Two playlists from Account Economics, a YouTube channel
    2. Jonas Frey’s YouTube channel

  3. As always, one should read the official documentation for oTree.
    • One may find the Conceptual overview helpful to conceptualize the different components in an experiment.
    • Additinoally, one may get confused by what is an “app” and what is a “project”. A good exercise is to try the following CLI commands that are shipped with oTree:
      • In a new directory, use otree startproject NewProject to create a new project, which comes with its own settings.py file, along with other Django folders.
      • Then, change directory to NewProject/, and use otree startapp NewApp to create a new app.

Developing oTree apps locally

One universal way to configure a local oTree development invironment is to install Anaconda from the commandline, which can be downloaded here.

Then, one can create a working oTree development by issuing the following commands in the terminal:

conda create -n oTree5 python 
conda activate oTree5
pip install otree

Deploying oTree apps for production

A common combination for the production cycle of an experiment is to use Github to manage the codebase, and to use Heroku for hosting the experiment.

One can mostly avoid interacting with Git by using the Github integration for Heroku. The steps are simple:

  1. Choose Github as the deployment method for the project, and
  2. Connect the entire oTree project repository to the Heroku project
  3. Click “Deploy Branch” in the Manual deploy section at the bottom of the Deploy page.

For very simple oTree projects, the steps above should suffice. Though, for production server setup, it is necessary to:

  1. Opt to a paid Dyno (CPU), and
  2. Add and configure two database add-ons: Heroku Redis and Heroku Postgres. These serve the purpose of storing all the experiment data.

If you have suggestions for what may enhance this page, please use this Google doc as linked.