https://dagster.io/ logo
s

sandy

04/08/2021, 3:25 PM
Bye bye 
PythonObjectDagsterType
 and bye bye (mostly) to 
make_python_type_usable_as_dagster_type
  I wanted to highlight a recent change that makes Dagster easier to use with PEP 484 type annotations. Previously, 
@solid
-decorated functions would only accept type annotations for a limited subset of types.  E.g. the following code would fail with a `DagsterInvalidDefinitionError`:
Copy code
class MyClass:
    pass

@solid
def my_solid(_, input1: MyClass):
   pass
As of 0.11.0, this is a valid definition. Dagster will automatically construct a 
DagsterType
 for 
MyClass
, which means it will automatically show up in Dagit as well. This change should significantly reduce boilerplate in some situations.  You should never need to instantiate a 
PythonObjectDagsterType
, and you should only need to use the 
usable_as_dagster_type
 and 
make_python_type_usable_as_dagster_type
 APIs in situations where you want to apply a custom type check function to every instance of a particular Python type. Happy typing!
🪄 1
🙌 9
blob hero 2
😮 1
s

schrockn

04/08/2021, 3:26 PM
cc: @dwall i think this will be of interest
d

dwall

04/08/2021, 3:35 PM
Woo!!
So much more intuitive and way less boilerplate. Nice work <!subteam^S017AHZGB5Y|@elementl-team> !!!!
🙌🏻 1
a

Alessandro Marrella

04/08/2021, 3:57 PM
that's nice! i'm inspecting the dagster type in my IO Manager, is there a way to reconstruct what dagster does with the class?
a

alex

04/08/2021, 3:58 PM
i believe the
python_type
property should be consistent between the old way and this new way - calling that on the
DagsterType
might be the way to go. @sandy can confirm
s

sandy

04/08/2021, 4:01 PM
@Alessandro Marrella - in your
load_input
, you can access
context.dagster_type.python_type
. Does that answer your question?
a

Alessandro Marrella

04/08/2021, 4:03 PM
i believe it does, thanks! 🙇
a

Alex Despotakis

04/08/2021, 4:39 PM
Praise be
blob pray 1