From b7017d6a9063cb1059e019240ea5218b28f330d9 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Mon, 4 Dec 2023 16:31:10 +0900 Subject: [PATCH 1/6] feat: Allows field_ref to be used as a key value in fieldset --- src/ai/backend/client/output/types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ai/backend/client/output/types.py b/src/ai/backend/client/output/types.py index c0059785e4..fc0709c54f 100644 --- a/src/ai/backend/client/output/types.py +++ b/src/ai/backend/client/output/types.py @@ -104,7 +104,9 @@ def _default_formatter(self) -> AbstractOutputFormatter: class FieldSet(UserDict, Mapping[str, FieldSpec]): def __init__(self, fields: Sequence[FieldSpec]) -> None: - super().__init__({f.alt_name: f for f in fields}) + fields_set = {f.alt_name: f for f in fields} + fields_set.update({f.field_ref: fields_set[f.alt_name] for f in fields}) + super().__init__(fields_set) T = TypeVar("T") From 80f570264e775ba5b9c078b468ab262643e245b3 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Mon, 4 Dec 2023 16:38:27 +0900 Subject: [PATCH 2/6] Create .feature.md --- changes/.feature.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/.feature.md diff --git a/changes/.feature.md b/changes/.feature.md new file mode 100644 index 0000000000..db5d0d5fb3 --- /dev/null +++ b/changes/.feature.md @@ -0,0 +1 @@ +In order to be able to use not only alt_name but also field_ref when using the --format option of session list, add values to FieldSet. From ef98a096a49015228e85a88ea57301b2dc7fe946 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Mon, 4 Dec 2023 07:38:50 +0000 Subject: [PATCH 3/6] docs: Rename the news fragment with the PR number .feature.md -> 1756.feature.md --- changes/{.feature.md => 1756.feature.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changes/{.feature.md => 1756.feature.md} (100%) diff --git a/changes/.feature.md b/changes/1756.feature.md similarity index 100% rename from changes/.feature.md rename to changes/1756.feature.md From 967eb2e60620291c3932a37cb9befc2861320d12 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Mon, 4 Dec 2023 17:25:38 +0900 Subject: [PATCH 4/6] fix: Test results change due to changes in fieldset implementation --- tests/client/output/test_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/client/output/test_types.py b/tests/client/output/test_types.py index 2219fb9d8d..d5cdd515c6 100644 --- a/tests/client/output/test_types.py +++ b/tests/client/output/test_types.py @@ -44,7 +44,7 @@ def test_fieldspec_init(): ] ), ) - assert f.field_ref == "key_foo { bar baz }" + assert f.field_ref == "key_foo { bar baz baz }" assert f.field_name == "key_foo" assert f.humanized_name == "Key Foo" assert f.subfields["bar"].field_ref == "bar" From 36ac056c859dec607bbd80643be9a36beb28f258 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 7 Dec 2023 15:46:57 +0900 Subject: [PATCH 5/6] fix: Test results change due to changes in fieldset implementation --- tests/client/output/test_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/client/output/test_types.py b/tests/client/output/test_types.py index d5cdd515c6..1006cf9ab2 100644 --- a/tests/client/output/test_types.py +++ b/tests/client/output/test_types.py @@ -65,7 +65,7 @@ def test_fieldspec_init(): ] ), ) - assert f.field_ref == "key_foo { bar { kaz } }" + assert f.field_ref == "key_foo { bar { kaz } bar { kaz } } " assert f.field_name == "key_foo" assert f.humanized_name == "Key Foo" assert f.subfields["bar"].field_ref == "bar { kaz }" From f771baca4f0ba332309e7112e68ba1e27d46fa45 Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Thu, 7 Dec 2023 15:53:05 +0900 Subject: [PATCH 6/6] fix: Test results change due to changes in fieldset implementation --- tests/client/output/test_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/client/output/test_types.py b/tests/client/output/test_types.py index 1006cf9ab2..688cbe7367 100644 --- a/tests/client/output/test_types.py +++ b/tests/client/output/test_types.py @@ -65,7 +65,7 @@ def test_fieldspec_init(): ] ), ) - assert f.field_ref == "key_foo { bar { kaz } bar { kaz } } " + assert f.field_ref == "key_foo { bar { kaz } bar { kaz } }" assert f.field_name == "key_foo" assert f.humanized_name == "Key Foo" assert f.subfields["bar"].field_ref == "bar { kaz }"