Can you pass pedantic models between flows? Furth...
# prefect-cloud
m
Can you pass pedantic models between flows? Furthermore, if you can, can you pass models that allow abstract types
1
n
hey @Matthew Scanlon - yes, locally you can pass around pretty much anything that python functions can return / accept
Copy code
In [14]: class Anything(BaseModel):
    ...:     foo: str
    ...:

In [15]: @flow
    ...: def emits_anything() -> Anything:
    ...:     return Anything(foo="something")
    ...:

In [16]: @flow(log_prints=True)
    ...: def accepts_anything(anything: Anything):
    ...:     print(anything)
    ...:

In [17]: anything = emits_anything()
15:12:33.619 | INFO    | prefect.engine - Created flow run 'quartz-iguana' for flow 'emits-anything'
15:12:34.441 | INFO    | Flow run 'quartz-iguana' - Finished in state Completed()

In [18]: accepts_anything(anything)
15:12:44.867 | INFO    | prefect.engine - Created flow run 'magnetic-copperhead' for flow 'accepts-anything'
15:12:45.372 | INFO    | Flow run 'magnetic-copperhead' - foo='something'
15:12:45.495 | INFO    | Flow run 'magnetic-copperhead' - Finished in state Completed()
but if you're passing in flow run params in network calls, then you'll have to pass a JSON-serializable representation of those models, which the flow run will coerce into the expected type according to the flow run type annotations
m
Got it. So as long as its json serializable, its prefect cloud safe? Awesome!
👍 1