|
34 | 34 | @Example(
|
35 | 35 | full = true,
|
36 | 36 | title = """
|
37 |
| - Execute a Python script in a Conda virtual environment. First, add the following script in the embedded Code Editor and name it `etl_script.py`: |
| 37 | + Execute a Python script in a uv virtual environment. First, add the following script as a Namespace File in the embedded Code Editor and name it `etl_script.py`: |
38 | 38 |
|
39 | 39 | ```python
|
40 | 40 | import argparse
|
| 41 | + import requests |
41 | 42 |
|
42 | 43 | parser = argparse.ArgumentParser()
|
43 | 44 |
|
|
46 | 47 | args = parser.parse_args()
|
47 | 48 | result = args.num * 2
|
48 | 49 | print(result)
|
| 50 | + print(f"Requests version: {requests.__version__}") |
49 | 51 | ```
|
50 | 52 |
|
51 |
| - Then, make sure to set the `enabled` flag of the `namespaceFiles` property to `true` to enable [namespace files](https://kestra.io/docs/developer-guide/namespace-files). By default, setting to `true` injects all Namespace files; we `include` only the `etl_script.py` file as that is the only file we require from namespace files. |
| 53 | + Then, make sure to set the `enabled` flag of the `namespaceFiles` property to `true` to enable [namespace files](https://kestra.io/docs/concepts/namespace-files). By default, setting this to `true` injects all Namespace files; we `include` only the `etl_script.py` file as that is the only file we need for this task. |
52 | 54 |
|
53 |
| - This flow uses a `io.kestra.plugin.core.runner.Process` Task Runner and Conda virtual environment for process isolation and dependency management. However, note that, by default, Kestra runs tasks in a Docker container (i.e. a Docker task runner), and you can use the `taskRunner` property to customize many options, as well as `containerImage` to choose the Docker image to use. |
| 55 | + This flow uses a `io.kestra.plugin.core.runner.Process` Task Runner and a virtual environment for process isolation and dependency management. However, note that, by default, Kestra runs tasks in a Docker container (i.e. a Docker Task Runner), and you can use the `taskRunner` property to customize many options, as well as `containerImage` to choose the Docker image to use. |
54 | 56 | """,
|
55 | 57 | code = """
|
56 | 58 | id: python_venv
|
57 | 59 | namespace: company.team
|
| 60 | + |
| 61 | + inputs: |
| 62 | + - id: nr |
| 63 | + type: INT |
| 64 | + defaults: 21 |
58 | 65 |
|
59 | 66 | tasks:
|
60 | 67 | - id: python
|
|
66 | 73 | taskRunner:
|
67 | 74 | type: io.kestra.plugin.core.runner.Process
|
68 | 75 | beforeCommands:
|
69 |
| - - conda activate myCondaEnv |
| 76 | + - uv venv --python 3.13 |
| 77 | + - uv pip install requests |
70 | 78 | commands:
|
71 |
| - - python etl_script.py |
| 79 | + - python etl_script.py --num {{inputs.nr}} |
72 | 80 | """
|
73 | 81 | ),
|
74 | 82 | @Example(
|
|
128 | 136 | ),
|
129 | 137 | @Example(
|
130 | 138 | full = true,
|
131 |
| - title = "Run a Python command that can takes an input using an environment variable", |
| 139 | + title = "Run a Python command that takes an environment variable as input", |
132 | 140 | code = """
|
133 | 141 | id: python_input_as_env_variable
|
134 | 142 | namespace: company.team
|
|
248 | 256 | ),
|
249 | 257 | @Example(
|
250 | 258 | full = true,
|
251 |
| - title = "Create a python script and execute it in a virtual environment", |
| 259 | + title = "Create a Python script and execute it in a venv virtual environment", |
252 | 260 | code = """
|
253 | 261 | id: script_in_venv
|
254 | 262 | namespace: company.team
|
|
0 commit comments