diff --git a/demo.py b/demo.py index 1477abd..9884514 100644 --- a/demo.py +++ b/demo.py @@ -1,6 +1,6 @@ import requests -def main(event, context): +def main(event=None, context=None): try: r = requests.get('https://httpbin.org/get', timeout=3) return { diff --git a/doc/plans/console-python-env-fix-2026-05-04.md b/doc/plans/console-python-env-fix-2026-05-04.md new file mode 100644 index 0000000..8fab1ef --- /dev/null +++ b/doc/plans/console-python-env-fix-2026-05-04.md @@ -0,0 +1,43 @@ +# Plan: console-python-env — fix function call signature + +Date: 2026-05-04 + +## Problem + +Fission Python env v3 calls user function as `userfunc()` with no arguments +(Flask URL path params only, empty for parameterless routes). + +Users writing `def main(event, context)` (AWS Lambda style) get: +``` +TypeError: main() missing 2 required positional arguments: 'event' and 'context' +``` + +This is a real limitation of `ghcr.io/fission/python-env` — it never supported +Lambda-style signatures. The user code is valid Python, the env is inflexible. + +## Solution + +Build custom `naeel/console-python-env` based on `ghcr.io/fission/python-env`. +Patch `server.py`: before calling `userfunc`, use `inspect.signature` to count +required positional args, fill them with `None` if Fission passes fewer. + +Supported signatures after fix: +- `def main()` — standard Fission +- `def main(event, context)` — AWS Lambda style (event=None, context=None) +- `def main(request)` — single-arg style (request=None) +- `def main(*args, **kwargs)` — variadic, works as before + +## Steps + +1. Get `server.py` from running pod +2. Apply inspect patch to `userfunc_call` +3. Write Dockerfile: `FROM ghcr.io/fission/python-env`, COPY patched server.py +4. Build `naeel/console-python-env:v1.0` +5. Push to Docker Hub +6. Update Environment CRD `console-python-env` in k8s → new runtime image +7. Restart poolmgr pod for that env +8. Test `aa1` with `def main(event, context)` from archive + +## Documentation (after fix) + +Add to user docs: supported function signatures for Fission Python env.