Fix review issues: async safety, schemas, model relations, and storage#2
Merged
Merged
Conversation
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.
Motivation
DocumentandChunkEmbedding, duplicated schema types/fields, and fragile filename parsing.Description
DocumentandChunkEmbeddingand removed the duplicatedsource_documentcolumn usage so chunk rows usechunk.document.nameinstead of a separate string field.ErrorResponseand re-exported it foraskschema compatibility.DocumentListItemwithpopulate_by_name=Trueso thechunksalias maps tochunks_countreliably during (de)serialization.Dependsprovider helpers so routers useDepends(get_document_service)/Depends(get_question_answer_service)instead of callingService(db)directly.Path(...).suffix, adding enqueue error handling aroundprocess_document_task.delay(...), and marking documentsfailedwitherror_messageon enqueue errors.asyncio.to_thread(...)and implemented an async_ageneratein the demoEchoChatModel.FileStorageService.saveto stream writes in 1MB chunks via thread offload to avoid reading entire uploads into memory, and maderemove()asynchronous._worker_loop) with athreading.Lockto avoid race conditions during initialization and shutdown.Testing
blackon modified files (reformattedsrc/services/storage.py) and completed without blocking.python -m compileall src, which completed successfully.flake8 src, which returned clean results after fixes.Codex Task