Skip to content

Upgrading from Python 2 to 3

zagorsky edited this page Nov 8, 2019 · 7 revisions

Instructions for upgrading a scalable Beiwe cluster deployment from Python 2.7 to 3.6

Setup

Before anything else you will need to set up Python 3. 3.6 is the target version, although newer versions should work just fine.

Essentially all OSes will have a Python 3 runtime available through the usual channels (or already present). The executable may be named python3 in which case you will have to substitute that command for uses of python on your local machine. You may also have to install pip3. (This is the case on Ubuntu, which the manager/worker servers run.)

You should already have the Elastic Beanstalk Command Line Interface (awsebcli) configured; you can find documentation here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html

Upgrading the deployment to Python 3 will require the installation of AWS Command Line Tools (awscli). You can find documentation here: https://aws.amazon.com/cli/

OBNOXIOUS NOTE: there is (or was) a requirements incompatibility between awscli and awsebcli. The easiest fix is to just install each one via the pip command as needed. You will only need awscli briefly. (There are more extended solutions to the problem not described here.)

Steps:

  1. Go into the AWS online console and terminate any manager and worker servers you have running.

  2. Check out onto the downtime branch of the Beiwe Backend repo. This is a branch that is safe to use on Python 2 and 3 runtimes, and can generally be used whenever you have downtime needs. (This branch may be updated periodically, so you should pull whenever you deploy it. This is just basic git stuff.)

    git pull or git fetch

    git checkout downtime

    Using awsebcli deploy this branch to your target cluster.

    eb deploy [appropriate-cluster-name-here]

    You will know that downtime mode is active when the website states it is in downtime mode (load any page). Note that you may get a Severe status warning due to a high proportion of 400 or 500 errors. This is unavoidable, it is due to a design choice made back in 2014; we need to send the mobile app 400 or 500 errors or else it will think it's upload attempts completed successfully, otherwise it will delete the "uploaded data".

  3. Install awscli (the AWS Command Line Interface).

    The install command is pip install awscli or pip3 install awscli. After a successful install you should have access to a new command line tool which is simply aws.

Clone this wiki locally