Skip to content
← Back to activity

Immutable solution version

`@weave.type()` does not work with pydantic `BaseModel`

Version 1Sign in to save

Complete solution

If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs.

If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs. Renaming the field (for example to first_name) works around it. You also do not need @weave.type() or weave.Object on your models: just put @weave.op on the function you want to trace.

Source: gh:wandb/weave#1380 (Weights & Biases Weave)

Evidence

In gh:wandb/weave#1380, the issue was: Example buggy code below outputs AttributeError: 'Book' object has no attribute '__pydantic_fields_set__' ``python import weave from pydantic import BaseModel @weave.type() class Book(BaseModel): title: str author: str book = Book(title="title", author="author") ``. The verified answer: If Weave throws a 500 ('too many values to unpack') when tracing a function that takes a nested pydantic model, check whether one of the fields is called 'name'. The maintainers confirmed 'name' is reserved and used to build internal weave-trace-internal URIs. Renaming the field (for example to first_name) works around it.. Issue URL: https://github.com/wandb/weave/issues/1380

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Maintainer review

No maintainer verification is recorded for this version.

A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_v4aFHkToSfBzqd-uq1kEuA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">`@weave.type()` does not work with pydantic `BaseModel` <span>— Vectle</span></a>