Skip to content

janesenaj42/templates-python

Repository files navigation

(YOUR PROJECT NAME) ...

(ADD A DESCRIPTION FOR YOUR PROJECT) ...

How to use this code template

  1. Git clone this project
  2. Fill in the fillers ('...') in the README above with your project specific information
  3. Rename the folder src/my_package to whatever your project name is (e.g. src/my_awesome_project) and update the tool.poetry-exec-plugin.commands section in pyproject.toml and the CMD line in runtime stage of the Dockerfile accordingly
    • This adopts the src/package layout structure. The benefits of this layout is that it allows for independent testing of installed packaged code from local code that are still in development (i.e. import parity from a user pov). Benefits are more apparent for python packages meant for installation but let's just give this a try :)
      • tests/ contains test for project code.
      • src/my_package contains code for your python project. "my_package" is usually your project's name.
    • For convention and consistency, use underscores ('_') to delimit folder names
  4. Delete this 'How to use this code template' section
  5. Re-initialize git
    • Delete .git folder
    • Follow instructions in gitlab on how to create new projects
      • New Project > Create blank project > (Enter your project name and uncheck the 'Initialize repository with a README') > Create project > Follow the command line instructions under Push an existing folder section
  6. Proceed with development :)

Quick Start

  1. Create new python virtual environment.
# usage: python -m venv <name of venv>
python -m venv venv
  1. Activate the virtual environment.
# windows
.\venv\Scripts\activate.bat

# linux
source venv/bin/activate
  1. Install setup setuff.
# installs setup stuff and poetry and its plugins
pip install -U pip setuptools
pip install poetry poetry-exec-plugin

# installs packages specified in `pyproject.toml` (similar to `pip install`)
poetry install

# installs precommit hooks
pre-commit install

To add packages,

# prod packages
poetry add pandas

# dev packages
poetry add pytest --group dev

To remove packages,

poetry remove pytest --group dev

Common commands

To run the code,

poetry exec start

To run lint and formatter,

poetry exec lint

To run tests,

poetry exec test

Deployment

To create a release,

poetry exec release

This taps on commitizen to auto bump version numbers in pyproject.toml based on Semantic Versioning conventions. It also updates the changelog and creates a corresponding git tag. To push the commit and tag,

git push && git push origin --tags

This project uses kustomize to manage kube configurations across namespaces and has been tested with kubectl version v1.29.2 which ships with kustomize v5.0.4-0.20230601165947-6ce0bf390ce3.

To deploy to kubernetes,

kubectl apply -k kube/base
kubectl apply -k kube/overlays/production

Note that any domain name used in the ingress needs to be added to the DNS.

To delete from kubernetes,

kubectl delete -k kube/base

To generate manifests without deploying,

kubectl kustomize kube/base
kubectl kustomize kube/overlays/production

About

Template python project.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published