diff --git a/CHANGELOG.md b/CHANGELOG.md index 3061f1b9..56d1b847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,15 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] ### Added + ### Changed + ### Deprecated + ### Removed + ### Fixed + ### Security ## 0.8.1 - 2026-04-14 @@ -81,5 +86,3 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Initial Implementation of the Python HTTP Functions Middleware - - diff --git a/README.md b/README.md index c991526a..50296d1d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This middleware is used by Knative Functions to expose a Function written in Python as a network service. ## Contents + ``` . ├── cmd @@ -43,7 +44,7 @@ library is used when integrate with Functions, and can be useful during dev. - 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 + 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` @@ -54,8 +55,8 @@ library is used when integrate with Functions, and can be useful during dev. 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") - `git worktree add feature-a` +named appropriately (eg. "feature-a") +`git worktree add feature-a` 2. Implement the code changes and commit. @@ -80,35 +81,38 @@ is pushed (which triggers production release). To test, in a test project ensure the it adds the test package as an explicit source in pyproject.toml: + ``` [[tool.poetry.source]] name = "test-pypi" url = "https://test.pypi.org/simple/" priority = "explicit" ``` + Then update the dependency to explicitly pull the new version which is only -available on TestPyPI. For example to test a hypothetical unreleased version +available on TestPyPI. For example to test a hypothetical unreleased version 0.1.2: + ``` [tool.poetry.dependencies] func_python = {version = "0.1.2", source = "test-pypi"} ``` + Run `poetry install` to install the unreleased version from Test PyPI Note: do not check in this change. - ## Releasing NOTE: This process is currently undergoing minor tweaks, and thus contains -several manual steps. Once the process is codified, it can be more highly +several manual steps. Once the process is codified, it can be more highly automated. 1. Create a new branch "release-x.y" from an up-to-date main When incrementing, follow Semantic Versioning standard. eg: - - Bug fixes: ++ patch version - - Features: ++ minor version - - Breaking Changes: ++ major version + - Bug fixes: ++ patch version + - Features: ++ minor version + - Breaking Changes: ++ major version 2. Update pyproject.toml with the new version. @@ -134,11 +138,10 @@ automated. 10. Update the GitHub release's notes to be the changelog section's contents . - ### Potential improvements Update to using the suffix "rcX" so as not to confuse folks pulling tags list -from the git repo. Without this suffix, a simple listing of the latest +from the git repo. Without this suffix, a simple listing of the latest tags from the repo would show a potentially unreleased version as the latest. With the use of these release-candidate tags, the use of TestPyPI may be @@ -146,5 +149,5 @@ unnecessary. Perhaps push the RC tag to the PR's commit and test prior to merging the PR to main, such that a potentially broken version is not kept in the main -branch's history. For example, if v0.1.2rc1 failed, its commit will not be +branch's history. For example, if v0.1.2rc1 failed, its commit will not be part of the main branch. diff --git a/cmd/fcloudevent/README.md b/cmd/fcloudevent/README.md index 3384fc87..07a943ed 100644 --- a/cmd/fcloudevent/README.md +++ b/cmd/fcloudevent/README.md @@ -5,21 +5,24 @@ This directory contains an example CloudEvent function that demonstrates how to This is an example usage of the Functions CloudEvents middleware. Run the function -``` + +```` ## Start the Function Run the instanced handler (default): ```bash poetry run python cmd/fcloudevent/main.py -``` +```` Run the static handler: + ```bash poetry run python cmd/fcloudevent/main.py --static ``` Change the listen address (default is [::]:8080): + ```bash LISTEN_ADDRESS=127.0.0.1:8081 poetry run python cmd/fcloudevent/main.py ``` @@ -56,6 +59,5 @@ curl -X POST http://127.0.0.1:8080 \ }' ``` - To see the actual middleware which is used when building a Python Function, see the [Functions Python Scaffolding](https://github.com/knative/func/tree/main/templates/python/cloudevents) diff --git a/cmd/fhttp/README.md b/cmd/fhttp/README.md index fd94c91f..4b8e39e6 100644 --- a/cmd/fhttp/README.md +++ b/cmd/fhttp/README.md @@ -6,11 +6,13 @@ wraps a function and exposes it as a service. Useful for development. This is an example usage of the Functions HTTP middleware. Run the function + ``` poetry run python cmd/fhttp/main.py ``` Send a HTTP request against it: + ``` curl -v -X POST http://127.0.0.1:8080/ \ -H "Content-Type: application/json" \ diff --git a/src/func_python/README.md b/src/func_python/README.md index 694bfa59..fcc7d95a 100644 --- a/src/func_python/README.md +++ b/src/func_python/README.md @@ -1,14 +1,14 @@ # Functions Python Middleware -An ASGI Application which will serve a Function. The ASGI application +An ASGI Application which will serve a Function. The ASGI application is the middleware. -The middleware implements lifecycle events such as "start" and "stop", health +The middleware implements lifecycle events such as "start" and "stop", health checks for readiness and liveness, and a handler for HTTP requests. The function is expected to implement "handle", and the middleware will -raise an error if the function does not implement this method. Start and stop -are optional. Readiness and liveness are also optional, with the middleware +raise an error if the function does not implement this method. Start and stop +are optional. Readiness and liveness are also optional, with the middleware providing default implementations. Signals are handled by the ASGI server implementation hypercorn and initiate @@ -17,6 +17,3 @@ shutdown of the service. ## Usage To see a usage example, refer to cmd/fhttp. - - -