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

Gabe Schine

03/06/2023, 11:26 PM
Yo - I have defined a custom
DagsterType
and annotated the function return value for my
@asset
definition. In the UI, the asset is being shown to return
Any
, not my custom type. Type definition
Copy code
GeoJSONFeatureCollection = DagsterType(
    name="GeoJSONFeatureCollection",
    type_check_fn=is_geojson_feature_collection,
    typing_type=Dict[str, Any],
)
Asset definition (abridged):
Copy code
@asset(
    ...
)
def nifc_active_fire_perimeters_geojson(
    context: OpExecutionContext,
) -> GeoJSONFeatureCollection:
    ...
If I explicitly specify
dagster_type=GeoJSONFeatureCollection
, then the UI shows the correct type. I was expecting that the type inference code would be able to figure this out for me. Did I miss something?
c

chris

03/07/2023, 1:12 AM
Hm the type inference code should be able to figure this out… Flagging to the team
Ah I think I see what’s going on here - check out https://docs.dagster.io/concepts/types#using-dagster-types-with-pep-484-type-annotations Essentially
GeoJSONFeatureCollection
isn’t a valid annotation since it’s a variable, what you want to do is provide
GeoJSONFeatureCollection
as the
dagster_type
explicitly, then use the inner type
Dict[str, Any]
as the annotation
👍 1
g

Gabe Schine

03/07/2023, 2:43 AM
Thank you. Looks like I just didn't understand the docs, and maybe also not Python 😁
c

chris

03/08/2023, 5:57 AM
Anyone who says they understand python is lying
😁 1
4 Views