Merged
Conversation
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
JoanFM
previously requested changes
Feb 27, 2023
JohannesMessner
requested changes
Feb 27, 2023
Member
There was a problem hiding this comment.
I think we should split this out into two functions:
- one that mirrors
create_modelas closely as possible, has a similar name, takes all the same arguments, and just makes sure that the__base__is set correctly. It should also take the fields in the same way pydantic does - another, slightly higher level one, that would be called
creat_from_dict, and take the fields as a dictionary. This would also closely mirror functionality in pydantic: https://docs.pydantic.dev/usage/models/#model-creation-from-namedtuple-or-typeddict
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
samsja
reviewed
Feb 27, 2023
samsja
reviewed
Feb 27, 2023
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
samsja
reviewed
Feb 28, 2023
samsja
reviewed
Feb 28, 2023
samsja
requested changes
Feb 28, 2023
Member
There was a problem hiding this comment.
good job ! I added a small requests
JohannesMessner
approved these changes
Feb 28, 2023
Member
There was a problem hiding this comment.
Nice! Should we also have something that creates from normal dict by looking at the data and "guessing" the type? This would be different from what pydantic can do, and could be a separate PR
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
samsja
reviewed
Feb 28, 2023
Signed-off-by: AnneY <evangeline-lun@foxmail.com>
|
📝 Docs are deployed on https://ft-feat-dynamic-creation--jina-docs.netlify.app 🎉 |
samsja
approved these changes
Feb 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goals:
This PR is for issue #1152
In the issue, Pydantic's create_model was mentioned. In order for the function to return a subclass of
BaseDocument, we need to pass the parameter__base__.