Happy new year folks! Just wanted to share this l...
# announcements
k
Happy new year folks! Just wanted to share this little snippet to use Python enums in solid configs and hear your thoughts on it. Is this something you already have a dedicated function for (couldn’t find anything in the docs) or something that conceptually doesn’t make sense?
Copy code
def as_dagster_enum(e: enum.EnumMeta):
    return Enum(e.__name__, [EnumValue(v.name, python_value=v) for v in e])
You can then use it in your solid config like so
Copy code
class Strategy(enum.Enum):
    SOMETHING = enum.auto()
    SOMETHING_ELSE = enum.auto()


@solid(
    config={"strategy": Field(as_dagster_enum(Strategy)),
    …
)
…
a
Ya this looks good - consider sending a PR to add it as a static method on
Enum
,
from_py_enum
or something
k
Done :) please let me know if anything needs improving
🤩 1