Folks may already know this but fyi if anyone else...
# ask-community
k
Folks may already know this but fyi if anyone else has been wanting to use Prefect params in Cloud and be able to run the CLI scripts the terminal, you can just add
typer.run
directly and it'll work for both. i.e.:
Copy code
if __name__ == "__main__":
    typer.run(process_file_flow)
❤️ 4
n
Nice idea ❤️ But unfortunately typer does not support Pydantic Models as parameters
n
hi @Nico Neumann - in case this is helpful, you can pass json to a flow expecting a pydantic model and it will be coerced into an instance of that model at runtime
Copy code
❯ ipython
Python 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:25:12) [Clang 14.0.6 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from prefect import flow

In [2]: from pydantic import BaseModel

In [3]: class MyModel(BaseModel):
   ...:     foo: str
   ...:     bar: int
   ...:

In [4]: @flow
   ...: def my_flow(my_model: MyModel):
   ...:     print(type(my_model), my_model)
   ...:

In [5]: my_flow(my_model={"foo": "hi", "bar": 42})

19:56:20.346 | INFO    | prefect.engine - Created flow run 'arboreal-swift' for flow 'my-flow'
<class '__main__.MyModel'> foo='hi' bar=42
19:56:21.523 | INFO    | Flow run 'arboreal-swift' - Finished in state Completed()
🙏 1
🙌 1