-
Notifications
You must be signed in to change notification settings - Fork 237
feat: make compatible based type with fastapi #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
77a2055
feat: allow da bulk access to return da for document
samsja bd6d128
fix: fix mypy type pb
samsja d778cec
fix: add link to the mypy issue
samsja 717e7ee
fix: remove useless list type hint
samsja 2c3d5f1
feat: torch tensor type (#800)
JohannesMessner e5d678c
feat: add fastapi to dependency
samsja 414a04c
feat(wip): add fake method to dump tensor to json
samsja 42c6fe4
feat(wip): add fastapi test
samsja 56497b9
feat: add json dump for type and document
samsja 945a72a
feat: add json compatible with orjson
samsja 83236cd
refactor: clean tests
samsja f1a4d7b
fix: remove duplicate
samsja c983246
fix: better json schema for tensor
samsja 3873a9a
fix: fix fast api test
samsja 51a402d
refactor: move to json test to integration
samsja 2e92866
fix: json laod from tensor type now working
samsja 606134b
fix: add tensor to fastapi test
samsja 731feff
fix: add new fastapi test
samsja e114b91
Merge branch 'feat-rewrite-v2' into feat-v2-fastapi-test
samsja 061b05e
fix: fix mypy
samsja 94c0069
feat: add more testing for text uri about json
samsja e04285a
fix: fix default orson not returning
samsja b8de8bc
fix: apply johannes suggestion on docstring
samsja 19ffb0b
fix: does not perform copy anymore on torch tensor unwrap
samsja 0b7dac7
fix: add johannes suggestion
samsja a334c65
fix: fix ruff line lenght
samsja 909ee74
fix: fix mypy pb
samsja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Empty file.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import orjson | ||
|
|
||
|
|
||
| def _default_orjson(obj): | ||
| """ | ||
| default option for orjson dumps. It will call _to_json_compatible | ||
| from docarray typing object that expose such method. | ||
| :param obj: | ||
| :return: return a json compatible object | ||
| """ | ||
|
|
||
| if getattr(obj, '_to_json_compatible'): | ||
| return obj._to_json_compatible() | ||
| else: | ||
| return obj | ||
|
|
||
|
|
||
| def orjson_dumps(v, *, default=None): | ||
| # orjson.dumps returns bytes, to match standard json.dumps we need to decode | ||
| return orjson.dumps( | ||
| v, default=_default_orjson, option=orjson.OPT_SERIALIZE_NUMPY | ||
| ).decode() | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.