Mark Fickett
03/02/2022, 2:31 PMvalues_resource
with an Optional
List
of `Enum`s?
Here's what I tried:
from typing import List
from typing import Optional
from dagster import make_values_resource
from dagster import Enum
from common_definitions import PipelineStage, Pipe # regular Python enums
# Define a resource for a config that can be passed to multiple ops in a job.
# <https://docs.dagster.io/concepts/configuration/config-schema#passing-configuration-to-multiple-ops-in-a-job>
SHARED_CONFIG = make_values_resource(
from_stage=Enum.from_python_enum(PipelineStage), # seems to work
pipes=Optional[List[Enum.from_python_enum(Pipe)]], # error
)
The error I get is:
/...packages/dagster/core/workspace/context.py:541: UserWarning: Error loading repository location my_pipeline.py:TypeError: Parameters to generic types must be types. Got <dagster.config.config_type.Enum object at 0x7f54f51247c0>.
I haven't done much debugging yet, but thought I'd ask for a definitive answer while I experiment. This is my first time trying to declare a values_resource
.from dagster import Field
from processing.common.common_definitions import PipelineStage, Pipe
SHARED_CONFIG_RESOURCE = make_values_resource(
from_stage=Enum.from_python_enum(PipelineStage),
pipes=Field([Enum.from_python_enum(Pipe)], is_required=False),
)
Optional
=> dagster.Field(is_required=False)
List[]
=> []
alex
03/02/2022, 3:24 PM