Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
docs: explain how to set document config
Signed-off-by: Johannes Messner <[email protected]>
  • Loading branch information
JohannesMessner committed Sep 5, 2023
commit ea6e9bd33453b50bd545c89d0ad85aee319daabf
15 changes: 15 additions & 0 deletions docs/user_guide/representing/first_step.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ This representation can be used to [send](../sending/first_step.md) or [store](.

[BaseDoc][docarray.base_doc.doc.BaseDoc] can be nested to represent any kind of data hierarchy.

## Setting a Pydantic `Config` class

Documents support setting a `Config` [like any other Pydantic `BaseModel`](https://docs.pydantic.dev/latest/usage/model_config/).

However, if you set a config, you should inherit from the `BaseDoc` config class:

```python
from docarray import BaseDoc


class MyDoc(BaseDoc):
class Config(BaseDoc.Config):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment. In pydantic v1, we only had to pass a class Config in the model. It didn't need to be inherited from another config class.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in pydantic that is not needed. But we set some pydantic configs in BaseDoc, so to preserve them, inheritance is needed. We could probably find some magic way around this, but until then this is the safest option imo.

arbitrary_types_allowed = True # just an example setting
```

See also:

* The [next part](./array.md) of the representing section
Expand Down