From a3e389af1f7db2252887fac67d49b777ce3fd370 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 24 Dec 2019 21:25:29 -0800 Subject: [PATCH 1/5] Side by side --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index e708209..c20aaaf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ When you run a Fluid program, which is indeed a Python program, it prints the YA Here is an example Fluid program. +
+ ```python import fluid @@ -25,4 +27,49 @@ if __name__ == "__main__": echo_hello_world("Aloha") ``` + + +```yaml +--- +apiVersion: tekton.dev/v1alpha1 +kind: Task +metadata: + name: echo-hello-world +spec: + inputs: + params: + - description: '' + name: hello + type: string + - default: El mundo + description: '' + name: world + type: string + steps: + - args: + - $(inputs.params.hello) + command: + - echo + image: ubuntu + name: example-py-12 + - args: + - $(inputs.params.world) + command: + - echo + image: ubuntu + name: example-py-13 +--- +apiVersion: tekton.dev/v1alpha1 +kind: TaskRun +metadata: + name: echo-hello-world-run +spec: + inputs: + params: + - name: hello + value: Aloha + taskRef: + name: echo_hello_world +``` +
From f85c65aa79de17e746bf163923748ee089f403c5 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 24 Dec 2019 21:26:52 -0800 Subject: [PATCH 2/5] align top --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c20aaaf..83cbf74 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ When you run a Fluid program, which is indeed a Python program, it prints the YA Here is an example Fluid program. -
+
```python import fluid @@ -27,7 +27,7 @@ if __name__ == "__main__": echo_hello_world("Aloha") ``` - + ```yaml --- From f0ed4e1ffb56f7b07ef0532e9109650272b299b2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 24 Dec 2019 21:27:50 -0800 Subject: [PATCH 3/5] Shorten code --- README.md | 3 +-- example.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 83cbf74..e545902 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,7 @@ def echo_hello_world(hello, world="El mundo"): fluid.step(image="ubuntu", cmd=["echo"], args=[hello]) fluid.step(image="ubuntu", cmd=["echo"], args=[world]) -if __name__ == "__main__": - echo_hello_world("Aloha") +echo_hello_world("Aloha") ``` diff --git a/example.py b/example.py index fb514ee..8304f5a 100755 --- a/example.py +++ b/example.py @@ -13,5 +13,4 @@ def echo_hello_world(hello, world="El mundo"): fluid.step(image="ubuntu", cmd=["echo"], args=[world]) -if __name__ == "__main__": - echo_hello_world("Aloha") +echo_hello_world("Aloha") From 278de10843924a21d5f8a0c996d42cca02b9fbdf Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 24 Dec 2019 21:28:50 -0800 Subject: [PATCH 4/5] Shorten code --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e545902..7c72ab2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ import fluid @fluid.task def echo_hello_world(hello, world="El mundo"): - '''Defines an example Tekton Task''' fluid.step(image="ubuntu", cmd=["echo"], args=[hello]) fluid.step(image="ubuntu", cmd=["echo"], args=[world]) From 738e4462376e1730ffae5dd6280c67d2247b123d Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 24 Dec 2019 21:36:37 -0800 Subject: [PATCH 5/5] Update --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7c72ab2..024a168 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,8 @@ # Fluid -Fluid is a Python package allowing users to write [Tekton Pipeline](https://github.com/tektoncd/pipeline) workflows in Python other than YAML. +Fluid is a Python package allowing users to write [Tekton](https://github.com/tektoncd/pipeline) workflows in Python other than YAML. -You can consider Fluid a programming langauge with a small subset of Python syntax. - -- Only function definitions and function invocations. -- Only positional arguments, but no keyword (named) arguments. -- Functions have no return values. (Tekton doesn't support Task output parameters.) - -When you run a Fluid program, which is indeed a Python program, it prints the YAML to standard output. You can then to submit the YAML to Tekton. - -Here is an example Fluid program. +Here is an example. To the left is a Python program defining a Task and related TaskRun. To the right is the equivalent YAML file.
@@ -71,3 +63,13 @@ spec: ```
+ +## Fluid as a Langauge + +You can consider Fluid a programming langauge with a small subset of Python syntax. + +- Only function definitions and function invocations. +- Only positional arguments, but no keyword (named) arguments. +- Functions have no return values. (Tekton doesn't support Task output parameters.) + +When you run a Fluid program, which is indeed a Python program, it prints the YAML file, which, you can then to submit the YAML to Tekton.