From cedeeda9e6942bf05bb255daec9ecbf896efeb5b Mon Sep 17 00:00:00 2001 From: creatermaker <64019083+creatermaker@users.noreply.github.com> Date: Mon, 29 Apr 2024 15:10:11 +0200 Subject: [PATCH] fibonacci claimed component Signed-off-by: creatermaker --- component-library/examples/fibonacci.cwl | 27 +++++++++++++++++++ component-library/examples/fibonacci.job.yaml | 20 ++++++++++++++ component-library/examples/fibonacci.py | 10 +++++++ component-library/examples/fibonacci.yaml | 21 +++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 component-library/examples/fibonacci.cwl create mode 100644 component-library/examples/fibonacci.job.yaml create mode 100644 component-library/examples/fibonacci.py create mode 100644 component-library/examples/fibonacci.yaml diff --git a/component-library/examples/fibonacci.cwl b/component-library/examples/fibonacci.cwl new file mode 100644 index 00000000..d8f970a5 --- /dev/null +++ b/component-library/examples/fibonacci.cwl @@ -0,0 +1,27 @@ +cwlVersion: v1.2 +class: CommandLineTool + +baseCommand: "claimed" + +inputs: + component: + type: string + default: docker.io/mdorzweiler/claimed-fibonacci:0.1 + inputBinding: + position: 1 + prefix: --component + log_level: + type: string + default: "INFO" + inputBinding: + position: 2 + prefix: --log_level + b: + type: string + default: None + inputBinding: + position: 3 + prefix: --b + + +outputs: [] diff --git a/component-library/examples/fibonacci.job.yaml b/component-library/examples/fibonacci.job.yaml new file mode 100644 index 00000000..ced5622d --- /dev/null +++ b/component-library/examples/fibonacci.job.yaml @@ -0,0 +1,20 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: fibonacci +spec: + template: + spec: + containers: + - name: fibonacci + image: docker.io/mdorzweiler/claimed-fibonacci:0.1 + workingDir: /opt/app-root/src/ + command: ["/opt/app-root/bin/python","claimed_fibonacci.py"] + env: + - name: log_level + value: value_of_log_level + - name: b + value: value_of_b + restartPolicy: OnFailure + imagePullSecrets: + - name: image_pull_secret \ No newline at end of file diff --git a/component-library/examples/fibonacci.py b/component-library/examples/fibonacci.py new file mode 100644 index 00000000..377c34ff --- /dev/null +++ b/component-library/examples/fibonacci.py @@ -0,0 +1,10 @@ +def fib(b): + n = int(b) + if n == 0: + return 0 + if n == 1: + return 1 + return fib(n-2) + fib(n-1) + +b = os.getenv('b') +print(fib(b)) diff --git a/component-library/examples/fibonacci.yaml b/component-library/examples/fibonacci.yaml new file mode 100644 index 00000000..788aafda --- /dev/null +++ b/component-library/examples/fibonacci.yaml @@ -0,0 +1,21 @@ +name: fibonacci +description: "claimed-fibonacci – CLAIMED V0.1" + +inputs: +- {name: log_level, type: String, description: "update log level", default: "INFO"} +- {name: b, type: String, description: ""} + + +outputs: + + +implementation: + container: + image: docker.io/mdorzweiler/claimed-fibonacci:0.1 + command: + - sh + - -ec + - | + python ./claimed_fibonacci.py log_level="${0}" b="${1}" + - {inputValue: log_level} + - {inputValue: b}