Changeset View
Changeset View
Standalone View
Standalone View
examples/docs_snippets/docs_snippets/concepts/types/make_usable.py
from dagster import PythonObjectDagsterType, make_python_type_usable_as_dagster_type, solid | from dagster import ( | ||||
PythonObjectDagsterType, | |||||
make_python_type_usable_as_dagster_type, | |||||
solid, | |||||
) | |||||
class EvenType: | class EvenType: | ||||
def __init__(self, num): | def __init__(self, num): | ||||
assert num % 2 is 0 | assert num % 2 is 0 | ||||
self.num = num | self.num = num | ||||
EvenDagsterType = PythonObjectDagsterType(EvenType, name="EvenDagsterType") | EvenDagsterType = PythonObjectDagsterType(EvenType, name="EvenDagsterType") | ||||
make_python_type_usable_as_dagster_type(EvenType, EvenDagsterType) | make_python_type_usable_as_dagster_type(EvenType, EvenDagsterType) | ||||
@solid | @solid | ||||
def double_even(even_num: EvenType) -> EvenType: | def double_even(even_num: EvenType) -> EvenType: | ||||
return EvenType(even_num.num * 2) | return EvenType(even_num.num * 2) |