Tecnológico de Monterrey BEER Lab
Back to Research · Research with BEER Lab

Implementation

Implement and operate your experiment

A practical guide to turn a reviewed project into a tested build, deploy it on the lab infrastructure, run sessions, and preserve the results.

Scope

From approved project to final export

The sequence below covers technical and operational implementation only. Use it as the shared reference for the research and lab teams during programming, validation, sessions, updates, and retirement.

01 · Infrastructure

Know the environment before coding

Each approved experiment runs as an independent service managed by the lab.

Dedicated address

The study receives an HTTPS URL such as name.beer-lab.org and oTree administrative access.

Database

The lab configures PostgreSQL, service credentials, and nightly operational backups.

Managed operations

The lab team deploys, updates, and retires the service from an identifiable release.

Technical assumptions

  • The runtime uses Python 3.11 on Linux. File names are case-sensitive.
  • The application receives its PostgreSQL connection through environment variables.
  • The container file system is ephemeral. Do not use it to retain data, uploads, or results.
  • One instance serves one experiment and supports up to a few hundred simultaneous participants. Report larger or unusual loads early.
Do not code against the infrastructure. Source code must not contain passwords, database URLs, local paths, Heroku domains, or localhost addresses.

02 · Code

Prepare a reproducible project

Start from the public template and keep the repository root as the oTree project root.

Minimum structure

my-experiment/
├── settings.py
├── requirements.txt
├── README.md
├── .gitignore
├── my_app/
│   ├── __init__.py
│   └── ...
├── _static/       # optional
└── _templates/    # optional

Do not nest a second oTree project inside the repository. settings.py must be at its root.

Safe configuration

from os import environ

ADMIN_PASSWORD = environ.get('ADMIN_PASSWORD')
SECRET_KEY = environ.get('SECRET_KEY')

# Keep SESSION_CONFIGS, SESSION_CONFIG_DEFAULTS, and ROOMS here.
# The lab supplies DATABASE_URL at deployment.
  • Do not define DATABASE_URL, DEBUG, or AUTH_LEVEL inside settings.py.
  • Prefix custom variables with OTREE_, read them with environ.get(), and document their purpose.
  • Define ROOMS when the operating flow uses room codes or persistent rooms.

Exact dependencies

otree==6.x.y
psycopg2-binary==2.9.10
# add every other dependency actually used below

Replace 6.x.y with the exact version used in testing. Do not include a Procfile, runtime.txt, or Dockerfile; the server builds the runtime.

Files that must not travel

.venv/
__pycache__/
*.py[cod]
*.sqlite3
.env
.otreezip
.DS_Store
exports/
participant_data/

Exclude local databases, exports, participant data, secrets, virtual environments, caches, and large binaries. Discuss videos or other heavy assets before deployment.

Recommended technical README. Record the tested oTree and Python versions, available configurations and Rooms, required variable names—not their values—runtime files, and expected load.

03 · Testing

Reproduce the study from scratch

The handoff must work away from the machine on which it was written.

Install and run

python -m venv .venv
# activate the virtual environment on your system
python -m pip install -r requirements.txt
otree devserver

Run automated tests

otree test

Include bots for the main paths and every critical branch. Passing automation does not replace a manual walkthrough.

Test the way it will run

  1. Create every SESSION_CONFIG and, where applicable, enter through every Room.
  2. Walk through treatments and contingencies in at least two independent browsers or profiles.
  3. Verify instructions, payments, timeouts, disconnects, and re-entry.
  4. Test planned devices, including phones if the study permits them.
  5. Install from a clean clone or ZIP using only the README.
  6. Simulate production with OTREE_PRODUCTION=1 and confirm no local data are required.
Exit criterion. Another team member can install, start, and complete the study without tacit knowledge or undocumented files.

04 · Technical handoff

Prepare the deployment release

Attach a specific technical release to the project record already approved in step 2.

Source code

  • Preferred: a repository URL accessible to the lab team, plus a specific tag or commit.
  • Alternative: a complete ZIP shared through a secure institutional channel. Include Git history when needed to identify versions.

Deployment factsheet

ItemWhat to report
ReleaseRepository and tag/commit, or ZIP name and date.
SubdomainA neutral name of 3–15 characters: lowercase letters, numbers, or hyphens; it must start with a letter.
ConfigurationsSESSION_CONFIGS, Rooms, and the flow used for each session type.
OperationsDates, number of sessions, expected simultaneous participants, and pilot window.
VariablesRequired variable names and purpose. Send secret values separately.
AccessThe authorized person who should receive the administrative URL and password.
Do not resubmit the proposal here. Protocol, ethics, recruitment, and resources were reviewed in step 2. This handoff adds only the executable release and technical metadata.

05 · Publication

Validate deployment with the lab

The lab builds the identified release; the research team confirms that it behaves like the approved build.

  1. Build. The lab installs dependencies, configures PostgreSQL, and loads the agreed variables.
  2. Correction. If the build fails, the research team supplies a new release; code is not patched without identifying it.
  3. Access. The public URL and administrative credential are sent through separate channels.
  4. Smoke test. The research team creates a test session, completes each flow, and verifies exports.
  5. Release. The service is enabled for the reported dates and load.
Schedule changes. An update usually causes about 15 seconds of downtime. Never deploy during an active session and leave time to test before the next group.

06 · Operations

Run sessions and export at the end

Use oTree administrative tools as operational controls, not as a replacement for the session protocol.

Before

Sign in through /login; confirm release, configuration, Room, links, capacity, and responsible staff.

During

Track progress in Monitor, log incidents, and never update the service while participants are connected.

After

Export data, verify record counts, and store a copy in the approved institutional repository.

Minimum export after every session

  • all_apps_wide: integrated longitudinal data across all apps;
  • per-app data: exports needed for the study's structure;
  • PageTimes: page timing when relevant to quality or diagnosis.
Nightly backups are operational recovery, not a research archive. The research team must export after every session and preserve data under the approved plan.

07 · Lifecycle

Control changes, versions, and retirement

Every deployment must map to a recoverable release and an explicit operating decision.

Change typeAction
Text, styles, or logic without model changesSupply a new release, document the change, and repeat affected tests. The database can usually be retained.
Data fields or modelsSchedule a window. oTree may require a database reset; export everything first and validate the new structure.
Material study changeReturn to the step 2 project record before implementation; further review may be required.
End of data collectionMake the final export, verify the files, and tell the lab when the service can be retired.

For each release, retain the tag or commit, date, owner, change summary, test results, and database decision.

08 · Diagnosis

Resolve common problems

Most deployment failures come from incomplete dependencies, Windows/Linux differences, or undeclared local files.

SymptomRecommended check
Installation failsConfirm every package is in requirements.txt, with a compatible version available for Python 3.11.
TemplateNotFoundMatch capitalization exactly in paths, templates, images, and static files.
CSS or images are missingCheck static paths and confirm the files are part of the supplied release.
A link points to localhostRemove hard-coded hosts and construct relative or request-based URLs.
Administrative login failsConfirm ADMIN_PASSWORD comes from the environment and AUTH_LEVEL is not overridden.
“Database is out of date”Stop sessions, export data, and coordinate a reset if the data model changed.
Files disappear after an updateDo not write results to service disk; use the database and controlled exports.

Implementation checklist

Has your project passed review and is it ready to build?

Use this page as the technical checklist. If the design, population, protocol, or any approved condition changes, update the project record before deployment.

Back to Research · Research with BEER Lab