Skip to content

Commit

Permalink
feat: add sample to showcase 2023-09 task parameter definitions
Browse files Browse the repository at this point in the history
This adds a sample that demonstrates all of the different types of things
that you can do to define task parameters, and multidimensional task parameter
spaces.

Signed-off-by: Daniel Neilson <53624638+ddneilson@users.noreply.github.com>
  • Loading branch information
ddneilson committed Dec 11, 2024
1 parent 0ac49c9 commit caada9a
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 0 deletions.
1 change: 1 addition & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Please see the [CONTRIBUTING guide](../CONTRIBUTING.md) for additional informati
| [host-requirements](./v2023-09/job_templates/host-requirements.yaml) | host requirements |
| [path-mapping](./v2023-09/job_templates/path-mapping.yaml) | path mapping |
| [stdout-messages](./v2023-09/job_templates/stdout-messages.yaml) | stdout messages, embedded files |
| [task-parameter-definition-showcase](./v2023-09/job_templates/task-parameter-definition-showcase.yaml) | task parameters, task parameter combination operators |
| [ui-controls-showcase](./v2023-09/job_templates/ui-controls-showcase.yaml) | job parameters, ui metadata, embedded file |

| Environment Template | Concepts Demonstrated |
Expand Down
248 changes: 248 additions & 0 deletions samples/v2023-09/job_templates/task-parameter-definition-showcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# ----
# Demonstrates
# ----
# This is a showcase of the sorts of value ranges that you can express with
# task parameters.
#
# Run with:
# PATH_MAPPING_RULES="{\"version\":\"pathmapping-1.0\", \"path_mapping_rules\": [{\"source_path_format\": \"POSIX\", \"source_path\": \"/mnt/drive\", \"destination_path\": \"/mnt/remapped_drive\"}]}"
# openjd run task-parameter-definition-showcase.yaml -p PathValue=/mnt/drive/dir/path_file --step "List of path values" --path-mapping-rules "$PATH_MAPPING_RULES"
#
# ----
# Requirements
# ----
# - Any POSIX-compliant system to run the sample.
#
# -----
# Contributors to this template:
# Daniel Neilson (https://github.com/ddneilson)

name: Showcase of value definitions for task parameters
specificationVersion: jobtemplate-2023-09
parameterDefinitions:
- name: IntRange
type: STRING
default: "1-100"
- name: IntValue
type: INT
default: 10
- name: FloatValue
type: FLOAT
default: 10.4
- name: PathValueAsString
type: STRING
default: "/mnt/drive/dir/string_file"
- name: PathValue
type: PATH

steps:

## INTEGER task parameter value samples
- name: Basic integer range expression
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
# Values: 1, 2, 3, 4, ..., 100
range: "1-100"
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"

- name: Range is a format string
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
# Values: 1, 2, 3, 4, ..., 100
range: "{{Param.IntRange}}"
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"

- name: Integer range expression with a skip value
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
# Values: 1, 11, 21, ..., 91
# Note: 100 is not included because (100-1)/10 is not an integer.
range: "1-100:10"
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"

- name: Compound integer range expression
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
# Use commas to create a compound range.
# Values: 1,2,3,...,10,50,60,65,...,100
# Notes:
# * 100 is in the list this time because (100-60)/5 is an integer.
# * The order of the values in the compound expression is irrelevant.
# There is no guarantee regarding the order in which Tasks will be run.
range: "50, 60-100:5, 1-10"
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"

- name: List of integer values
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
range:
- 1
- 2
- "3" # Can be a string that converts to an integer
- "{{Param.IntValue}}" # Each element is a format string
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"

## FLOAT task parameter value samples
- name: List of float values
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: FLOAT
range:
- 1
- 2.2
- "3" # Can be a string that converts to an integer
- "4.5" # Can be a string that converts to a float
- "{{Param.FloatValue}}" # Each element is a format string
script:
actions:
onRun:
command: echo
args:
- "{{ Task.Param.Foo }}"


## STRING task parameter value samples
- name: List of string values
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: STRING
range:
- "one"
- two, three, four
- "{{Param.IntRange}}" # Each element is a format string
script:
actions:
onRun:
# Values printed are: "one", "two, three, four", and "1-100"
command: echo
args:
- "{{ Task.Param.Foo }}"

## PATH task parameter value samples
- name: List of path values
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: PATH
range:
- "/mnt/drive/dir/file1"
- "{{Param.PathValueAsString}}"
- "{{RawParam.PathValue}}" # Note: Param.PathValue does not exist at this scope
script:
actions:
onRun:
# Values printed are:
# "Mapped Path: /mnt/remapped_drive/dir/file1 -- Raw Value: /mnt/drive/dir/file1"
# "Mapped Path: /mnt/remapped_drive/dir/string_file -- Raw Value: /mnt/drive/dir/string_file"
# "Mapped Path: /mnt/remapped_drive/dir/path_file -- Raw Value: /mnt/drive/dir/path_file"
command: echo
args:
- "Mapped Path: {{ Task.Param.Foo }}"
- " -- "
- "Raw Value: {{ Task.RawParam.Foo }}"

## Multidimensional task parameter spaces
- name: Cartesian product
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
range: "1-3"
- name: Bar
type: STRING
range: ["one", "two", "three"]
# Values (Foo,Bar): (1,"one"), (1,"two"), (1,"three"), (2,"one"), (2,"two"), (2,"three"), (3,"one"), (3,"two"), (3,"three")
combination: "Foo * Bar"
script:
actions:
onRun:
command: echo
args:
- "Foo={{ Task.Param.Foo }}"
- " -- "
- "Bar={{ Task.Param.Bar }}"

- name: Association
parameterSpace:
taskParameterDefinitions:
# Note: Foo & Bar must have exactly the same number of elements in their range
- name: Foo
type: INT
range: "1-3"
- name: Bar
type: STRING
range: ["one", "two", "three"]
# Values (Foo,Bar): (1,"one"), (2,"two"), (3,"three")
combination: "(Foo, Bar)"
script:
actions:
onRun:
command: echo
args:
- "Foo={{ Task.Param.Foo }}"
- " -- "
- "Bar={{ Task.Param.Bar }}"

- name: Mix of operators
parameterSpace:
taskParameterDefinitions:
- name: Foo
type: INT
range: "1-3"
- name: Bar
type: STRING
range: ["one", "two", "three"]
- name: Buz
type: STRING
range: ["Buz1", "Buz2"]
# Values (Foo,Bar,Buz): (1,"one","Buz1"), (2,"two","Buz1"), (3,"three","Buz1"), (1,"one","Buz2"), (2,"two","Buz2"), (3,"three","Buz2")
combination: "(Foo, Bar) * Buz"
script:
actions:
onRun:
command: echo
args:
- "Foo={{ Task.Param.Foo }}"
- " -- "
- "Bar={{ Task.Param.Bar }}"
- " -- "
- "Buz={{ Task.Param.Buz }}"

0 comments on commit caada9a

Please sign in to comment.