How do I set a list of default values. ``` Field( ...
# ask-community
s
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
Would an Enum config type work?
s
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
Oh apologies, I misunderstood the problem. Have you tried
Copy code
Field(Noneable(Array(str)), default_value=['GIT_HASH', 'DAGSTER_VERSION'])?
s
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
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
compile
but do you have a default value
z
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
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
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
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