Skip to content
Draft
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
3 changes: 2 additions & 1 deletion e2e/e2e_matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ func TestMatrix_Run(t *testing.T) {
t.Fatal("service does not appear to have started correctly.")
}

// ^C the running function
// ^C the running function and wait for it to exit so the port is released
if err := cmd.Process.Signal(os.Interrupt); err != nil {
fmt.Fprintf(os.Stderr, "error interrupting. %v", err)
}
_ = cmd.Wait()

})
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/templates-userdeps/python/http/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "function"
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = "MIT"

[build-system]
Expand Down
2 changes: 1 addition & 1 deletion e2e/testdata/templates/python/http/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "function"
description = ""
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = [
Expand Down
14,407 changes: 7,204 additions & 7,203 deletions generate/zz_filesystem_generated.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/buildpacks/scaffolder.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func patchPyprojectForPack(pyprojectPath string) error {
return fmt.Errorf("cannot read pyproject.toml for patching: %w", err)
}
content := strings.Replace(string(data), "{root:uri}/f", "./f", 1)
content += "[tool.poetry.dependencies]\npython = \">=3.9,<4.0\"\nfunction = { path = \"f\", develop = true }\n"
content += "[tool.poetry.dependencies]\npython = \">=3.10,<4.0\"\nfunction = { path = \"f\", develop = true }\n"
if err = os.WriteFile(pyprojectPath, []byte(content), 0644); err != nil {
return fmt.Errorf("cannot write patched pyproject.toml: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/s2i/assemblers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Assemble Scripts Patched for Functions Support
These are minimally patched assemblers taken from the S2I builders. For
example the Python assemble script can be extracted with:

docker run --rm registry.access.redhat.com/ubi8/python-39 \
docker run --rm registry.access.redhat.com/ubi8/python-311 \
cat /usr/libexec/s2i/assemble > bin/assemble

The scripts are modified slightly to support Functions as explained by
Expand Down
2 changes: 1 addition & 1 deletion pkg/s2i/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DefaultName = builders.S2I

var DefaultNodeBuilder = "registry.access.redhat.com/ubi8/nodejs-20-minimal"
var DefaultQuarkusBuilder = "registry.access.redhat.com/ubi8/openjdk-21"
var DefaultPythonBuilder = "registry.access.redhat.com/ubi8/python-39"
var DefaultPythonBuilder = "registry.access.redhat.com/ubi8/python-311"
var DefaultGoBuilder = "registry.access.redhat.com/ubi8/go-toolset"

// DefaultBuilderImages for s2i builders indexed by Runtime Language
Expand Down
20 changes: 10 additions & 10 deletions templates/python/cloudevents/function/func.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Function
import logging
from cloudevents.http import CloudEvent
from cloudevents.core.v1.event import CloudEvent


def new():
Expand Down Expand Up @@ -33,16 +33,16 @@ async def handle(self, scope, receive, send):
request = scope["event"]

# 2) Create a new CloudEvent as response with "OK" as data
response = CloudEvent({
"type": "function.response",
"source": "function",
"id": f"response-{request.get('id', 'unknown')}"
})
response = CloudEvent(
attributes={
"type": "function.response",
"source": "function",
"id": f"response-{request.get_id() or 'unknown'}"
},
data={"message": "OK"}
)

# 3) Set the response's data field to {"message": "OK"}
response.data = {"message": "OK"}

# 4) Send the response CloudEvent
# 3) Send the response CloudEvent
# The 'send' method is already decorated with CloudEvent middleware
await send(response)

Expand Down
4 changes: 2 additions & 2 deletions templates/python/cloudevents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
name = "function"
description = ""
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = [
"httpx",
"cloudevents>=1.11,<2",
"cloudevents>=2,<3",
"pytest",
"pytest-asyncio"
]
Expand Down
6 changes: 3 additions & 3 deletions templates/python/cloudevents/tests/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import json
import asyncio
import pytest
from cloudevents.http import CloudEvent
from cloudevents.core.v1.event import CloudEvent
from function import new


Expand All @@ -25,7 +25,7 @@ async def test_func():
"source": "https://example.com/event-producer",
}
data = {"message": "test message"}
event = CloudEvent(attributes, data)
event = CloudEvent(attributes=attributes, data=data)

invoked = False # Flag indicating send method was invoked

Expand All @@ -40,7 +40,7 @@ async def send(e):

# Ensure it returns {"message": "OK"} as data
expected = {"message": "OK"}
assert e.data == expected, f"Expected data {expected}, got {e.data}"
assert e.get_data() == expected, f"Expected data {expected}, got {e.get_data()}"

# Invoke the Function
scope = {"event": event} # Add the CloudEvent to the scope
Expand Down
2 changes: 1 addition & 1 deletion templates/python/http/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "function"
description = ""
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "service"
description = "an autogenerated service which runs a Function"
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = [
"func-python==0.7.0",
"func-python==0.8.0",
"function @ {root:uri}/f"
]
authors = [
Expand Down
4 changes: 2 additions & 2 deletions templates/python/scaffolding/instanced-http/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
name = "service"
description = "an autogenerated service which runs a Function"
version = "0.1.0"
requires-python = ">=3.9"
requires-python = ">=3.10"
readme = "README.md"
license = "MIT"
dependencies = [
"func-python==0.7.0",
"func-python==0.8.0",
"function @ {root:uri}/f"
]
authors = [
Expand Down
Loading