Skip to content

Commit

Permalink
Merge pull request Bridgeconn#747 from kavitharaju/separate-TBT-repo
Browse files Browse the repository at this point in the history
Separate Translation module
  • Loading branch information
kavitharaju authored Jan 2, 2024
2 parents 5a1887f + 744633a commit bf056e0
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 9,561 deletions.
21 changes: 11 additions & 10 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import db_models
from database import engine
from dependencies import get_db, log
from routers import content_apis, translation_apis, auth_api, media_api, filehandling_apis
from routers import content_apis, auth_api, media_api, filehandling_apis
from auth.authentication import create_super_user
# pylint: enable=E0401

Expand All @@ -28,9 +28,14 @@

create_super_user()

root_url = os.getenv("VACHAN_DOMAIN", 'http://localhost:8000')
if root_url is not None and not root_url.startswith("http://"):
root_url = "http://" + root_url

app = FastAPI(title="Vachan-API", version="2.0.0",
description="The server application that provides APIs to interact \
with the underlying Databases and modules in Vachan-Engine.")
description=f"The server application that provides APIs to interact \
with the underlying Databases and modules in Vachan-Engine. \
\n • For Vachan-TBT docs: {root_url}/v2/text/translate/token-based/docs")
template = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")

Expand Down Expand Up @@ -214,9 +219,6 @@ def test(request: Request,db_: Session = Depends(get_db)):
'''Tests if app is running and the DB connection is active
* Also displays API documentation page upon successful connection on root endpoint'''
db_.query(db_models.Language).first()
root_url = os.getenv("VACHAN_DOMAIN")
if root_url is not None and not root_url.startswith("http://"):
root_url = "http://" + root_url
return template.TemplateResponse(
"landing_page.html",
{
Expand All @@ -227,15 +229,13 @@ def test(request: Request,db_: Session = Depends(get_db)):

app.include_router(auth_api.router)
app.include_router(content_apis.router)
app.include_router(translation_apis.router)
app.include_router(media_api.router)
app.include_router(filehandling_apis.router)

beta_endpoints = [
"/graphql", # Specify the paths of the beta endpoints
"/v2/resources/bibles/{resource_name}/versification",
"/v2/resources/bibles/{resource_name}/books/{book_code}/export/{output_format}",
"/v2/text/translate/token-based/project/versification",
"/v2/media/gitlab/stream",
"/v2/media/gitlab/download",
"/v2/files/usfm/to/{output_format}"
Expand All @@ -244,8 +244,9 @@ def test(request: Request,db_: Session = Depends(get_db)):
def custom_openapi():
'''Modify the auto generated openapi schema for API docs'''
openapi_schema = get_openapi(title="Vachan-API", version="2.0.0",
description="The server application that provides APIs to interact \
with the underlying Databases and modules in Vachan-Engine.",
description=f"The server application that provides APIs to interact \
with the underlying Databases and modules in Vachan-Engine. \
<br> • <a href=\"{root_url}/v2/text/translate/token-based/docs\" > Vachan-TBT docs </a>",
routes=app.routes)

# Add version information to specific endpoints
Expand Down
15 changes: 15 additions & 0 deletions app/routers/content_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,18 @@ async def delete_deleteditems(request: Request,user_details =Depends(get_user_or
log.info('In delete_deleteditems')
deleted_item_count = structurals_crud.cleanup_database(db_=db_)
return {'message': "Database cleanup done!!",'deletedItemCount':deleted_item_count}

@router.get('/v2/jobs', response_model=schemas_nlp.JobStatusResponse,
response_model_exclude_none=True, status_code=200,
responses={502: {"model": schemas.ErrorResponse},
422: {"model": schemas.ErrorResponse},404:{"model": schemas.ErrorResponse}},
tags=['Jobs'])
@get_auth_access_check_decorator
async def check_job_status(request: Request,
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')
log.debug('job_id:%s', job_id)
result = nlp_sw_crud.check_job_status(db_, job_id)
return result
778 changes: 0 additions & 778 deletions app/routers/translation_apis.py

This file was deleted.

Loading

0 comments on commit bf056e0

Please sign in to comment.