Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Side by side #7

Merged
merged 5 commits into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 59 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,75 @@
# 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. To the left is a Python program defining a Task and related TaskRun. To the right is the equivalent YAML file.

Here is an example Fluid program.
<table><tr><td valign=top>

```python
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])

if __name__ == "__main__":
echo_hello_world("Aloha")
echo_hello_world("Aloha")
```

</td><td valign=top>

```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
```

</tr></td></table>

## 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.
3 changes: 1 addition & 2 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")