<Release - [Test/Alpha] Pydantic PR #1660> New rel...
# flytekit
a
t
@cool-lifeguard-49380 @loud-oil-9899 - this is the latest commit on that pr - 4c463dee4088e5e44dd1086cff6d7d2903df724d
we can do more
c
Cool thanks, will report back πŸ‘
l
Thanks!
b
just for reference, this is what a v1 + v2-supported PR looks like: https://github.com/unionai-oss/pandera/pull/1253 (obviously the pydantic migration guide would probably be the best place to start)
a
Nice! I might go ahead and try this as well as we’re using pydantic for a lot of our internal models πŸ‘
c
Our integration tests failed when I removed our internal pydantic base model type transformer and replaced it with the alpha release. I boiled it down to this minimal example:
Copy code
from flytekit import task, workflow, dynamic

from pydantic import BaseModel


class Config(BaseModel):
    path: str


@task
def train(cfg: Config):
    print(cfg)


@dynamic(cache=True, cache_version="0.3")
def sub_wf(cfg: Config):
    train(cfg=cfg)


@workflow
def wf():
    sub_wf(cfg=Config(path="bar"))


if __name__ == "__main__":
    wf()
Upon local execution with
python test.py
, the error is:
Copy code
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/core/workflow.py:271 in __call__                  β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 271 β”‚   β”‚   β”‚   raise exc                                                                                                 β”‚
β”‚                                                                                                                             β”‚
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/core/workflow.py:268 in __call__                  β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 268 β”‚   β”‚   β”‚   return flyte_entity_call_handler(self, *args, **input_kwargs)                                             β”‚
β”‚                                                                                                                             β”‚
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/core/promise.py:1022 in flyte_entity_call_handler β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 1022 β”‚   β”‚   β”‚   result = cast(LocallyExecutable, entity).local_execute(child_ctx, **kwargs)                              β”‚
β”‚                                                                                                                             β”‚
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/core/workflow.py:290 in local_execute             β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 290 β”‚   β”‚   function_outputs = self.execute(**kwargs_literals)                                                            β”‚
β”‚                                                                                                                             β”‚
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/core/workflow.py:729 in execute                   β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 729 β”‚   β”‚   return exception_scopes.user_entry_point(self._workflow_function)(**kwargs)                                   β”‚
β”‚                                                                                                                             β”‚
β”‚ /home/fabiogratz/miniconda3/envs/dev/lib/python3.9/site-packages/flytekit/exceptions/scopes.py:203 in user_entry_point      β”‚
β”‚                                                                                                                             β”‚
β”‚ ❱ 203 β”‚   β”‚   β”‚   β”‚   raise type(exc)(f"Error encountered while executing '{fn_name}':\n  {exc                              β”‚
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Encountered error while executing workflow 'wf':
  Error encountered while executing 'wf':
  Parameter to MergeFrom() must be instance of same class: expected <class 'flyteidl.core.literals_pb2.Literal'> got <class 
'flyteidl.core.literals_pb2.LiteralMap'>.
πŸ‘ 1
When setting
cache=False
it works. But having forgotten to bump the cache version appears not to be the problem. When activating the cache and setting a cache version that 100% was never used before, it fails with this error on the first try.
Can you pls take a look whether you can reproduce this error @loud-oil-9899?
l
thanks Fabio! I'll check it out
πŸ™ 1