Repository navigation
fix(documents): type the server's batch_size in import parameters - #160
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
Fixes typesense#124. The batch_size argument of import_ splits the list on the client and is never sent to the server, while the import parameter types had no batch_size key, so the documented server parameter failed the type check. Add DocumentImportWriteParameters with batch_size, use it for the plain import and the return_id/return_doc variants, and document the difference in the import_ docstring.
This branch has not been deployed
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.
Fixes #124.
import_(docs, batch_size=42)does not sendbatch_sizeto the server. That argument splits the list into requests of that size on the client. To set the server'sbatch_sizequery parameter you pass it inimport_parameters, which works at run time, but none of the import parameter types had abatch_sizekey, so a type checker rejects it.What I changed:
DocumentImportWriteParameters(extendsDocumentWriteParameters) withbatch_size: NotRequired[int].return_id,return_docandreturn_doc+return_idimport types extend it, andDocumentImportParametersuses it in place ofDocumentWriteParameters. The plainimport_overload and thecreate_manycast use it too.import_docstring now says whichbatch_sizegoes where.async_/and regeneratedsync/withutils/run-unasync.py.Tests: new
tests/import_parameters_test.pychecks the types, thatimport_parameters={"batch_size": 42}reaches the query string, and that thebatch_sizeargument splits the requests and is not sent. It fails on master (the type does not exist) and passes with the change.mypy src/typesense,ruff checkandruff format --checkon the changed files pass, and the mock-transport suites pass. Tests that need a running Typesense server were not run locally.