From bf06a0bcf4facddca03160e6162b6aed24d570d9 Mon Sep 17 00:00:00 2001 From: joel-joseph-george Date: Wed, 23 Aug 2023 16:06:35 +0530 Subject: [PATCH 1/4] FAST API: 0.101.1 -> pydantic v1 --- app/routers/auth_api.py | 8 +- app/routers/content_apis.py | 188 +++++++++++++++---------------- app/routers/filehandling_apis.py | 16 +-- app/routers/media_api.py | 16 +-- app/routers/translation_apis.py | 142 +++++++++++------------ requirements.txt | 8 +- 6 files changed, 191 insertions(+), 187 deletions(-) diff --git a/app/routers/auth_api.py b/app/routers/auth_api.py index 24c76268..86c50f3d 100644 --- a/app/routers/auth_api.py +++ b/app/routers/auth_api.py @@ -77,8 +77,8 @@ def logout(request: Request,user_details =Depends(get_user_or_none),#pylint: dis ,tags=["Authentication"]) @get_auth_access_check_decorator async def get_identities_list(request: Request,#pylint: disable=unused-argument - name: str = Query(None, example="Bridgeconn"), - user_id: str = Query(None, example="ecf57420-9rg0-40t8-b56b-dce1fc52c452"), + name: str = Query(None, examples="Bridgeconn"), + user_id: str = Query(None, examples="ecf57420-9rg0-40t8-b56b-dce1fc52c452"), roles:List[schema_auth.FilterRoles]=Query([schema_auth.FilterRoles.ALL]), skip: int = Query(0, ge=0),limit: int = Query(100, ge=0), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)):#pylint: disable=unused-argument @@ -100,7 +100,7 @@ async def get_identities_list(request: Request,#pylint: disable=unused-argument ,tags=["Authentication"]) @get_auth_access_check_decorator async def get_user_profile(request: Request,#pylint: disable=unused-argument - user_id:str =Path(...,example="4bd012fd-7de8-4d66-928f-4925ee9bb"), + user_id:str =Path(...,examples="4bd012fd-7de8-4d66-928f-4925ee9bb"), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)):#pylint: disable=unused-argument '''fetches user profile Data''' log.info('In User Profile') @@ -132,7 +132,7 @@ async def userrole(role_data:schema_auth.UserRole,request: Request,#pylint: disa 500: {"model": schemas.ErrorResponse}},status_code=201,tags=["Authentication"]) @get_auth_access_check_decorator async def edit_user(request: Request,#pylint: disable=unused-argument - user_id:str =Path(...,example="4bd012fd-7de8-4d66-928f-4925ee9bb"), + user_id:str =Path(...,examples="4bd012fd-7de8-4d66-928f-4925ee9bb"), edit_details:schema_auth.EditUser = Body(...), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)):#pylint: disable=unused-argument '''update user data''' diff --git a/app/routers/content_apis.py b/app/routers/content_apis.py index d83bdb0c..66ec53ab 100644 --- a/app/routers/content_apis.py +++ b/app/routers/content_apis.py @@ -23,7 +23,7 @@ 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Resources Types"]) @get_auth_access_check_decorator -async def get_resources_types(request: Request,resource_type: str = Query(None, example="bible"), +async def get_resources_types(request: Request,resource_type: str = Query(None, examples="bible"), skip: int = Query(0, ge=0),limit: int = Query(100, ge=0), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)): '''fetches all the resources types supported and their details @@ -66,7 +66,7 @@ async def add_resources_types(request: Request, resourcetype: schemas.ResourceTy status_code=200,tags=["Resources Types"]) @get_auth_access_check_decorator async def delete_resources_types(request: Request, - resourcetype_id: int = Query(..., example=100001), + resourcetype_id: int = Query(..., examples=100001), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Resourcetype * unique ResourceType Id can be used to delete an exisiting identity''' @@ -91,10 +91,10 @@ async def delete_resources_types(request: Request, 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Languages"]) @get_auth_access_check_decorator async def get_language(request: Request, - language_code : schemas.LangCodePattern = Query(None, example="hi"), - language_name: str = Query(None, example="hindi"), - search_word: str = Query(None, example="Sri Lanka"), - localscript_name: str = Query(None,example="हिंदी"), + language_code : schemas.LangCodePattern = Query(None, examples="hi"), + language_name: str = Query(None, examples="hindi"), + search_word: str = Query(None, examples="Sri Lanka"), + localscript_name: str = Query(None,examples="हिंदी"), skip: int = Query(0, ge=0), limit: int = Query(100, ge=0), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)): '''fetches all the languages supported in the DB, their code and other details. @@ -149,7 +149,7 @@ async def edit_language(request: Request, lang_obj: schemas.LanguageEdit = Body( status_code=200,tags=["Languages"]) @get_auth_access_check_decorator async def delete_languages(request: Request, - language_id: int = Query(..., example=100001), + language_id: int = Query(..., examples=100001), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Language * unique Language Code can be used to delete an exisiting identity''' @@ -171,9 +171,9 @@ async def delete_languages(request: Request, 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Licenses"]) @get_auth_access_check_decorator async def get_license(request: Request, - license_code : schemas.LicenseCodePattern=Query(None, example="CC-BY-SA"), - license_name: str=Query(None, example="Creative Commons License"), - permission: schemas.ResourcePermissions=Query(None, example="open-access"), + license_code : schemas.LicenseCodePattern=Query(None, examples="CC-BY-SA"), + license_name: str=Query(None, examples="Creative Commons License"), + permission: schemas.ResourcePermissions=Query(None, examples="open-access"), active: bool=Query(True), skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none),db_: Session=Depends(get_db)): '''fetches all the licenses present in the DB, their code and other details. @@ -226,7 +226,7 @@ async def edit_license(request: Request, license_obj: schemas.LicenseEdit = Body status_code=200,tags=["Licenses"]) @get_auth_access_check_decorator async def delete_licenses(request: Request, - license_id:int = Query(..., example=100001), + license_id:int = Query(..., examples=100001), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete License * unique License Id can be used to delete an exisiting identity''' @@ -248,10 +248,10 @@ async def delete_licenses(request: Request, 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Versions"]) @get_auth_access_check_decorator async def get_version(request: Request, - version_abbreviation : schemas.VersionPattern = Query(None, example="KJV"), - version_name: str = Query(None, example="King James Version"), + version_abbreviation : schemas.VersionPattern = Query(None, examples="KJV"), + version_name: str = Query(None, examples="King James Version"), version_tag : schemas.VersionTagPattern = Query(None), - metadata: schemas.MetaDataPattern = Query(None, example='{"publishedIn":"1611"}'), + metadata: schemas.MetaDataPattern = Query(None, examples='{"publishedIn":"1611"}'), skip: int = Query(0, ge=0), limit: int = Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Fetches all versions and their details. @@ -315,7 +315,7 @@ async def edit_version(request: Request, ver_obj: schemas.VersionEdit = Body(... status_code=200,tags=["Versions"]) @get_auth_access_check_decorator async def delete_versions(request: Request, - version_id: int = Query(..., example=100001), + version_id: int = Query(..., examples=100001), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Version * unique Version Id can be used to delete an exisiting identity''' @@ -339,14 +339,14 @@ async def delete_versions(request: Request, status_code=200, tags=["Resources"]) @get_auth_access_check_decorator async def get_resource(request: Request, #pylint: disable=too-many-locals - resource_name : schemas.TableNamePattern=Query(None, example="hi_IRV_1_bible"), - resource_type: str=Query(None, example="commentary"), - version_abbreviation: schemas.VersionPattern=Query(None,example="KJV"), - version_tag: schemas.VersionTagPattern=Query(None, example="1611.12.31"), - language_code: schemas.LangCodePattern=Query(None,example="en"), - license_code: schemas.LicenseCodePattern=Query(None,example="ISC"), + resource_name : schemas.TableNamePattern=Query(None, examples="hi_IRV_1_bible"), + resource_type: str=Query(None, examples="commentary"), + version_abbreviation: schemas.VersionPattern=Query(None,examples="KJV"), + version_tag: schemas.VersionTagPattern=Query(None, examples="1611.12.31"), + language_code: schemas.LangCodePattern=Query(None,examples="en"), + license_code: schemas.LicenseCodePattern=Query(None,examples="ISC"), metadata: schemas.MetaDataPattern=Query(None, - example='{"otherName": "KJBC, King James Bible Commentaries"}'), + examples='{"otherName": "KJBC, King James Bible Commentaries"}'), access_tag:List[schemas.ResourcePermissions]=Query([schemas.ResourcePermissions.CONTENT]), labels:List[schemas.ResourceLabel] = Query([]), active: bool = True, latest_revision: bool = True, @@ -457,7 +457,7 @@ async def edit_resource(request: Request,resource_obj: schemas.ResourceEdit = Bo status_code=200,tags=["Resources"]) @get_auth_access_check_decorator async def delete_resources(request: Request, - resource_id:int = Query(..., example=100001), + resource_id:int = Query(..., examples=100001), user_details =Depends(get_user_or_none), \ db_: Session = Depends(get_db)): '''Delete Resource @@ -479,9 +479,9 @@ async def delete_resources(request: Request, responses={502: {"model": schemas.ErrorResponse}, 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Lookups"]) @get_auth_access_check_decorator -async def get_bible_book(request: Request,book_id: int=Query(None, example=67), - book_code: schemas.BookCodePattern=Query(None,example='rev'), - book_name: str=Query(None, example="Revelation"),user_details =Depends(get_user_or_none), +async def get_bible_book(request: Request,book_id: int=Query(None, examples=67), + book_code: schemas.BookCodePattern=Query(None,examples='rev'), + book_name: str=Query(None, examples="Revelation"),user_details =Depends(get_user_or_none), skip: int = Query(0, ge=0), limit: int = Query(100, ge=0), db_: Session = Depends(get_db)): ''' returns the list of book ids, codes and names. * optional query parameters can be used to filter the result set @@ -505,7 +505,7 @@ async def get_bible_book(request: Request,book_id: int=Query(None, example=67), status_code=201, tags=["Bibles"]) @get_auth_access_check_decorator async def add_bible_book(request: Request, - resource_name : schemas.TableNamePattern=Path(..., example="hi_IRV_1_bible"), + resource_name : schemas.TableNamePattern=Path(..., examples="hi_IRV_1_bible"), books: List[schema_content.BibleBookUpload] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -526,7 +526,7 @@ async def add_bible_book(request: Request, status_code=201, tags=["Bibles"]) @get_auth_access_check_decorator async def edit_bible_book(request: Request, - resource_name: schemas.TableNamePattern=Path(..., example="hi_IRV_1_bible"), + resource_name: schemas.TableNamePattern=Path(..., examples="hi_IRV_1_bible"), books: List[schema_content.BibleBookEdit] = Body(...),user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Either changes the active status or the bible contents. @@ -553,8 +553,8 @@ async def edit_bible_book(request: Request, status_code=200, tags=["Bibles"]) @get_auth_access_check_decorator async def get_available_bible_book(request: Request, - resource_name: schemas.TableNamePattern=Path(...,example="hi_IRV_1_bible"), - book_code: schemas.BookCodePattern=Query(None, example="mat"), + resource_name: schemas.TableNamePattern=Path(...,examples="hi_IRV_1_bible"), + book_code: schemas.BookCodePattern=Query(None, examples="mat"), content_type: schema_content.BookContentType=Query(None), active: bool=True, skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): @@ -578,8 +578,8 @@ async def get_available_bible_book(request: Request, status_code=200,tags=["Bibles"]) @get_auth_access_check_decorator async def delete_bible_book(request: Request, - biblebook_id:int = Query(..., example=100001), - resource_name: str = Path(...,example="en_KJV_1_bible"), + biblebook_id:int = Query(..., examples=100001), + resource_name: str = Path(...,examples="en_KJV_1_bible"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Bible Book * unique bible book id with resource name can be used to delete an exisiting identity''' @@ -610,7 +610,7 @@ async def delete_bible_book(request: Request, 422: {"model": schemas.ErrorResponse}}, status_code=200, tags=["Bibles"]) @get_auth_access_check_decorator async def get_bible_versification(request: Request, - resource_name:schemas.TableNamePattern=Path(..., example="hi_IRV_1_bible"), + resource_name:schemas.TableNamePattern=Path(..., examples="hi_IRV_1_bible"), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): '''Fetches the versification structure of the specified bible, with details of number of chapters, max verses in each chapter etc''' @@ -627,10 +627,10 @@ async def get_bible_versification(request: Request, status_code=200, tags=["Bibles"]) @get_auth_access_check_decorator async def get_bible_verse(request: Request, - resource_name: schemas.TableNamePattern=Path(..., example="hi_IRV_1_bible"), - book_code: schemas.BookCodePattern=Query(None, example="mat"), - chapter: int=Query(None, example=1), verse: int=Query(None, example=1), - last_verse: int=Query(None, example=15), search_phrase: str=Query(None, example='सन्‍तान'), + resource_name: schemas.TableNamePattern=Path(..., examples="hi_IRV_1_bible"), + book_code: schemas.BookCodePattern=Query(None, examples="mat"), + chapter: int=Query(None, examples=1), verse: int=Query(None, examples=1), + last_verse: int=Query(None, examples=15), search_phrase: str=Query(None, examples='सन्‍तान'), active: bool=True, skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): @@ -662,10 +662,10 @@ async def get_bible_verse(request: Request, 415:{"model": schemas.ErrorResponse}}, status_code=200, tags=["Commentaries"]) @get_auth_access_check_decorator async def get_commentary(request: Request, - resource_name: schemas.TableNamePattern=Path(..., example="en_BBC_1_commentary"), - book_code: schemas.BookCodePattern=Query(None, example="1ki"), - chapter: int = Query(None, example=10, ge=-1), verse: int = Query(None, example=1, ge=-1), - last_verse: int = Query(None, example=3, ge=-1), active: bool = True, + resource_name: schemas.TableNamePattern=Path(..., examples="en_BBC_1_commentary"), + book_code: schemas.BookCodePattern=Query(None, examples="1ki"), + chapter: int = Query(None, examples=10, ge=-1), verse: int = Query(None, examples=1, ge=-1), + last_verse: int = Query(None, examples=3, ge=-1), active: bool = True, skip: int = Query(0, ge=0), limit: int = Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Fetches commentries under the specified resource. @@ -695,7 +695,7 @@ async def get_commentary(request: Request, status_code=201, tags=["Commentaries"]) @get_auth_access_check_decorator async def add_commentary(request: Request,background_tasks: BackgroundTasks, - resource_name : schemas.TableNamePattern=Path(...,example="en_BBC_1_commentary"), + resource_name : schemas.TableNamePattern=Path(...,examples="en_BBC_1_commentary"), commentaries: List[schema_content.CommentaryCreate] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -736,7 +736,7 @@ async def add_commentary(request: Request,background_tasks: BackgroundTasks, status_code=201, tags=["Commentaries"]) @get_auth_access_check_decorator async def edit_commentary(request: Request,background_tasks: BackgroundTasks, - resource_name: schemas.TableNamePattern=Path(..., example="en_BBC_1_commentary"), + resource_name: schemas.TableNamePattern=Path(..., examples="en_BBC_1_commentary"), commentaries: List[schema_content.CommentaryEdit] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -770,8 +770,8 @@ async def edit_commentary(request: Request,background_tasks: BackgroundTasks, status_code=200,tags=["Commentaries"]) @get_auth_access_check_decorator async def delete_commentary(request: Request, - commentary_id:int = Query(..., example=100001), - resource_name: schemas.TableNamePattern=Path(..., example="en_BBC_1_commentary"), + commentary_id:int = Query(..., examples=100001), + resource_name: schemas.TableNamePattern=Path(..., examples="en_BBC_1_commentary"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Commentary * unique Commentary Id with resource name can be used to delete an exisiting identity''' @@ -799,10 +799,10 @@ async def delete_commentary(request: Request, 404:{"model": schemas.ErrorResponse},}, status_code=200, tags=["Vocabularies"]) @get_auth_access_check_decorator async def get_vocabulary_word(request: Request, - resource_name: schemas.TableNamePattern=Path(...,example="en_TW_1_vocabulary"), - search_word: str=Query(None, example="Adam"), + resource_name: schemas.TableNamePattern=Path(...,examples="en_TW_1_vocabulary"), + search_word: str=Query(None, examples="Adam"), exact_match: bool=False, word_list_only: bool=False, - details: schemas.MetaDataPattern=Query(None, example='{"type":"person"}'), active: bool=None, + details: schemas.MetaDataPattern=Query(None, examples='{"type":"person"}'), active: bool=None, skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db), operates_on=Depends(AddHiddenInput(value=schema_auth.ResourceType.CONTENT.value))): @@ -834,10 +834,10 @@ async def get_vocabulary_word(request: Request, 404:{"model": schemas.ErrorResponse},}, status_code=200, tags=["Vocabularies"]) @get_auth_access_check_decorator async def get_vocabulary_word_count(request: Request, - resource_name: schemas.TableNamePattern=Path(...,example="en_TW_1_vocabulary"), - search_word: str=Query(None, example="Adam"), + resource_name: schemas.TableNamePattern=Path(...,examples="en_TW_1_vocabulary"), + search_word: str=Query(None, examples="Adam"), exact_match: bool=False, - details: schemas.MetaDataPattern=Query(None, example='{"type":"person"}'), + details: schemas.MetaDataPattern=Query(None, examples='{"type":"person"}'), active: bool= Query(None), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db), operates_on=Depends(AddHiddenInput(value=schema_auth.ResourceType.CONTENT.value))): @@ -869,7 +869,7 @@ async def get_vocabulary_word_count(request: Request, status_code=201, tags=["Vocabularies"]) @get_auth_access_check_decorator async def add_vocabulary_word(request: Request, - resource_name : schemas.TableNamePattern=Path(..., example="en_TW_1_vocabulary"), + resource_name : schemas.TableNamePattern=Path(..., examples="en_TW_1_vocabulary"), vocabulary_words: List[schema_content.VocabularyWordCreate] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): ''' uploads dictionay words and their details. 'Details' should be of JSON datatype and have @@ -889,7 +889,7 @@ async def add_vocabulary_word(request: Request, status_code=201, tags=["Vocabularies"]) @get_auth_access_check_decorator async def edit_vocabulary_word(request: Request, - resource_name: schemas.TableNamePattern=Path(..., example="en_TW_1_vocabulary"), + resource_name: schemas.TableNamePattern=Path(..., examples="en_TW_1_vocabulary"), vocabulary_words: List[schema_content.VocabularyWordEdit] = Body(...), user_details =Depends(get_user_or_none),db_: Session = Depends(get_db)): ''' Updates a vocabulary word. Item identifier is word, which cannot be altered. @@ -909,8 +909,8 @@ async def edit_vocabulary_word(request: Request, status_code=200,tags=["Vocabularies"]) @get_auth_access_check_decorator async def delete_vocabularies(request: Request, - word_id: int = Query(..., example=100001), - resource_name: str = Path(...,example="en_KJV_1_vocabulary"), + word_id: int = Query(..., examples=100001), + resource_name: str = Path(...,examples="en_KJV_1_vocabulary"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Vocabulary * unique word Id with resource name can be used to delete an exisiting identity''' @@ -940,17 +940,17 @@ async def delete_vocabularies(request: Request, @get_auth_access_check_decorator async def get_parascriptural(request: Request, #pylint: disable=too-many-locals resource_name:schemas.TableNamePattern= - Path(...,example="en_KJV_1_parascriptural"), - category:str=Query(None, example="Bible project video"), - title:str=Query(None,example="Bible Video of Genesis"), - description:str=Query(None, example="Origin Chronicles"), - content:str=Query(None, example="A Visual Journey Through the Bible's Beginning"), + Path(...,examples="en_KJV_1_parascriptural"), + category:str=Query(None, examples="Bible project video"), + title:str=Query(None,examples="Bible Video of Genesis"), + description:str=Query(None, examples="Origin Chronicles"), + content:str=Query(None, examples="A Visual Journey Through the Bible's Beginning"), reference: str = Query(None, - example='{"book": "mat", "chapter": 1, "verseNumber": 6}'), - link:AnyUrl=Query(None,example="http://someplace.com/resoucesid"), - search_word:str=Query(None,example="subtitle"), + examples='{"book": "mat", "chapter": 1, "verseNumber": 6}'), + link:AnyUrl=Query(None,examples="http://someplace.com/resoucesid"), + search_word:str=Query(None,examples="subtitle"), metadata: schemas.MetaDataPattern=Query(None, - example='{"otherName": "BPV, Videos of Bible chapters"}'), + examples='{"otherName": "BPV, Videos of Bible chapters"}'), active: bool=Query(True), skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): @@ -984,7 +984,7 @@ async def get_parascriptural(request: Request, #pylint: disable=too-many-locals @get_auth_access_check_decorator async def add_parascripturals(request: Request, resource_name : schemas.TableNamePattern=Path(..., - example="en_KJV_1_parascriptural"), + examples="en_KJV_1_parascriptural"), parascriptural: List[schema_content.ParascripturalCreate] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1004,7 +1004,7 @@ async def add_parascripturals(request: Request, @get_auth_access_check_decorator async def edit_parascripturals(request: Request, resource_name: schemas.TableNamePattern=Path(..., - example="en_KJV_1_parascriptural"), + examples="en_KJV_1_parascriptural"), parascripturals: List[schema_content.ParascriptEdit] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1024,8 +1024,8 @@ async def edit_parascripturals(request: Request, status_code=200,tags=["Parascripturals"]) @get_auth_access_check_decorator async def delete_parascripturals(request: Request, - parascript_id:int = Query(..., example=100001), - resource_name: str = Path(...,example="en_KJV_1_parascriptural"), + parascript_id:int = Query(..., examples=100001), + resource_name: str = Path(...,examples="en_KJV_1_parascriptural"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Parascriptural * unique parascript Id with source name can be used to delete an exisiting identity''' @@ -1054,15 +1054,15 @@ async def delete_parascripturals(request: Request, @get_auth_access_check_decorator async def get_audio_bibles(request: Request, #pylint: disable=too-many-locals resource_name:schemas.TableNamePattern= - Path(...,example="en_KJV_1_audiobible"), - name:str=Query(None,example="Audio Bible of Genesis"), - audio_format:str=Query(None, example="mp3"), + Path(...,examples="en_KJV_1_audiobible"), + name:str=Query(None,examples="Audio Bible of Genesis"), + audio_format:str=Query(None, examples="mp3"), reference: str = Query(None, - example='{"book": "gen", "chapter": 1, "verseNumber": 6}'), - link:AnyUrl=Query(None,example="http://someplace.com/resoucesid"), - search_word:str=Query(None,example="subtitle"), + examples='{"book": "gen", "chapter": 1, "verseNumber": 6}'), + link:AnyUrl=Query(None,examples="http://someplace.com/resoucesid"), + search_word:str=Query(None,examples="subtitle"), metadata: schemas.MetaDataPattern=Query(None, - example='{"otherName": "Creation"}'), + examples='{"otherName": "Creation"}'), active: bool=Query(True), skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): @@ -1096,7 +1096,7 @@ async def get_audio_bibles(request: Request, #pylint: disable=too-many-locals @get_auth_access_check_decorator async def add_audio_bibles(request: Request, resource_name : schemas.TableNamePattern=Path(..., - example="en_KJV_1_audiobible"), + examples="en_KJV_1_audiobible"), audiobibles: List[schema_content.AudioBibleCreate] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1116,7 +1116,7 @@ async def add_audio_bibles(request: Request, @get_auth_access_check_decorator async def edit_audio_bibles(request: Request, resource_name: schemas.TableNamePattern=Path(..., - example="en_KJV_1_audiobible"), + examples="en_KJV_1_audiobible"), audiobibles: List[schema_content.AudioBibleEdit] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1136,8 +1136,8 @@ async def edit_audio_bibles(request: Request, status_code=200,tags=["Audio Bibles"]) @get_auth_access_check_decorator async def delete_audio_bibles(request: Request, - audio_id:int = Query(..., example=100001), - resource_name: str = Path(...,example="en_KJV_1_audiobible"), + audio_id:int = Query(..., examples=100001), + resource_name: str = Path(...,examples="en_KJV_1_audiobible"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Audio Bible * unique audioId with source name can be used to delete an exisiting identity''' @@ -1166,15 +1166,15 @@ async def delete_audio_bibles(request: Request, @get_auth_access_check_decorator async def get_sign_bible_videos(request: Request, #pylint: disable=too-many-locals resource_name:schemas.TableNamePattern= - Path(...,example="ins_KJV_1_signbiblevideo"), - title:str=Query(None,example="Sign Bible Video of Genesis"), - description:str=Query(None, example="Origin Chronicles"), + Path(...,examples="ins_KJV_1_signbiblevideo"), + title:str=Query(None,examples="Sign Bible Video of Genesis"), + description:str=Query(None, examples="Origin Chronicles"), reference: str = Query(None, - example='{"book": "gen", "chapter": 1, "verseNumber": 6}'), - link:AnyUrl=Query(None,example="http://someplace.com/resoucesid"), - search_word:str=Query(None,example="subtitle"), + examples='{"book": "gen", "chapter": 1, "verseNumber": 6}'), + link:AnyUrl=Query(None,examples="http://someplace.com/resoucesid"), + search_word:str=Query(None,examples="subtitle"), metadata: schemas.MetaDataPattern=Query(None, - example='{"otherName": "ISL, Indian Sign Language Videos"}'), + examples='{"otherName": "ISL, Indian Sign Language Videos"}'), active: bool=Query(True), skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_: Session=Depends(get_db)): @@ -1208,7 +1208,7 @@ async def get_sign_bible_videos(request: Request, #pylint: disable=too-many-loca @get_auth_access_check_decorator async def add_sign_bible_videos(request: Request, resource_name : schemas.TableNamePattern=Path(..., - example="ins_KJV_1_signbiblevideo"), + examples="ins_KJV_1_signbiblevideo"), signvideos: List[schema_content.SignVideoCreate] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1228,7 +1228,7 @@ async def add_sign_bible_videos(request: Request, @get_auth_access_check_decorator async def edit_sign_bible_videos(request: Request, resource_name: schemas.TableNamePattern=Path(..., - example="ins_KJV_1_signbiblevideo"), + examples="ins_KJV_1_signbiblevideo"), signvideos: List[schema_content.SignVideoEdit] = Body(...), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): @@ -1248,8 +1248,8 @@ async def edit_sign_bible_videos(request: Request, status_code=200,tags=["Sign Bible Videos"]) @get_auth_access_check_decorator async def delete_sign_bible_videos(request: Request, - signvideo_id:int = Query(..., example=100001), - resource_name: str = Path(...,example="ins_KJV_1_signbiblevideo"), + signvideo_id:int = Query(..., examples=100001), + resource_name: str = Path(...,examples="ins_KJV_1_signbiblevideo"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Delete Sign Bible Video * unique signvideoId with source name can be used to delete an exisiting identity''' @@ -1276,10 +1276,10 @@ async def delete_sign_bible_videos(request: Request, status_code=200, tags=["Resources"]) @get_auth_access_check_decorator async def extract_text_contents(request:Request, #pylint: disable=W0613 - resource_name:schemas.TableNamePattern=Query(None,example="en_TBP_1_bible"), - books:List[schemas.BookCodePattern]=Query(None,example='GEN'), - language_code:schemas.LangCodePattern=Query(None, example="hi"), - resource_type:str=Query(None, example="commentary"), + resource_name:schemas.TableNamePattern=Query(None,examples="en_TBP_1_bible"), + books:List[schemas.BookCodePattern]=Query(None,examples='GEN'), + language_code:schemas.LangCodePattern=Query(None, examples="hi"), + resource_type:str=Query(None, examples="commentary"), skip: int = Query(0, ge=0), limit: int = Query(100, ge=0), user_details = Depends(get_user_or_none), db_: Session = Depends(get_db), operates_on=Depends(AddHiddenInput(value=schema_auth.ResourceType.RESEARCH.value))): diff --git a/app/routers/filehandling_apis.py b/app/routers/filehandling_apis.py index 17c7d9b4..cf1bd1c2 100644 --- a/app/routers/filehandling_apis.py +++ b/app/routers/filehandling_apis.py @@ -21,12 +21,12 @@ status_code=200, tags=['File Handling', 'Bibles']) @get_auth_access_check_decorator async def usfm_parse_resource_bible(request: Request, - resource_name: schemas.TableNamePattern = Path(..., example="hi_IRV_1_bible"), - book_code: schemas.BookCodePattern=Path(..., example="mat"), - output_format: usfm_grammar.Format = Path(..., example="usx"), + resource_name: schemas.TableNamePattern = Path(..., examples="hi_IRV_1_bible"), + book_code: schemas.BookCodePattern=Path(..., examples="mat"), + output_format: usfm_grammar.Format = Path(..., examples="usx"), content_filter: usfm_grammar.Filter = Query(usfm_grammar.Filter.SCRIPTURE_PARAGRAPHS), - chapter: int=Query(None, example=1), - # verse: int=Query(None, example=1), last_verse: int=Query(None, example=15), + chapter: int=Query(None, examples=1), + # verse: int=Query(None, examples=1), last_verse: int=Query(None, examples=15), active: bool=True, # skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details = Depends(get_user_or_none), @@ -58,11 +58,11 @@ async def usfm_parse_resource_bible(request: Request, status_code=200, tags=['File Handling']) @get_auth_access_check_decorator async def parse_uploaded_usfm(request:Request, - output_format: usfm_grammar.Format = Path(..., example="usx"), + output_format: usfm_grammar.Format = Path(..., examples="usx"), content_filter: usfm_grammar.Filter = Query(usfm_grammar.Filter.SCRIPTURE_PARAGRAPHS), input_usfm: schema_content.UploadedUsfm = Body(...), - chapter: int=Query(None, example=1), - # verse: int=Query(None, example=1), last_verse: int=Query(None, example=15), + chapter: int=Query(None, examples=1), + # verse: int=Query(None, examples=1), last_verse: int=Query(None, examples=15), user_details=Depends(get_user_or_none)): '''Allows to upload a USFM file to be converted to another format. uses usfm-grammar''' log.info("In parse_uploaded_usfm router function") diff --git a/app/routers/media_api.py b/app/routers/media_api.py index 1a2d5ef7..ab677638 100644 --- a/app/routers/media_api.py +++ b/app/routers/media_api.py @@ -70,10 +70,10 @@ async def get_and_accesscheck_for_repo(repo, file_path, tag, permanent_link, db_ @get_auth_access_check_decorator async def stream_media(request: Request, #pylint: disable=unused-argument,too-many-arguments access_token: str = Query(None), - repo: str = Query(None,example="kavitha.raju/trial-media-project"), - tag: str = Query(None,example="main"), - file_path: str=Query(None,example="token videos/Apostle.MOV"), - permanent_link: str=Query(None,example= + repo: str = Query(None,examples="kavitha.raju/trial-media-project"), + tag: str = Query(None,examples="main"), + file_path: str=Query(None,examples="token videos/Apostle.MOV"), + permanent_link: str=Query(None,examples= "https://gitlab.bridgeconn.com/kavitha.raju/"+ "trial-media-project/-/raw/main/token videos/Apostle.MOV"), start_time: Optional[datetime] =Query(None), @@ -110,10 +110,10 @@ async def stream_media(request: Request, #pylint: disable=unused-argument,too-ma @get_auth_access_check_decorator async def download_media(request: Request, #pylint: disable=too-many-arguments access_token: str = Query(None), - repo: str = Query(None,example="kavitha.raju/trial-media-project"), - tag: str = Query(None,example="main"), - file_path: str=Query(None,example="token videos/Apostle.MOV"), - permanent_link: str=Query(None,example= + repo: str = Query(None,examples="kavitha.raju/trial-media-project"), + tag: str = Query(None,examples="main"), + file_path: str=Query(None,examples="token videos/Apostle.MOV"), + permanent_link: str=Query(None,examples= "https://gitlab.bridgeconn.com/kavitha.raju/"+ "trial-media-project/-/raw/main/token videos/Apostle.MOV"), db_: Session = Depends(get_db)): diff --git a/app/routers/translation_apis.py b/app/routers/translation_apis.py index 18403019..f51bd2ff 100644 --- a/app/routers/translation_apis.py +++ b/app/routers/translation_apis.py @@ -22,11 +22,11 @@ status_code=200, tags=['Translation-Project management']) @get_auth_access_check_decorator async def get_projects(request: Request, - project_name:str=Query(None,example="Hindi-Bilaspuri Gospels"), - source_language:schemas.LangCodePattern=Query(None,example='en'), - target_language:schemas.LangCodePattern=Query(None,example='ml'), + project_name:str=Query(None,examples="Hindi-Bilaspuri Gospels"), + source_language:schemas.LangCodePattern=Query(None,examples='en'), + target_language:schemas.LangCodePattern=Query(None,examples='ml'), active:bool=True, user_id:str=Query(None), - compatible_with: List[schema_auth.App] = Query(None,example=["Autographa","SanketMAST"]), + compatible_with: List[schema_auth.App] = Query(None,examples=["Autographa","SanketMAST"]), skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db), filtering_required=Depends(AddHiddenInput(value=True))): @@ -67,7 +67,7 @@ async def create_project(request: Request, @get_auth_access_check_decorator @check_app_compatibility_decorator async def update_project(request: Request, project_obj:schemas_nlp.TranslationProjectEdit, - project_id:int=Query(...,example="1022004"), user_details =Depends(get_user_or_none), + project_id:int=Query(...,examples="1022004"), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db), operates_on=Depends(AddHiddenInput(value=schema_auth.ResourceType.PROJECT.value))): # operates_on=schema_auth.ResourceType.PROJECT.value): @@ -115,7 +115,7 @@ async def update_project(request: Request, project_obj:schemas_nlp.TranslationPr @get_auth_access_check_decorator @check_app_compatibility_decorator async def remove_project(request: Request, - project_id:int = Query(..., example=100001), + project_id:int = Query(..., examples=100001), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Removes a project.''' log.info('In remove_project') @@ -151,7 +151,7 @@ async def add_user(request: Request,project_id:int, user_id:str, @get_auth_access_check_decorator @check_app_compatibility_decorator async def update_user(request: Request,user_obj:schemas_nlp.ProjectUser, - project_id:int=Query(...,example="1022004"), + project_id:int=Query(...,examples="1022004"), user_details =Depends(get_user_or_none),db_:Session=Depends(get_db)): '''Changes role, metadata or active status of user of a project.''' log.info('In update_user') @@ -189,10 +189,10 @@ async def remove_user(request: Request,project_id:int, user_id:str, status_code=200, tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_tokens(request: Request, project_id:int=Query(...,example="1022004"), - books:List[schemas.BookCodePattern]=Query(None,example=["mat", "mrk"]), - sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,example=(410010001, 41001999)), - sentence_id_list:List[int]=Query(None, example=[41001001,41001002,41001003]), +async def get_tokens(request: Request, project_id:int=Query(...,examples="1022004"), + books:List[schemas.BookCodePattern]=Query(None,examples=["mat", "mrk"]), + sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,examples=(410010001, 41001999)), + sentence_id_list:List[int]=Query(None, examples=[41001001,41001002,41001003]), use_translation_memory:bool=True, include_phrases:bool=True, include_stopwords:bool=False, user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Tokenize the source texts. Optional params books, @@ -218,7 +218,7 @@ async def get_tokens(request: Request, project_id:int=Query(...,example="1022004 status_code=201, tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def apply_token_translations(request: Request,project_id:int=Query(...,example="1022004"), +async def apply_token_translations(request: Request,project_id:int=Query(...,examples="1022004"), token_translations:List[schemas_nlp.TokenUpdate]=Body(...), return_drafts:bool=True, user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Updates drafts using the provided token translations and returns updated verses''' @@ -236,10 +236,10 @@ async def apply_token_translations(request: Request,project_id:int=Query(...,exa tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_token_translation(request: Request,project_id:int=Query(...,example="1022004"), - token:str=Query(...,example="duck"), - sentence_id:int=Query(..., example="41001001"), - offset:List[int]=Query(..., max_items=2,min_items=2,example=[0,4]), +async def get_token_translation(request: Request,project_id:int=Query(...,examples="1022004"), + token:str=Query(...,examples="duck"), + sentence_id:int=Query(..., examples="41001001"), + offset:List[int]=Query(..., max_items=2,min_items=2,examples=[0,4]), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Get the current translation for specific tokens providing their occurence in source''' log.info('In get_token_translation') @@ -255,9 +255,9 @@ async def get_token_translation(request: Request,project_id:int=Query(...,exampl tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_token_sentences(request: Request,project_id:int=Query(...,example="1022004"), - token:str=Query(...,example="duck"), - occurrences:List[schemas_nlp.TokenOccurence]=Body(..., example=[ +async def get_token_sentences(request: Request,project_id:int=Query(...,examples="1022004"), + token:str=Query(...,examples="duck"), + occurrences:List[schemas_nlp.TokenOccurence]=Body(..., examples=[ {"sentenceId":41001001, "offset":[0,4]}]), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Pass in the occurence list of a token and get all sentences it is present in with draftMeta @@ -273,10 +273,10 @@ async def get_token_sentences(request: Request,project_id:int=Query(...,example= tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_draft(request: Request,project_id:int=Query(...,example="1022004"), - books:List[schemas.BookCodePattern]=Query(None,example=["mat", "mrk"]), - sentence_id_list:List[int]=Query(None,example=[41001001,41001002,41001003]), - sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,example=[41001001,41001999]), +async def get_draft(request: Request,project_id:int=Query(...,examples="1022004"), + books:List[schemas.BookCodePattern]=Query(None,examples=["mat", "mrk"]), + sentence_id_list:List[int]=Query(None,examples=[41001001,41001002,41001003]), + sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,examples=[41001001,41001999]), output_format:schemas_nlp.DraftFormats=Query(schemas_nlp.DraftFormats.USFM), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Obtains draft, as per current project status, in any of the formats: @@ -296,7 +296,7 @@ async def get_draft(request: Request,project_id:int=Query(...,example="1022004") tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def update_draft(request: Request,project_id:int=Query(...,example="1022004"), +async def update_draft(request: Request,project_id:int=Query(...,examples="1022004"), sentence_list:List[schemas_nlp.ProjectDraftInput]=Body(...), user_details =Depends(get_user_or_none),db_:Session=Depends(get_db)): '''Obtains draft, as per current project status, in any of the formats: @@ -315,10 +315,10 @@ async def update_draft(request: Request,project_id:int=Query(...,example="102200 tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_project_source(request: Request,project_id:int=Query(...,example="1022004"), - books:List[schemas.BookCodePattern]=Query(None,example=["mat", "mrk"]), - sentence_id_list:List[int]=Query(None,example=[41001001,41001002,41001003]), - sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,example=[41001001,41001999]), +async def get_project_source(request: Request,project_id:int=Query(...,examples="1022004"), + books:List[schemas.BookCodePattern]=Query(None,examples=["mat", "mrk"]), + sentence_id_list:List[int]=Query(None,examples=[41001001,41001002,41001003]), + sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,examples=[41001001,41001999]), with_draft:bool=False, only_ids:bool=False, user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Obtains source sentences or verses, as per the filters''' @@ -337,8 +337,8 @@ async def get_project_source(request: Request,project_id:int=Query(...,example=" tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def remove_sentence(request: Request,project_id:int=Query(...,example="1022004"), - sentence_id:int=Query(...,example="41001001"), +async def remove_sentence(request: Request,project_id:int=Query(...,examples="1022004"), + sentence_id:int=Query(...,examples="41001001"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Remove sentence.''' log.info('In remove_sentence') @@ -358,10 +358,10 @@ async def remove_sentence(request: Request,project_id:int=Query(...,example="102 tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_progress(request: Request,project_id:int=Query(...,example="1022004"), - books:List[schemas.BookCodePattern]=Query(None,example=["mat", "mrk"]), - sentence_id_list:List[int]=Query(None,example=[41001001,41001002,41001003]), - sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,example=[41001001,41001999]), +async def get_progress(request: Request,project_id:int=Query(...,examples="1022004"), + books:List[schemas.BookCodePattern]=Query(None,examples=["mat", "mrk"]), + sentence_id_list:List[int]=Query(None,examples=[41001001,41001002,41001003]), + sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,examples=[41001001,41001999]), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Obtains source sentences or verses, as per the filters''' log.info('In get_progress') @@ -378,7 +378,7 @@ async def get_progress(request: Request,project_id:int=Query(...,example="102200 tags=['Project-Based-Translation']) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def get_project_versification(request: Request,project_id:int=Query(...,example="1022004"), +async def get_project_versification(request: Request,project_id:int=Query(...,examples="1022004"), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Obtains versification structure for source sentences or verses''' log.info('In get_project_versification') @@ -393,10 +393,10 @@ async def get_project_versification(request: Request,project_id:int=Query(...,ex tags=["Translation Suggestion"]) @get_auth_access_check_decorator @check_app_compatibility_decorator -async def suggest_auto_translation(request: Request,project_id:int=Query(...,example="1022004"), - books:List[schemas.BookCodePattern]=Query(None,example=["mat", "mrk"]), - sentence_id_list:List[int]=Query(None,example=[41001001,41001002,41001003]), - sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,example=[41001001,41001999]), +async def suggest_auto_translation(request: Request,project_id:int=Query(...,examples="1022004"), + books:List[schemas.BookCodePattern]=Query(None,examples=["mat", "mrk"]), + sentence_id_list:List[int]=Query(None,examples=[41001001,41001002,41001003]), + sentence_id_range:List[int]=Query(None,max_items=2,min_items=2,examples=[41001001,41001999]), confirm_all:bool=False,user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Try to fill draft with suggestions. If confirm_all is set, will only change status of all "suggestion" to "confirmed" in the selected sentences and will not fill in new suggestion''' @@ -416,9 +416,9 @@ async def suggest_auto_translation(request: Request,project_id:int=Query(...,exa tags=['Generic Translation']) @get_auth_access_check_decorator async def tokenize(request: Request, - source_language:schemas.LangCodePattern=Query(...,example="hi"), + source_language:schemas.LangCodePattern=Query(...,examples="hi"), sentence_list:List[schemas_nlp.SentenceInput]=Body(...), - target_language:schemas.LangCodePattern=Query(None,example="ml"), + target_language:schemas.LangCodePattern=Query(None,examples="ml"), use_translation_memory:bool=True, include_phrases:bool=True, include_stopwords:bool=False, punctuations:List[str]=Body(None), stopwords:schemas_nlp.Stopwords=Body(None), user_details =Depends(get_user_or_none),db_:Session=Depends(get_db)): @@ -446,8 +446,8 @@ async def tokenize(request: Request, @get_auth_access_check_decorator async def token_replace(request: Request,sentence_list:List[schemas_nlp.DraftInput]=Body(...), token_translations:List[schemas_nlp.TokenUpdate]=Body(...), - source_language:schemas.LangCodePattern=Query(...,example='hi'), - target_language:schemas.LangCodePattern=Query(...,example='ml'), + source_language:schemas.LangCodePattern=Query(...,examples='hi'), + target_language:schemas.LangCodePattern=Query(...,examples='ml'), use_data_for_learning:bool=True, user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Perform token replacement on provided sentences and @@ -485,8 +485,8 @@ async def generate_draft(request: Request,sentence_list:List[schemas_nlp.DraftIn tags=["Translation Suggestion"]) @get_auth_access_check_decorator async def suggest_translation(request: Request, - source_language:schemas.LangCodePattern=Query(...,example="hi"), - target_language:schemas.LangCodePattern=Query(...,example="ml"), + source_language:schemas.LangCodePattern=Query(...,examples="hi"), + target_language:schemas.LangCodePattern=Query(...,examples="ml"), sentence_list:List[schemas_nlp.DraftInput]=Body(...), punctuations:List[str]=Body(None), stopwords:schemas_nlp.Stopwords=Body(None), user_details =Depends(get_user_or_none),db_:Session=Depends(get_db)): @@ -508,11 +508,11 @@ async def suggest_translation(request: Request, tags=["Nlp"]) @get_auth_access_check_decorator async def get_glossary(request: Request, - source_language:schemas.LangCodePattern=Query(...,example="en"), - target_language:schemas.LangCodePattern=Query(...,example="hi"), - token:str=Query(...,example="duck"), - context:str=Query(None,example="The duck swam in the lake"), - token_offset:List[int]=Query(None,max_items=2,min_items=2,example=(4,8)), + source_language:schemas.LangCodePattern=Query(...,examples="en"), + target_language:schemas.LangCodePattern=Query(...,examples="hi"), + token:str=Query(...,examples="duck"), + context:str=Query(None,examples="The duck swam in the lake"), + token_offset:List[int]=Query(None,max_items=2,min_items=2,examples=(4,8)), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Finds translation suggestions or gloss for one token in the given context''' log.info('In get_glossary') @@ -528,9 +528,9 @@ async def get_glossary(request: Request, tags=["Nlp"]) @get_auth_access_check_decorator async def get_glossary_entries(request: Request, - source_language:schemas.LangCodePattern=Query(...,example="en"), - target_language:schemas.LangCodePattern=Query(...,example="hi"), - token:str=Query(None,example="duck"), + source_language:schemas.LangCodePattern=Query(...,examples="en"), + target_language:schemas.LangCodePattern=Query(...,examples="hi"), + token:str=Query(None,examples="duck"), skip: int=Query(None, ge=0), limit: int=Query(None, ge=0), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Searches the translation memory for matching entries. Not context aware''' @@ -548,9 +548,9 @@ async def get_glossary_entries(request: Request, 404:{"model": schemas.ErrorResponse},}, status_code=200, tags=["Nlp"]) @get_auth_access_check_decorator async def get_gloss_count(request: Request, - source_language:schemas.LangCodePattern=Query(...,example="en"), - target_language:schemas.LangCodePattern=Query(...,example="hi"), - token:str=Query(None,example="love"), + source_language:schemas.LangCodePattern=Query(...,examples="en"), + target_language:schemas.LangCodePattern=Query(...,examples="hi"), + token:str=Query(None,examples="love"), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Counts all glossary entries in translation memory between two languages. * Also counts unique tokens in translation memory @@ -575,8 +575,8 @@ async def get_gloss_count(request: Request, tags=["Nlp"]) @get_auth_access_check_decorator async def add_gloss(request: Request, - source_language:schemas.LangCodePattern=Query(...,example='en'), - target_language:schemas.LangCodePattern=Query(..., example="hi"), + source_language:schemas.LangCodePattern=Query(...,examples='en'), + target_language:schemas.LangCodePattern=Query(..., examples="hi"), token_translations:List[schemas_nlp.GlossInput]=Body(...), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Load a list of predefined tokens and translations to improve tokenization and suggestion''' @@ -608,10 +608,10 @@ async def update_glossary(request: Request, tags=['Nlp']) @get_auth_access_check_decorator async def remove_glossary(request: Request, - source_lang:schemas.LangCodePattern=Query(...,example="en"), - target_lang:schemas.LangCodePattern=Query(...,example="hi"), - token:str=Query(...,example="duck"), - translation:str=Query(None,example="बत्तख"), + source_lang:schemas.LangCodePattern=Query(...,examples="en"), + target_lang:schemas.LangCodePattern=Query(...,examples="hi"), + token:str=Query(...,examples="duck"), + translation:str=Query(None,examples="बत्तख"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Remove glossary.''' log.info('In remove_gloss') @@ -648,7 +648,7 @@ async def add_alignments(request: Request, tags=["Lookups"]) @get_auth_access_check_decorator async def get_stop_words(request: Request, - language_code:schemas.LangCodePattern=Path(...,example="hi"), + language_code:schemas.LangCodePattern=Path(...,examples="hi"), include_system_defined:bool=True, include_user_defined:bool=True, include_auto_generated :bool=True, only_active:bool=True, skip: int=Query(0, ge=0), limit: int=Query(100, ge=0), @@ -671,7 +671,7 @@ async def get_stop_words(request: Request, tags=['Lookups']) @get_auth_access_check_decorator async def update_stop_words(request: Request, - language_code:schemas.LangCodePattern=Path(...,example="hi"), + language_code:schemas.LangCodePattern=Path(...,examples="hi"), sw_info:schemas_nlp.StopWordUpdate=Body(...), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Api to update fields of a stopword in lookup table''' @@ -688,8 +688,8 @@ async def update_stop_words(request: Request, tags=['Lookups']) @get_auth_access_check_decorator async def add_stopwords(request: Request, - language_code:schemas.LangCodePattern=Path(...,example="hi"), - stopwords_list:List[str]=Body(..., example=["और", "के", "उसका"]), + language_code:schemas.LangCodePattern=Path(...,examples="hi"), + stopwords_list:List[str]=Body(..., examples=["और", "के", "उसका"]), user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Insert provided stopwords into db and returns added data''' log.info('In add_stopwords') @@ -707,8 +707,8 @@ async def add_stopwords(request: Request, tags=['Lookups']) @get_auth_access_check_decorator async def remove_stopword(request: Request, - lang:schemas.LangCodePattern=Query(...,example="en"), - stopword:str=Query(...,example="as"), + lang:schemas.LangCodePattern=Query(...,examples="en"), + stopword:str=Query(...,examples="as"), user_details =Depends(get_user_or_none), db_: Session = Depends(get_db)): '''Api to remove stopwords from lookup table''' log.info('In remove_stopword') @@ -726,9 +726,9 @@ async def remove_stopword(request: Request, tags=['Nlp']) @get_auth_access_check_decorator async def generate_stopwords(request: Request, background_tasks: BackgroundTasks, - language_code:schemas.LangCodePattern=Query(...,example="bi"), + language_code:schemas.LangCodePattern=Query(...,examples="bi"), use_server_data:bool=True, - source_name: schemas.TableNamePattern=Query(None,example="en_TW_1_vocabulary"), + source_name: schemas.TableNamePattern=Query(None,examples="en_TW_1_vocabulary"), user_details =Depends(get_user_or_none), sentence_list:List[schemas_nlp.SentenceInput]=Body(None), db_:Session=Depends(get_db), operates_on=Depends(AddHiddenInput(value=schema_auth.ResourceType.LOOKUP.value))):#pylint: disable=unused-argument @@ -769,7 +769,7 @@ async def generate_stopwords(request: Request, background_tasks: BackgroundTasks tags=['Jobs']) @get_auth_access_check_decorator async def check_job_status(request: Request, - job_id:int=Query(...,example="100000"),user_details =Depends(get_user_or_none), + job_id:int=Query(...,examples="100000"),user_details =Depends(get_user_or_none), db_:Session=Depends(get_db)): '''Checking the status of a job''' log.info('In check_job_status') diff --git a/requirements.txt b/requirements.txt index f7278ee0..2bf1ca13 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,10 @@ SQLAlchemy==1.4.41 python-gitlab==3.9.0 -fastapi[all]==0.95.0 +fastapi==0.101.1 +pydantic==1.10.11 +httpx==0.24.1 +python-multipart==0.0.6 +Jinja2==3.1.2 pygtrie==2.5.0 nltk==3.7 numpy==1.23.3 @@ -10,7 +14,7 @@ pytest==7.1.3 psycopg2==2.9.3 Unidecode==1.3.4 beautifulsoup4==4.11.1 -starlette==0.26.1 +starlette==0.27.0 pylint==2.16.1 jsonpickle==2.2.0 usfm-grammar==3.0.0a4 From fc29d98423ddd7c731cf746967f0798db279c75b Mon Sep 17 00:00:00 2001 From: joel-joseph-george Date: Thu, 24 Aug 2023 14:05:51 +0530 Subject: [PATCH 2/4] FAST API:changes in packages --- requirements.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/requirements.txt b/requirements.txt index 2bf1ca13..b56bc9fa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,23 @@ pydantic==1.10.11 httpx==0.24.1 python-multipart==0.0.6 Jinja2==3.1.2 +uvicorn==0.23.2 + +#fast-api (all) packages +# email-validator==2.0.0.post2 +# ujson==5.8.0 +# orjson==3.9.5 +# itsdangerous==2.1.2 +# PyYAML==6.0.1 + +# uvloop==0.17.0 +# watchfiles==0.19.0 +# websockets==11.0.3 +# httptools==0.6.0 +# dnspython==2.4.2 +# python-dotenv==1.0.0 + + pygtrie==2.5.0 nltk==3.7 numpy==1.23.3 From 98ec5b02403149724c47e8bdc8edfb8950aebdba Mon Sep 17 00:00:00 2001 From: joel-joseph-george Date: Fri, 25 Aug 2023 12:01:25 +0530 Subject: [PATCH 3/4] FAST API: Text changes --- requirements.txt | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index b56bc9fa..3829a51c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,22 +6,6 @@ httpx==0.24.1 python-multipart==0.0.6 Jinja2==3.1.2 uvicorn==0.23.2 - -#fast-api (all) packages -# email-validator==2.0.0.post2 -# ujson==5.8.0 -# orjson==3.9.5 -# itsdangerous==2.1.2 -# PyYAML==6.0.1 - -# uvloop==0.17.0 -# watchfiles==0.19.0 -# websockets==11.0.3 -# httptools==0.6.0 -# dnspython==2.4.2 -# python-dotenv==1.0.0 - - pygtrie==2.5.0 nltk==3.7 numpy==1.23.3 From c2d68dabeab8628da1bf811a326a0647c1e928c6 Mon Sep 17 00:00:00 2001 From: joel-joseph-george Date: Fri, 8 Sep 2023 17:06:12 +0530 Subject: [PATCH 4/4] UPDATE: on landing page and Fast api upgradation --- app/templates/landing_page.html | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/app/templates/landing_page.html b/app/templates/landing_page.html index 8228b60b..9eee242a 100644 --- a/app/templates/landing_page.html +++ b/app/templates/landing_page.html @@ -9,6 +9,12 @@ API Documentation + + + + + + @@ -35,7 +41,8 @@ - + + @@ -73,27 +80,26 @@ + + + -