From c02a000a58c2d8daf7f1f0c6f0f633b8cf88134d Mon Sep 17 00:00:00 2001 From: cnativid Date: Thu, 16 Oct 2025 08:34:34 -0700 Subject: [PATCH 1/3] add utils for arbitrary Options-type classes --- src/condor/implementations/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/condor/implementations/utils.py b/src/condor/implementations/utils.py index f0bc611c..9d84447e 100644 --- a/src/condor/implementations/utils.py +++ b/src/condor/implementations/utils.py @@ -1,6 +1,6 @@ -def options_to_kwargs(new_cls): - """Process a model clasa and create the kwarg dictionary for the :class:`Options`""" - opts = getattr(new_cls, "Options", None) +def options_to_kwargs(new_cls, attr_name="Options"): + """Process a model class and create the kwarg dictionary for the :class:`Options`""" + opts = getattr(new_cls, attr_name, None) if opts is not None: backend_option = { k: v for k, v in opts.__dict__.items() if not k.startswith("_") @@ -8,3 +8,4 @@ def options_to_kwargs(new_cls): else: backend_option = {} return backend_option + From 50fc8c63f4b451fffad88eb46f3590f4c3b8f8bf Mon Sep 17 00:00:00 2001 From: cnativid Date: Thu, 16 Oct 2025 08:45:53 -0700 Subject: [PATCH 2/3] add test for more options --- tests/test_more_options.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/test_more_options.py diff --git a/tests/test_more_options.py b/tests/test_more_options.py new file mode 100644 index 00000000..1cf85a99 --- /dev/null +++ b/tests/test_more_options.py @@ -0,0 +1,14 @@ +import condor as co +from condor.implementations.utils import options_to_kwargs + +def test_options_to_kwargs(): + class ExampleModel(co.ExplicitSystem): + + class Options: + in_options = True + + class MiscOptions: + in_misc_options = True + + assert options_to_kwargs(ExampleModel)["in_options"] + assert options_to_kwargs(ExampleModel, attr_name = "MiscOptions")["in_misc_options"] From a1e0a06d3bb11186915e177f9189d546c3275142 Mon Sep 17 00:00:00 2001 From: cnativid Date: Thu, 16 Oct 2025 09:06:06 -0700 Subject: [PATCH 3/3] ruff check, format --- src/condor/implementations/utils.py | 1 - tests/test_more_options.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/condor/implementations/utils.py b/src/condor/implementations/utils.py index 9d84447e..a675e778 100644 --- a/src/condor/implementations/utils.py +++ b/src/condor/implementations/utils.py @@ -8,4 +8,3 @@ def options_to_kwargs(new_cls, attr_name="Options"): else: backend_option = {} return backend_option - diff --git a/tests/test_more_options.py b/tests/test_more_options.py index 1cf85a99..1dcb03e2 100644 --- a/tests/test_more_options.py +++ b/tests/test_more_options.py @@ -1,14 +1,14 @@ import condor as co from condor.implementations.utils import options_to_kwargs + def test_options_to_kwargs(): class ExampleModel(co.ExplicitSystem): - class Options: in_options = True class MiscOptions: in_misc_options = True - + assert options_to_kwargs(ExampleModel)["in_options"] - assert options_to_kwargs(ExampleModel, attr_name = "MiscOptions")["in_misc_options"] + assert options_to_kwargs(ExampleModel, attr_name="MiscOptions")["in_misc_options"]