Skip to content

Latest commit

 

History

History
121 lines (89 loc) · 3.3 KB

File metadata and controls

121 lines (89 loc) · 3.3 KB

Website Checks oTree License: MIT

unstructured-bargaining-experiment

An otree experiment for testing unstructured bargaining in a specific context.

Installation

It is recommended to use a virtual environment for the project (either through conda or venv):

conda (standard)

Create the environment

    conda create --name unstructured-bargaining-experiment -y python pip

Activate the environment:

    conda activate unstructured-bargaining-experiment
conda (local)

Create the environment

    conda create --prefix=venv -y python pip

Activate the environment:

    conda activate ./venv
venv

Create the environment

    python3 -m venv ./venv

Activate the environment:

    source venv/bin/activate  # Linux/Mac
    venv/Script/activate  # Windows

Then install the requirements in this isolated environment. We have to use pip as oTree is not on conda-forge yet.

    pip install -r requirements.txt

Testing locally

Open a terminal in the project folder and run

otree devserver

Then navigate to http://localhost:8000 in your browser. You can stop the server by pressing Ctrl+c in your terminal window.

Prod deployment

The Procfile is set up to start a production server on Heroku. Simply create an app, assign a dyno and a Postgres database, and deploy the app from this repo.

Automated checks

The project is set up with GitHub Actions to run automated checks on every push and pull request to the main branch. The checks include:

  • otree test for playing the experiment with automated bots
  • pyright for Python type checking
  • ruff check for Python code style
  • ruff format for Python code formatting
  • codespell for spell checking

You can also run these checks locally.

  • You can execute the otree test running otree test
  • For pyright, you need to have the pyright package installed.
  • ruff and codespell are implemented as pre-commit hooks.
Running the checks locally You can run the oTree test and get nice output with the following one-liner:
otree test 2> /tmp/stderr.log || cat /tmp/stderr.log; rm /tmp/stderr.log

For the rest, install pyright and pre-commit, e.g. using pipx:

pipx install pyright
pipx install pre-commit

Then, you can install the pre-commit hooks by running

pre-commit install

This will install the hooks and run them on every commit automatically.

Finally, you can run the pyright checks using

pyright

Please make sure that all checks pass before merging to the main branch.