From 107fcf40afe15367d4d3ae2e6fbb857c655db88c Mon Sep 17 00:00:00 2001 From: Damian Badura Date: Thu, 28 Mar 2024 11:08:38 +0100 Subject: [PATCH 1/4] wip --- components/runtimes/python/{kubeless => }/.gitignore | 1 - components/runtimes/python/{kubeless => }/README.md | 11 +++++++---- components/runtimes/python/{kubeless => }/kubeless.py | 6 +++--- components/runtimes/python/{kubeless => lib}/ce.py | 0 .../runtimes/python/{kubeless => lib}/tracing.py | 0 components/runtimes/python/python39/Dockerfile | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) rename components/runtimes/python/{kubeless => }/.gitignore (97%) rename components/runtimes/python/{kubeless => }/README.md (67%) rename components/runtimes/python/{kubeless => }/kubeless.py (98%) rename components/runtimes/python/{kubeless => lib}/ce.py (100%) rename components/runtimes/python/{kubeless => lib}/tracing.py (100%) diff --git a/components/runtimes/python/kubeless/.gitignore b/components/runtimes/python/.gitignore similarity index 97% rename from components/runtimes/python/kubeless/.gitignore rename to components/runtimes/python/.gitignore index 4e0ed3e45..4c507e526 100644 --- a/components/runtimes/python/kubeless/.gitignore +++ b/components/runtimes/python/.gitignore @@ -1,5 +1,4 @@ #For local debugging function venv - __pycache__ diff --git a/components/runtimes/python/kubeless/README.md b/components/runtimes/python/README.md similarity index 67% rename from components/runtimes/python/kubeless/README.md rename to components/runtimes/python/README.md index c50f8f55e..ddbdf28c3 100644 --- a/components/runtimes/python/kubeless/README.md +++ b/components/runtimes/python/README.md @@ -1,6 +1,9 @@ ## How to locally run and debug Python Function and runtime 1.Create [venv](https://docs.python.org/3/library/venv.html) +```bash +python3 -m venv venv +``` 2.Activate venv: ```bash @@ -8,10 +11,10 @@ ``` 3.Create the `function` directory with `handler.py` and `requirements.txt` -4.Install dependencies from runtime and Function: +4.Install dependencies from specific runtime {XYZ} and Function: ```bash - pip install -r requirements.txt - pip install -r kubeless/requirements.txt + pip install -r python{XYZ}/requirements.txt + pip install -r function/requirements.txt ``` 5.Set the following envs: @@ -23,6 +26,6 @@ 6.Run Function from the terminal. ```bash - python3 kubeless.py + python3 kubeless/kubeless.py ``` diff --git a/components/runtimes/python/kubeless/kubeless.py b/components/runtimes/python/kubeless.py similarity index 98% rename from components/runtimes/python/kubeless/kubeless.py rename to components/runtimes/python/kubeless.py index e9c4bf1fc..6367f7649 100644 --- a/components/runtimes/python/kubeless/kubeless.py +++ b/components/runtimes/python/kubeless.py @@ -9,9 +9,9 @@ import bottle import prometheus_client as prom -import tracing -from ce import Event -from tracing import set_req_context +import lib.tracing as tracing +from lib.ce import Event +from lib.tracing import set_req_context # The reason this file has an underscore prefix in its name is to avoid a diff --git a/components/runtimes/python/kubeless/ce.py b/components/runtimes/python/lib/ce.py similarity index 100% rename from components/runtimes/python/kubeless/ce.py rename to components/runtimes/python/lib/ce.py diff --git a/components/runtimes/python/kubeless/tracing.py b/components/runtimes/python/lib/tracing.py similarity index 100% rename from components/runtimes/python/kubeless/tracing.py rename to components/runtimes/python/lib/tracing.py diff --git a/components/runtimes/python/python39/Dockerfile b/components/runtimes/python/python39/Dockerfile index 3a2f30494..d913c4ac3 100644 --- a/components/runtimes/python/python39/Dockerfile +++ b/components/runtimes/python/python39/Dockerfile @@ -10,7 +10,7 @@ COPY ./python39/requirements.txt /kubeless/requirements.txt RUN pip install --no-cache-dir -r /kubeless/requirements.txt -COPY ./kubeless/ / +COPY ./ / WORKDIR / From e34d8d9c7e61ba55a31e3264c37a42d28e50a08b Mon Sep 17 00:00:00 2001 From: Damian Badura Date: Thu, 28 Mar 2024 12:52:20 +0100 Subject: [PATCH 2/4] fix --- components/runtimes/python/python312/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/runtimes/python/python312/Dockerfile b/components/runtimes/python/python312/Dockerfile index 6fa301db0..a8186ef95 100644 --- a/components/runtimes/python/python312/Dockerfile +++ b/components/runtimes/python/python312/Dockerfile @@ -10,7 +10,7 @@ COPY ./python312/requirements.txt /kubeless/requirements.txt RUN pip install --no-cache-dir -r /kubeless/requirements.txt -COPY ./kubeless/ / +COPY ./ / WORKDIR / From dbcb257249842b3eff5375b3a9874d5dcfdbebb3 Mon Sep 17 00:00:00 2001 From: Damian Badura Date: Thu, 28 Mar 2024 14:43:47 +0100 Subject: [PATCH 3/4] fix after review --- components/runtimes/python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/runtimes/python/README.md b/components/runtimes/python/README.md index ddbdf28c3..d60bc2854 100644 --- a/components/runtimes/python/README.md +++ b/components/runtimes/python/README.md @@ -11,7 +11,7 @@ python3 -m venv venv ``` 3.Create the `function` directory with `handler.py` and `requirements.txt` -4.Install dependencies from specific runtime {XYZ} and Function: +4.From specific Python Runtime Version {XYZ} and Function: ```bash pip install -r python{XYZ}/requirements.txt pip install -r function/requirements.txt From 98f916688f4301494ff6c8f633685a5bc3223b91 Mon Sep 17 00:00:00 2001 From: Damian Badura <45110612+dbadura@users.noreply.github.com> Date: Fri, 29 Mar 2024 10:21:04 +0100 Subject: [PATCH 4/4] Update components/runtimes/python/README.md --- components/runtimes/python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/runtimes/python/README.md b/components/runtimes/python/README.md index d60bc2854..307cbfe82 100644 --- a/components/runtimes/python/README.md +++ b/components/runtimes/python/README.md @@ -11,7 +11,7 @@ python3 -m venv venv ``` 3.Create the `function` directory with `handler.py` and `requirements.txt` -4.From specific Python Runtime Version {XYZ} and Function: +4. Install dependencies from specific Python Runtime Version {XYZ} and Function: ```bash pip install -r python{XYZ}/requirements.txt pip install -r function/requirements.txt