Are there any other examples using the `Selector` ...
# announcements
b
Are there any other examples using the
Selector
type to limit input values in a config file? I'm trying to configure a solid with multiple parameters, but where one of the parameters is necessarily fixed to be one of a set of possible values
n
hey Bradley! would an enum work for this? looks like we need to document this better, but see this test for an example: https://github.com/dagster-io/dagster/blob/master/python_modules/dagster-graphql/dagster_graphql_tests/graphql/setup.py#L378-L395
b
Ah interesting. I'll check it out in a bit. Thanks!
e
I would also be interested in another small example. The documentation mentioned how it would be easy to conceive an example with selectors such as "xlsx, sql, and parquet". Does that mean in the same Selector ?
n
@Eric depends on your use case—`Selector` is useful when you would like to “select” a sub-tree of configuration. for example:
Copy code
config = { 
    'myconfig': Selector({
        'primary': Field(Dict(fields={
             'b': Field(str),
             'c': Field(int),
        }, 
        'secondary': Field(bool),
     }),
}
with this schema,
Copy code
myconfig:
  primary:
     b: "test"
     c: 2
and
Copy code
myconfig:
  secondary: True
are both valid configurations. In contrast,
Enum
is useful when you have a fixed set of scalar configurations to choose from. Hope that helps!
👍 1