Skip to content

Commit

Permalink
fix(examples): correct the examples for shell script and commands (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutimantri authored Jul 16, 2024
1 parent ef9f9a5 commit 44a021f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@
@Example(
title = "Execute Shell commands that generate files accessible by other tasks and available for download in the UI's Output tab.",
code = {
"outputFiles:",
" - first.txt",
" - second.txt",
"commands:",
" - echo \"1\" >> {{ outputDir }}/first.txt",
" - echo \"2\" >> {{ outputDir }}/second.txt"
" - echo \"1\" >> first.txt",
" - echo \"2\" >> second.txt"
}
),
@Example(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,40 @@
examples = {
@Example(
title = "Create an inline Shell script and execute it.",
code = {
"script: |",
" echo \"The current execution is : {{ execution.id }}\"",
" echo \"1\" >> {{ outputDir }}/first.txt",
" cat {{ outputs.previousTaskId.uri }}"
}
full = true,
code = """
id: shell_script_example
namespace: company.team
tasks:
- id: http_download
type: io.kestra.plugin.core.http.Download
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv
- id: shell_script_task
type: io.kestra.plugin.scripts.shell.Script
outputFiles:
- first.txt
script: |
echo "The current execution is : {{ execution.id }}"
echo "1" >> first.txt
cat {{ outputs.http_download.uri }}"""
),
@Example(
full = true,
title = """
If you want to generate files in your script to make them available for download and use in downstream tasks, you can leverage the `{{ outputDir }}` variable. Files stored in that directory will be persisted in Kestra's internal storage. To access this output in downstream tasks, use the syntax `{{ outputs.yourTaskId.outputFiles['yourFileName.fileExtension'] }}`.
""",
code = """
id: shell
id: shell_script_example
namespace: company.team
tasks:
- id: hello
type: io.kestra.plugin.scripts.shell.Script
taskRunner:
type: io.kestra.plugin.core.runner.Process
outputFiles:
- hello.txt
script: |
echo "Hello world!" > {{ outputDir }}/hello.txt"""
echo "Hello world!" > hello.txt"""
)
}
)
Expand Down

0 comments on commit 44a021f

Please sign in to comment.