This is the home for our Python/FastAPI AWS backend for senior design. Please refer to the following sections for what you need.
- Install Python.
- Install Serverless Framework.
# Install dependencies (Ubuntu)
sudo apt-get install python3.8 python3.8-venv
# Install Serverless CLI + plugins
npm install -g serverless
serverless plugin install -n serverless-python-requirements- Clone repository.
- Set up a Python virtual environment and install modules from
requirements.txt. - Set up Serverless CLI with AWS credentials (ask Quikks1lver for credentials).
# Clone repository
git clone git@github.com:ContentWarnings/Backend.git
cd Backend
# Configure venv
python3 -m venv venv
source venv/bin/activate
# Install dependencies
python3 -m pip install -r requirements.txt
# Configure Serverless with AWS keys
serverless config credentials --provider aws --key <aws_key> --secret <aws_secret>- Create a new feature branch using your name. Example:
adam/bug-fix. - Make relevant code changes in
src/. - Very important: Test your code by spinning up the AWS resources in your testing stage! To do so, open
serverless.yaml, and edit names forstage, DynamoDB tables, andapiKey. To deploy your changes, runsls deploy. Remember to revertyamlchanges prior to PR. - Ensure you run the
blackcommand to format code prior to attempting a merge. - Add any new modules to
requirements.txt. - Cite your sources! (see guide below)
- Submit a pull request (PR), and ensure any testing/formatting pipelines pass. Fill out PR template fully, attaching images if necessary to help your reviewers.
- Respond to other teammate's comments and merge in when approved.
- Delete your feature branch (should automatically do so on GitHub), and start the process over again for new changes.
# Create new branch
git checkout -B adam/bug-fix
# Enter venv
source venv/bin/activate
# Run Black to make sure formatting is compliant.
black src/*
# Running Pytests locally
# Step 1: export env. vars via terminal.
export TMDB_API_KEY=...
export MOVIES_TABLE=...
export JWT_ALGORITHM=...
...
# Step 2: run test command.
pytest
# Push to Git.
git add .
git commit -m "Push bug fix"
git push origin adam/bug-fix# (all in project root)
python3 -m pip install gunicorn
export TMDB_API_KEY=...
export MOVIES_TABLE=...
export JWT_ALGORITHM=...
...
python3 -m gunicorn src.main:app --worker-class uvicorn.workers.UvicornWorker- Ask yourself if the resource can be cited at all. If the resource is a tutorial, you can implicitly use the technique, but without a license, do not reference or use any code.
- If referencing code using a permissive license (ex: MIT, Apache 2.0, etc.), cite via a comment in relevant code file(s). This can be as simple as a URL since we will cite more.
- Create a full APA citation and attach to our senior design document bibliography.
- This last step is if you use/reference code, not necessarily for general help: include the license copyright in
licenses_references/, in the relevant file.
Reach out to Quikks1lver; he's happy to help!