Skip to content

xdr1xnl0p3z/python-service-template

Repository files navigation

Python Service Template

This is the Fondeadora Python serverless framework template. It is intended to be used with Python v3.7 but could be updated to more recent versions.

Contents

This template includes the following extra configurations:

It will, by default set the stage to dev and the region to us-east-1.

Pre-commit is configured to run pyformat and flake8 on the pre-commit hook.

Usage

First you should have Node.js, yarn and Python v3.6 installed on your machine.

  1. Install the serverless framework with
npm install -g serverless
  1. Install the serverless framework plugins required.
npm install
  1. Create a virtualenv for python
yarn venv-setup
  1. Install python dependencies
pip install -r requirements-dev.txt
  1. Install the pre-commit hooks.
pre-commit install

And that’s all.

To initialize a new repository using this template use the following command:

serverless create--template-url https://github.com/Fondeadora/python-service-template--path my-service

Make sure you replace myService with the name of your service and update the service.name in serverless.yml file.

Then start your development environment with

sls offline

Scripts

# Deploy dev
yarn deploy

# Deploy production
yarn deploy-prod

# Test
python -m unittest discover

Formatting and linting

make format
make lint

Further notes

By default, pre-commit will not update the staging area, so make sure to review any changes that the black code formatter do to your files before restaging them.

Flake8 will fail if it encounters any errors, so you can review and fix them appropriately.

Make sure to add any new dependencies in the requirements.txt file.

Suggestions

Please open an issue so we can discuss changes to this template.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published