Skip to content

Python runtime and invocation framework for Knative functions

License

Notifications You must be signed in to change notification settings

knative-extensions/func-python

Python Func Runtime

This middleware is used by Knative Functions to expose a Function written in Python as a network service.

Contents

.
├── cmd
│   └── fhttp          - Example a Function using the http middleware
├── src/func_python
│   ├── http.py        - HTTP Middleware
├── tests
│   ├── http_test.py   - HTTP Middleware tests
└── README.md          - This Readme

Development

Tests

Run suite: poetry run pytest

To enable more granular log levels: poetry run pytest --log-cli-level=INFO

Example Main

Minimal example of running the test command, which shows how this library is used when integrate with Functions, and can be useful during dev.

  • install poetry via pipx
  • install dependencies with poetry install
  • activate the virtual environment managed by poetry via poetry shell Note that in some environments this command may cause collissions with configured keyboard shortcuts. If there are problems, you can instead source the environment variables directly with: source $(poetry env info --path)/bin/activate
  • run the example via poetry run python cmd/fhttp/main.py
  • deactivate the virtual environment with exit

Suggested Flow

A nice method of development using git worktrees:

p. From a personal fork, create a new worktree for the bug, feature or chore named appropriately (eg. "feature-a")

  1. Implement the code changes and commit.

  2. Update the CHANGELOG.md to include the change in the "Unreleased" section.

  3. Commit, push and create a PR to the upstream repository's main branch.

  4. Solicit a code-read from another team member.

  5. Upon approval, squash and merge to main.

  6. (optional) cleanup by removing the worktree and associated local and remote branch.

  7. (optional) pull into local fork's main and push to remote fork main.

About

Python runtime and invocation framework for Knative functions

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages