https://dagster.io/ logo
#ask-community
Title
# ask-community
s

Samuel Stütz

05/31/2022, 1:40 PM
How do I set a list of default values.
Copy code
Field(
        Noneable(list),
        default_value=["GIT_HASH", "DAGSTER_VERSION"],
        is_required=False,
        description="Li.....",
 ),
I tried many different versions … all say invalid configuration
z

Zach

05/31/2022, 1:58 PM
Would an Enum config type work?
s

Samuel Stütz

05/31/2022, 2:03 PM
I do need to have a list of strings in the end.
when I specify it in config array it works with the stndard list[…], but as a default_value it does not.
z

Zach

05/31/2022, 2:23 PM
Oh apologies, I misunderstood the problem. Have you tried
Copy code
Field(Noneable(Array(str)), default_value=['GIT_HASH', 'DAGSTER_VERSION'])?
s

Samuel Stütz

05/31/2022, 2:31 PM
Copy code
Field(
        Noneable(dagster.Array(str)),
        default_value=['GIT_HASH', 'DAGSTER_VERSION'],
        is_required=False,
also does not work
Copy code
) cannot be resolved. This value can be a: - Field - Python primitive types that resolve to dagster config types - int, float, bool, str, list. - A dagster config type: Int, Float, Bool, Array, Optional, Selector, Shape, Permissive, Map - A bare python dictionary, which is wrapped in Field(Shape(...)). Any values in the dictionary get resolved by the same rules, recursively. - A python list with a single entry that can resolve to a type, e.g. [int]
z

Zach

05/31/2022, 2:38 PM
is that failing at compile time or at runtime? I've got fields using the
Field(Noneable(Array(str)))
pattern in my own code so it seems to work
s

Samuel Stütz

05/31/2022, 2:47 PM
compile
but do you have a default value
z

Zach

05/31/2022, 2:51 PM
this is what I've got (dagster 0.14.14):
Copy code
@op(config_schema={"chromosomes": Array(str),
                   "test_field": Field(Noneable(Array(str)), default_value=['1', '2'], is_required=False)})
s

Samuel Stütz

05/31/2022, 3:44 PM
okay I now tried to add it on and op as it was on a resource then I removed it from the function which generated the dict and moved it directly into the decorator. So I guess the decorator magic fails if you return
z

Zach

05/31/2022, 3:46 PM
not quite sure I follow, you might have to provide a code example. you should be able to dynamically generate that field if that's what you're trying to do
o

owen

05/31/2022, 10:49 PM
hi @Samuel Stütz! just checking on if you've resolved the issue. I don't believe there's any real magic in the decorator piece -- I'd expect
Copy code
def get_config_schema():
    return {"test_field": Field(Noneable(Array(str)), default_value=['1', '2'], is_required=False)}

@op(config_schema=get_config_schema())
def foo_op(context):
    ...
to work, so it's possible you were hitting some other issue
3 Views