metaflow icon indicating copy to clipboard operation
metaflow copied to clipboard

Add support for Parameters of type enum

Open svpino opened this issue 1 year ago • 3 comments

It'd be great if we had support for enum parameters.

Here is how we would define a Parameter today:

action = Parameter(
        "action",
        help="The action you want to perform. Supported values are 'traffic' and 'labeling'.",
        default="traffic"
    )

Notice how we need to rely on documentation to let the user know which values are supported. We also need to validate as part of the flow that the supplied value is supported.

Instead, it would be great to do something like this:

action = Parameter(
        "action",
        help="The action you want to perform.",
        type="enum",
        values=["traffic", "labeling"],
        default="traffic"
)

Metaflow could automatically validate the value of the parameter and we won't have to do that as part of the flow.

svpino avatar Oct 24 '24 15:10 svpino

that's a neat proposal. we will discuss internally and get back to you!

savingoyal avatar Oct 24 '24 15:10 savingoyal

Maybe even allow arbitrary types, so that you can just:

action = Parameter(
        "action",
        help="The action you want to perform.",
        type=Literal["traffic", "labeling"]
        default="traffic"
)

If you make Parameter a generic you could even have full type hint / check support

dotKokott avatar Feb 06 '25 17:02 dotKokott

Bumping this up for consideration.

svpino avatar Sep 09 '25 20:09 svpino