should `Dict`s be a valid dagster type in a Field ...
# announcements
m
should `Dict`s be a valid dagster type in a Field config? I'm trying to create a
Field
with a Dict type, but getting
DagsterInvalidDefinitionError
. tried both the dagster Dict (
from dagster import Dict
) and the typing Dict. the error message seems to imply Dicts and NamedDicts are valid, though
n
yes that should work fine, can you include a bit more of what the definition looks like?
m
sure, here's the decorator:
and here's what it throws when parsing
n
ah, I see the issue! so
Dict
expects to have explicit schema of the fields it contains, e.g.
Copy code
Field(Dict({'some_key': Field(str)}))
I think what you want here is probably
PermissiveDict
which permits arbitrary key-value pairs
🙌 1
m
boom, that worked. thanks @nate!
n
metal awesome. yeah our docs on this are unfortunately rather buried in the API docs here https://dagster.readthedocs.io/en/0.6.3/sections/api/apidocs/types.html#dagster.Dict
👍 1
as a quick aside, one other tip - we’ve set things up so you can now use built-in python types for most scalar types in dagster, e.g. use
str
instead of having to
from dagster import String
,
int
, etc.
save some keystrokes 🙂