From 5d247b94a1e004d5b9e2404daf91f3bac3ce2851 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Mon, 13 May 2024 15:13:30 -0400 Subject: [PATCH] Rename "greater_than" to ">" (and related operators) in toml. --- doc/src/guide/tutorial/group-workflow2.toml | 4 ++-- doc/src/guide/tutorial/group-workflow3.toml | 4 ++-- doc/src/guide/tutorial/group-workflow4.toml | 4 ++-- doc/src/guide/tutorial/group-workflow5.toml | 4 ++-- doc/src/guide/tutorial/group.md | 6 +++--- doc/src/workflow/action/group.md | 11 +++++------ src/project.rs | 2 +- src/workflow.rs | 20 ++++++++++++-------- 8 files changed, 29 insertions(+), 26 deletions(-) diff --git a/doc/src/guide/tutorial/group-workflow2.toml b/doc/src/guide/tutorial/group-workflow2.toml index 218f925..96ac15e 100644 --- a/doc/src/guide/tutorial/group-workflow2.toml +++ b/doc/src/guide/tutorial/group-workflow2.toml @@ -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"]] diff --git a/doc/src/guide/tutorial/group-workflow3.toml b/doc/src/guide/tutorial/group-workflow3.toml index 06bc686..85b162c 100644 --- a/doc/src/guide/tutorial/group-workflow3.toml +++ b/doc/src/guide/tutorial/group-workflow3.toml @@ -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"]] diff --git a/doc/src/guide/tutorial/group-workflow4.toml b/doc/src/guide/tutorial/group-workflow4.toml index b7ab6a0..593261f 100644 --- a/doc/src/guide/tutorial/group-workflow4.toml +++ b/doc/src/guide/tutorial/group-workflow4.toml @@ -5,7 +5,7 @@ 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 @@ -13,4 +13,4 @@ split_by_sort_key = true name = "process_letter" command = "echo {directory}" [action.group] -include = [["/type", "equal_to", "letter"]] +include = [["/type", "==", "letter"]] diff --git a/doc/src/guide/tutorial/group-workflow5.toml b/doc/src/guide/tutorial/group-workflow5.toml index a573ac9..ae3166c 100644 --- a/doc/src/guide/tutorial/group-workflow5.toml +++ b/doc/src/guide/tutorial/group-workflow5.toml @@ -5,7 +5,7 @@ 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 @@ -13,4 +13,4 @@ maximum_size = 4 name = "process_letter" command = "echo {directory}" [action.group] -include = [["/type", "equal_to", "letter"]] +include = [["/type", "==", "letter"]] diff --git a/doc/src/guide/tutorial/group.md b/doc/src/guide/tutorial/group.md index 6cde54f..483418c 100644 --- a/doc/src/guide/tutorial/group.md +++ b/doc/src/guide/tutorial/group.md @@ -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**. diff --git a/doc/src/workflow/action/group.md b/doc/src/workflow/action/group.md index e4109d0..c603327 100644 --- a/doc/src/workflow/action/group.md +++ b/doc/src/workflow/action/group.md @@ -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 @@ -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 diff --git a/src/project.rs b/src/project.rs index b43e535..96d1d24 100644 --- a/src/project.rs +++ b/src/project.rs @@ -424,7 +424,7 @@ products = ["one"] name = "two" command = "c" products = ["two"] -group.include = [["/i", "less_than", {}]] +group.include = [["/i", "<", {}]] [[action]] name = "three" diff --git a/src/workflow.rs b/src/workflow.rs index 7196c37..c2c0e77 100644 --- a/src/workflow.rs +++ b/src/workflow.rs @@ -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)] @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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