From db7862b8bd1fcfdc033e76918467a4c42c6b3d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 4 May 2026 09:03:51 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20console-python-env=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20def=20main(event,=20context)=20=E2=80=94=20TypeE?= =?UTF-8?q?rror=20=D0=BF=D1=80=D0=B8=20=D0=B2=D1=8B=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проблема: ghcr.io/fission/python-env v3 вызывает userfunc() без аргументов. Пользователи пишут def main(event, context) (AWS Lambda стиль) — получают: TypeError: main() missing 2 required positional arguments: 'event' and 'context' Это НЕ ошибка пользователя. Fission просто не реализует Lambda-конвенцию. demo.py: временно исправлен на event=None, context=None. План: собрать naeel/console-python-env с патчем inspect.signature чтобы любая сигнатура main() работала автоматически. Подробнее: doc/plans/console-python-env-fix-2026-05-04.md --- demo.py | 2 +- .../console-python-env-fix-2026-05-04.md | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 doc/plans/console-python-env-fix-2026-05-04.md 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.