Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This middleware is used by Knative Functions to expose a Function written in
Python as a network service.

## Contents

```
.
├── cmd
Expand Down Expand Up @@ -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`
Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -134,17 +138,16 @@ 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
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.
8 changes: 5 additions & 3 deletions cmd/fcloudevent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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)
2 changes: 2 additions & 0 deletions cmd/fhttp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
11 changes: 4 additions & 7 deletions src/func_python/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,6 +17,3 @@ shutdown of the service.
## Usage

To see a usage example, refer to cmd/fhttp.



Loading