Two radiobuttons fail

Dear all,

I have a strange problem. I am doing a KNIME 4.7 python extension. I use radio buttons in configure. If there is only one radio button, it works as expected, but the same code fails with two buttons.

class StereoOptions(knext.EnumParameterOptions):
    KEEP = ("No Changes", "Do nothing with stereochemistry.")
    REMOVE = ("Remove", "Remove stereochemistry at all.")
    CLEAN = ("Clean", "Clean and fix stereochemistry.")

stereo = knext.EnumParameter(
    "Stereochemistry processing",
    "How to process stereochemistry.",
    StereoOptions.KEEP.name,
    StereoOptions,
)

class StereoOptions2(knext.EnumParameterOptions):
    KEEP = ("No Changes", "Do nothing with stereochemistry.")
    REMOVE = ("Remove", "Remove stereochemistry at all.")
    CLEAN = ("Clean", "Clean and fix stereochemistry.")

stereo2 = knext.EnumParameter(
    "Stereochemistry processing",
    "How to process stereochemistry.",
    StereoOptions2.KEEP.name,
    StereoOptions2,
)

ValueError: The selection ‘None’ for parameter ‘Stereochemistry processing’ is not one of the available options: ‘KEEP’, ‘REMOVE’, ‘CLEAN’.

Hi @pirotex,

I just tested your example and it works for me. The node that I tested looks like this:

@knext.node(
    "Simple Python Node",
    node_type=knext.NodeType.MANIPULATOR,
    icon_path="icon.png",
    category=node_category,
)
@knext.input_table(name="Input Data", description="The data to process in my node")
@knext.output_table("Output Data", "Result of processing in my node")
class SimpleNode:
    """Node that does nothing

    Just testing some parameters.
    """

    class StereoOptions(knext.EnumParameterOptions):
        KEEP = ("No Changes", "Do nothing with stereochemistry.")
        REMOVE = ("Remove", "Remove stereochemistry at all.")
        CLEAN = ("Clean", "Clean and fix stereochemistry.")

    stereo = knext.EnumParameter(
        "Stereochemistry processing",
        "How to process stereochemistry.",
        StereoOptions.KEEP.name,
        StereoOptions,
    )

    class StereoOptions2(knext.EnumParameterOptions):
        KEEP = ("No Changes", "Do nothing with stereochemistry.")
        REMOVE = ("Remove", "Remove stereochemistry at all.")
        CLEAN = ("Clean", "Clean and fix stereochemistry.")

    stereo2 = knext.EnumParameter(
        "Stereochemistry processing",
        "How to process stereochemistry.",
        StereoOptions2.KEEP.name,
        StereoOptions2,
    )

    def configure(self, config_context, input_table_schema):
        print(f"stereo: {self.stereo}, stereo2: {self.stereo2}")
        return input_table_schema

    def execute(self, exec_context, input_table):
        print(f"stereo: {self.stereo}, stereo2: {self.stereo2}")
        return input_table

Is there something required to reproduce the issue that I am missing?

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.