Developer Setup

Requirements and Preparation

  • MySQL 8.0. See MySQL Setup for Plant Tracer

  • Python3.11. Verify that typing ‘python’ gives you python3.11. If it doesn’t, make sure that your PATH is up-to-date.

  • HomeBrew. If installing on a MacOS machine, HomeBrew must be installed prior to performing the steps below.

Setup Steps

  1. Clone the Plant Tracer webapp into a directory that will be the local repository, for example:

    git clone --recurse-submodules https://github.com/Plant-Tracer/webapp.git webapp
    
  2. Change to the local repository directory:

    cd webapp
    
  3. Make a Python Virtual Environment (venv):

    make venv
    
  4. Activate the venv:

    . venv/bin/activate
    
  5. Install the prerequisites with make install-<your-os>, e.g.:

    make install-macos
    
  6. Create a new local database

    • The database will be named actions_test by default

    • You may override the default with the PLANTTRACER_LOCALDB_NAME environment variable

    export MYSQL_ROOT_PASSWORD="your-mysql-root-password"
    make create_localdb
    
  7. Run the self-tests:

    PLANTTRACER_CREDENTIALS=etc/credentials.ini make pytest-quiet
    
  8. Create your first course! If you want, give it a demo account too:

    PLANTTRACER_CREDENTIALS=etc/credentials.ini python dbmaint.py --create_course "My Course Name" --admin_email your_admin_email@company.com --admin_name "Your Name" [--demo_email your_demo_email@company.com]
    >>> course_key: leact-skio-proih #save this course_key, you will need it later!
    
  9. You now have a course key! If the demo account is made, you have that too.

  10. In order run a non-demo instance, a mailer must be configured in the credentials ini file, for example:

    [smtp]
    SMTP_USERNAME=plantadmin@mycompany.com
    SMTP_PASSWORD=MyPassword
    SMTP_PORT=587
    SMTP_HOST=smtp.mycompany.com
    
    [imap]
    IMAP_USERNAME=plantadmin@mycompany.com
    IMAP_PASSWORD=MyPassword
    IMAP_HOST=imap.mycompany.com
    IMAP_PORT=993
    
  11. If you have created a demo account, that action has also added demo movies to the database. To finish setting up demo mode, run the server in non-demo mode, track all the demo movies manually, and publish them.

Running Locally Quick Start

  1. Run Plant-Tracer/webapp locally using the database created above and the default etc/credentials.ini file

    make run-local # Ctrl-C to quit
    
  2. To run a Plant-Tracer/webapp server process locally, examine the debug-* targets in Makefile. The general form is:

    PLANTTRACER_CREDENTIALS=${MY_INI_FILES}/credentials-myconfig.ini python bottle_app.py [arguments]
    
  3. A specific case: running with movies stored in MySQL rather than S3:

    PLANTTRACER_CREDENTIALS=${MY_INI_FILES}/credentials-myconfig.ini python bottle_app.py --storelocal
    
  4. Another case: running in demo mode, with movies stored in MySQL rather than S3:

    • Note: there must be no user logged in for demo mode to take effect. May have to clear browser cookies.

    PLANTTRACER_CREDENTIALS=${MY_INI_FILES}/credentials-myconfig.ini PLANTTRACER_DEMO_MODE_AVAILABLE=1 python bottle_app.py --storelocal
    
  5. Sometimes, it is necessary to manually clear the cookies that Plant-Tracer/webapp creates in a browser. These cookies are of the form “api_key-“+my_database_name. Here is an example:

_images/PlantTracerCookieExample.png