Chris Roth
04/03/2020, 11:28 PMalex
04/03/2020, 11:33 PMPythonObjectDagsterType
Chris Roth
04/03/2020, 11:38 PMalex
04/03/2020, 11:39 PMChris Roth
04/03/2020, 11:39 PMSimon Späti
10/15/2020, 2:27 PMAny
, or is there a way to directly have a type JSON. Or is that a PythonObjectDagsterType as well?
I just don’t like Any so much. Thanks a lot. I gues a Type would make sense, so I can also introduce checks if the JSON is valid and so on. Correct? Any example of this already maybe? =)alex
10/15/2020, 2:31 PMDagsterType
will allow you to write the type_check_fn
that does as many checks as you wantPythonObjectDagsterType
works best when your check would just be isinstance
, which for this json i am guessing won’t be what you are looking forSimon Späti
10/16/2020, 7:48 PMDagsterType
as below:
def isjson(_, value):
try:
json.loads(value)
return True
except ValueError:
return False
JsonType = DagsterType(
name="JsonType",
description="A valid representation of a JSON, validated with json.loads().",
type_check_fn=isjson,
)