Skip to content

Commit

Permalink
Rename "greater_than" to ">" (and related operators) in toml.
Browse files Browse the repository at this point in the history
  • Loading branch information
joaander committed May 13, 2024
1 parent 4627d60 commit 5d247b9
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions doc/src/guide/tutorial/group-workflow2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ value_file = "value.json"
name = "process_point"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "point"]]
include = [["/type", "==", "point"]]

[[action]]
name = "process_letter"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "letter"]]
include = [["/type", "==", "letter"]]
4 changes: 2 additions & 2 deletions doc/src/guide/tutorial/group-workflow3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ value_file = "value.json"
name = "process_point"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "point"]]
include = [["/type", "==", "point"]]
sort_by = ["/x"]

[[action]]
name = "process_letter"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "letter"]]
include = [["/type", "==", "letter"]]
4 changes: 2 additions & 2 deletions doc/src/guide/tutorial/group-workflow4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ value_file = "value.json"
name = "process_point"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "point"]]
include = [["/type", "==", "point"]]
sort_by = ["/x"]
split_by_sort_key = true

[[action]]
name = "process_letter"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "letter"]]
include = [["/type", "==", "letter"]]
4 changes: 2 additions & 2 deletions doc/src/guide/tutorial/group-workflow5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ value_file = "value.json"
name = "process_point"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "point"]]
include = [["/type", "==", "point"]]
sort_by = ["/x"]
maximum_size = 4

[[action]]
name = "process_letter"
command = "echo {directory}"
[action.group]
include = [["/type", "equal_to", "letter"]]
include = [["/type", "==", "letter"]]
6 changes: 3 additions & 3 deletions doc/src/guide/tutorial/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ This workflow will apply the `process_point` action to the directories where
`include` is an array. Each element is a length 3 array with the contents: `[JSON
pointer, operator, operand]`. Think of each element as an expression. The [*JSON
pointer*](../concepts/json-pointers.md) is a string that reads a particular value
from the directory's **value**. The *operator* is a comparison operator: `"equal_to",
"greater_than", or "less_than"`. The *operand* is the value to compare to. Together,
these 3 elements make a *condition*.
from the directory's **value**. The *operator* is a comparison operator: `"<"`, `"<="`,
`"=="`, `">="`, or `">"`. The *operand* is the value to compare to. Together, these 3
elements make a *condition*.

**Row** applies these *conditions* to all directories in the workspace. When all
*conditions* are true, the directory is included in the action's **groups**.
Expand Down
11 changes: 5 additions & 6 deletions doc/src/workflow/action/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ that it submits.
Example:
```toml
[action.group]
include = [["/subproject", "equal_to", "project_one"]]
include = [["/subproject", "==", "project_one"]]
sort_by = ["/value"]
split_by_sort_key = true
maximum_size = 16
Expand All @@ -25,20 +25,19 @@ groups of directories included in a given action.
all be true for a directory to be included in this group. Each condition is an **array**
of three elements: The *JSON pointer*, *the operator*, and the *operand*. The [JSON
pointer](../../guide/concepts/json-pointers.md) points to a specific element
from the directory's value. The operator may be `"less_than"`, `"greater_than"`, or
`"equal_to"`.
from the directory's value. The operator may be `"<"`, `"<="`, `"=="`, `">="`, or `">"`.

For example, select all directories where a value is in the given range:
```toml
include = [["/value, "less_than", 0.9], ["/value", "greater_than", 0.2]]
include = [["/value", ">", 0.2], ["/value", "<", 0.9]]
```
Choose directories where an array element is equal to a specific value:
```toml
include = [["/array/1", "equal_to", 12]]
include = [["/array/1", "==", 12]]
```
Match against strings:
```toml
include = [["/map/name", "equal_to", "string"]]
include = [["/map/name", "==", "string"]]
```
Compare by array:
```toml
Expand Down
2 changes: 1 addition & 1 deletion src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ products = ["one"]
name = "two"
command = "c"
products = ["two"]
group.include = [["/i", "less_than", {}]]
group.include = [["/i", "<", {}]]
[[action]]
name = "three"
Expand Down
20 changes: 12 additions & 8 deletions src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ pub struct Resources {
#[derive(Clone, Debug, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum Comparison {
#[serde(rename(deserialize = "<"))]
LessThan,
#[serde(rename(deserialize = "<="))]
LessThanOrEqualTo,
#[serde(rename(deserialize = "=="))]
EqualTo,
#[serde(rename(deserialize = ">="))]
GreaterThanOrEqualTo,
#[serde(rename(deserialize = ">"))]
GreaterThan,
}
// TODO: Possible to use <, >, <=, >=, ==?

/// Group definition.
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq)]
Expand Down Expand Up @@ -1262,7 +1266,7 @@ products = ["d", "e"]
name = "b"
command = "c"
[action.group]
include = [["/d", "equal_to", 5], ["/float", "greater_than", 6.5], ["/string", "less_than", "str"], ["/array", "equal_to", [1,2,3]], ["/bool", "equal_to", false]]
include = [["/d", "==", 5], ["/float", ">", 6.5], ["/string", "<", "str"], ["/array", "==", [1,2,3]], ["/bool", "==", false]]
sort_by = ["/sort"]
split_by_sort_key = true
maximum_size = 10
Expand Down Expand Up @@ -1559,7 +1563,7 @@ walltime.per_submission = "00:00:01"
# submit_options is tested above
[default.action.group]
include = [["/f", "equal_to", 5]]
include = [["/f", "==", 5]]
sort_by = ["/g"]
split_by_sort_key = true
reverse_sort = true
Expand Down Expand Up @@ -1622,7 +1626,7 @@ walltime.per_submission = "00:00:01"
# submit_options is tested above
[default.action.group]
include = [["/f", "equal_to", 5]]
include = [["/f", "==", 5]]
sort_by = ["/g"]
split_by_sort_key = true
reverse_sort = true
Expand All @@ -1645,7 +1649,7 @@ walltime.per_submission = "00:00:02"
# submit_options is tested above
[action.group]
include = [["/ff", "equal_to", 10]]
include = [["/ff", "==", 10]]
sort_by = ["/gg"]
split_by_sort_key = false
reverse_sort = false
Expand Down Expand Up @@ -1711,7 +1715,7 @@ walltime.per_submission = "00:00:01"
# submit_options is tested above
[default.action.group]
include = [["/f", "equal_to", 5]]
include = [["/f", "==", 5]]
sort_by = ["/g"]
split_by_sort_key = true
reverse_sort = true
Expand Down Expand Up @@ -1777,7 +1781,7 @@ walltime.per_submission = "00:00:01"
# submit_options is tested above
[default.action.group]
include = [["/f", "equal_to", 5]]
include = [["/f", "==", 5]]
sort_by = ["/g"]
split_by_sort_key = true
reverse_sort = true
Expand All @@ -1802,7 +1806,7 @@ walltime.per_submission = "00:00:02"
# submit_options is tested above
[action.group]
include = [["/ff", "equal_to", 10]]
include = [["/ff", "==", 10]]
sort_by = ["/gg"]
split_by_sort_key = false
reverse_sort = false
Expand Down

0 comments on commit 5d247b9

Please sign in to comment.