This is a template project to demonstrate how to integrate with PolyAPI in a git-centric python workflow.
To make use of this template you'll need the following installed:
- Python3 with pip3
- Git
- Bash or similar shell environment
If you're on MacOS or Linux there's a good chance you already have these installed on your system.
In addition you'll need an API key for PolyAPI. If you don't have one, signup at: https://polyapi.io/
And lastly you'll need a github account, and be able to make commits to it from git in your shell.
-
Clone this repository from Github using
git clone --branch main --single-branch https://github.com/polyapi/poly-glide-template-py.git your-repository-name(Be sure to change the destination name to be whatever you want) Or you can download the template project as a zip file. -
From within your local project directory disconnect from the template repositoy:
git remote remove origin -
Set up a new repository in github using the same name as the directory you cloned into in step 1.
-
Setup the necessary repository secrets in github which will be used to deploy your code.
Add
POLY_API_KEY_PRODandPOLY_API_BASE_URL_PRODas action secrets in your git repo.See Github documentation for more details on creating secrets.
-
Update Github actions workflow permissions to
Read and write permissionsclick
Save -
Connect you local project with your new remote repository by running
git remote add origin https://github.com/yourusername/your-repository-name.gitfollowed bygit push --set-upstream origin main -
Update the
pyproject.tomlname, description, author, and license fields to your satisfaction. And modify or delete theREADME.mdfile to be relevant for your project. -
Setup your Python virtual environment. For more on Python virtual environments, we recommend this venv primer.
python -m venv .venv source .venv/bin/activateNOTE: If you customize your virtual environment name you will need to update the
.pre-commit-config.yamlto put the correct name into the entry command. -
Install all needed project dependencies using
pip install -r requirements.txt. -
Install the git pre-commit hooks
python -m pre_commit install. -
Setup the polyapi client by running
python -m polyapi setupand putting in your instance url and api key. -
Run
python -m polyapi generateto generate the full, up-to-date python SDK for PolyAPI (which includes functions Poly makes available out of the box as well as any functions other members of your team might create and publish). -
Optionally remove the
./examplesdirectory with it's examplehello_poly.pyfunction.
And that's it! Your project should now be ready to develop and deploy to PolyAPI.
-
Make changes to your PolyAPI functions or create a new one.
-
Commit your changes using git by running something like:
git commit -am 'some useful message describing my changes here...' -
Watch the
polyapi preparecommand run and catalog all your deployable functions. -
If the prepare command made changes to any code comments then your commit will be paused to give you a chance to review those changes. If changes were made review, edit, and commit.
-
Push your changes to github:
git push origin -
Watch the github action run and automagically sync your server function(s) with PolyAPI!
-
After the github deployment action is complete run
git pullto pull the latest. -
Follow the link within the auto-generated deploy receipt at the top of your function file to view the deployed instance of the function in the PolyAPI management GUI, where you can view the function details, view any runtime logs, and even execute the function manually.
In the future, we will expand this Github Action to operate with different keys and different environments on develop vs main.
If you'd like to see an example, or have any other questions about Poly's Git Glide, please reach out to:
