From 6531b6b7aabc03ee338bd05f827a9355acabc0d3 Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:49:54 -0500 Subject: [PATCH 1/8] Update `cpu` types --- tljh/config_schema.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tljh/config_schema.py b/tljh/config_schema.py index 0b12c8f9..e6fb820a 100644 --- a/tljh/config_schema.py +++ b/tljh/config_schema.py @@ -79,7 +79,23 @@ "description": "User CPU and memory limits.", "type": "object", "additionalProperties": False, - "properties": {"memory": {"type": "string"}, "cpu": {"type": "integer"}}, + "properties": {"memory": {"type": "string"}, "cpu": { + "oneOf": [ + { + "type": "integer", + "minimum": 0 + }, + { + "type": "number", + "minimum": 0 + }, + { + "type": "string", + "enum": ["None"] + } + ] + } + }, }, "UserEnvironment": { "type": "object", From 73331f28fd733f3adbb314e3934abcbd0d312ab4 Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:07:35 -0500 Subject: [PATCH 2/8] Use `anyOf` --- tljh/config_schema.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/tljh/config_schema.py b/tljh/config_schema.py index e6fb820a..9d141c66 100644 --- a/tljh/config_schema.py +++ b/tljh/config_schema.py @@ -79,23 +79,16 @@ "description": "User CPU and memory limits.", "type": "object", "additionalProperties": False, - "properties": {"memory": {"type": "string"}, "cpu": { - "oneOf": [ - { - "type": "integer", - "minimum": 0 - }, - { - "type": "number", - "minimum": 0 + "properties": { + "memory": {"type": "string"}, + "cpu": { + "anyOf": [ + {"type": "integer", "minimum": 0}, + {"type": "number", "minimum": 0}, + {"type": "string", "enum": ["None"]}, + ] }, - { - "type": "string", - "enum": ["None"] - } - ] - } - }, + }, }, "UserEnvironment": { "type": "object", From e7555ae29cff47acfdbdb138866bfb626ed48e0b Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 15:01:57 -0500 Subject: [PATCH 3/8] Remove `integer` --- tljh/config_schema.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tljh/config_schema.py b/tljh/config_schema.py index 9d141c66..9463cf2a 100644 --- a/tljh/config_schema.py +++ b/tljh/config_schema.py @@ -83,7 +83,6 @@ "memory": {"type": "string"}, "cpu": { "anyOf": [ - {"type": "integer", "minimum": 0}, {"type": "number", "minimum": 0}, {"type": "string", "enum": ["None"]}, ] From 9ed2a92585f99cefa20b2a133665b6ae69ff10de Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:51:15 -0500 Subject: [PATCH 4/8] Parse `None` --- tljh/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tljh/config.py b/tljh/config.py index 3b317f93..73fdc1f6 100644 --- a/tljh/config.py +++ b/tljh/config.py @@ -317,8 +317,8 @@ def reload_component(component): def parse_value(value_str): """Parse a value string""" - if value_str is None: - return value_str + if value_str.lower() == "none": + return None if re.match(r"^\d+$", value_str): return int(value_str) elif re.match(r"^\d+\.\d*$", value_str): From 5a9cb2b395be149d72fa54a11cc964da903b6b39 Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:51:43 -0500 Subject: [PATCH 5/8] Update `tljh-config --help` --- docs/topic/tljh-config.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/topic/tljh-config.md b/docs/topic/tljh-config.md index 2df93ee1..e56609ba 100644 --- a/docs/topic/tljh-config.md +++ b/docs/topic/tljh-config.md @@ -227,7 +227,7 @@ it after an argument like `remove-item` gives information about this specific co ```bash sudo tljh-config --help -usage: tljh-config [-h] [--config-path CONFIG_PATH] {show,unset,set,add-item,remove-item,reload} ... +usage: tljh-config [-h] [--config-path CONFIG_PATH] [--validate] [--no-validate] {show,unset,set,add-item,remove-item,reload} ... positional arguments: {show,unset,set,add-item,remove-item,reload} @@ -238,10 +238,12 @@ positional arguments: remove-item Remove a value from a list for a configuration property reload Reload a component to apply configuration change -optional arguments: +options: -h, --help show this help message and exit --config-path CONFIG_PATH Path to TLJH config.yaml file + --validate Validate the TLJH config + --no-validate Do not validate the TLJH config ``` ```bash From e515bcad264f321326552705d592ca7fbaad0dfa Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 22:56:43 -0500 Subject: [PATCH 6/8] Fix `None` config test --- tests/test_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_config.py b/tests/test_config.py index 2d6ded43..88a752ce 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -220,7 +220,8 @@ def test_cli_remove_int(tljh_dir): ("x", "x"), ("1x", "1x"), ("1.2x", "1.2x"), - (None, None), + ("None", None), + ("none", None), ("", ""), ], ) From 5916407a5059ec70f1485fb1be9a86c76b9c3de9 Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:14:17 -0500 Subject: [PATCH 7/8] Update tljh/config_schema.py Co-authored-by: Min RK --- tljh/config_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tljh/config_schema.py b/tljh/config_schema.py index 9463cf2a..f86d3217 100644 --- a/tljh/config_schema.py +++ b/tljh/config_schema.py @@ -84,7 +84,7 @@ "cpu": { "anyOf": [ {"type": "number", "minimum": 0}, - {"type": "string", "enum": ["None"]}, + {"type": "null"}, ] }, }, From cd53b41b4983c3f24738c36a1e5ce84e02856ace Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Thu, 14 Nov 2024 23:17:32 -0500 Subject: [PATCH 8/8] Also allow `None` for memory --- tljh/config_schema.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tljh/config_schema.py b/tljh/config_schema.py index f86d3217..4a17f131 100644 --- a/tljh/config_schema.py +++ b/tljh/config_schema.py @@ -80,7 +80,12 @@ "type": "object", "additionalProperties": False, "properties": { - "memory": {"type": "string"}, + "memory": { + "anyOf": [ + {"type": "string"}, + {"type": "null"}, + ] + }, "cpu": { "anyOf": [ {"type": "number", "minimum": 0},