Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ $RECYCLE.BIN/

# Logs
**/logs/*


backend/dataset/admin.py

backend/projects/views.py

backend/shoonya_backend/settings.py
2 changes: 1 addition & 1 deletion backend/dataset/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import resource
# import resource
from django.contrib import admin
from import_export.admin import ImportExportActionModelAdmin
from .resources import *
Expand Down
3 changes: 3 additions & 0 deletions backend/deploy/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,6 @@ xmljson==0.2.0
zipp==3.15.0
flower==2.0.1
pydub==0.25.1
ffmpeg
locust==2.15.1
auth
89 changes: 89 additions & 0 deletions backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4103,6 +4103,95 @@ def types(self, request, *args, **kwargs):
def get_task_queryset(self, queryset):
return queryset


# from here translitrartion work starts
# For Text
# @action(detail=False, methods=["POST", "GET"], name="Populate asr model predictions")
# @is_org_owner
# def populate_asr_model_predictions(self, request , pk):
# try:
# data = json.loads(request.body)
# model_language = data.get("model_language")
# project_ids = [pk]
# stage = data.get("stage", "l1") # Default to "l1"

# # Ensure the stage is either "l1" or "l2"
# if stage not in ["l1", "l2"]:
# return JsonResponse({"error": "Invalid stage. Choose either 'l1' or 'l2'."}, status=400)

# if not model_language:
# return JsonResponse({"error": "Missing model_language"}, status=400)

# # Run the Celery task asynchronously
# populate_asr_try(model_language, project_ids, stage)
# return JsonResponse({"message": f"populate_asr_try started successfully for stage {stage}!"})
# except json.JSONDecodeError:
# return JsonResponse({"error": "Invalid JSON format"}, status=400)
# except Exception as e:
# return JsonResponse({"error": str(e)}, status=500)


@action(detail=False, methods=["POST"], name="Populate ASR model predictions")
# @is_org_owner
def populate_asr_model_predictions(self, request, pk=None):
try:
model_language = request.data.get("model_language")
stage = request.data.get("stage", "l1") # Default to "l1"
project_ids = [int(pk)]

# Validate stage
if stage not in ["l1", "l2"]:
return Response(
{"error": "Invalid stage. Choose either 'l1' or 'l2'."},
status=status.HTTP_400_BAD_REQUEST
)

# Validate language
if not model_language:
return Response(
{"error": "Missing model_language"},
status=status.HTTP_400_BAD_REQUEST
)

# Trigger Celery task
populate_asr_try.delay(model_language, project_ids, stage)

return Response(
{"message": f"populate_asr_try started successfully for stage '{stage}'."},
status=status.HTTP_202_ACCEPTED
)

except Exception as e:
return Response({"error": str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

# For Youtube
@action(detail=False, methods=["POST", "GET"], name="Populate asr model predictions yt")
@is_org_owner
def populate_asr_model_predictions_yt(self, request , pk):
try:
data = json.loads(request.body)
model_language = data.get("model_language")
project_ids =[pk]
stage = data.get("stage", "l1")

# Ensure the stage is either "l1" or "l2"
if stage not in ["l1", "l2"]:
return JsonResponse({"error": "Invalid stage. Choose either 'l1' or 'l2'."}, status=400)

if not model_language:
return JsonResponse({"error": "Missing model_language"}, status=400)

# Run the Celery task asynchronously
populate_asr_yt(model_language, project_ids, stage)

return Response({"message": "populate_asr_yt started successfully!"})
except json.JSONDecodeError:
return Response({"error": "Invalid JSON format"}, status=400)
except Exception as e:
ret_dict = {"message": "Project does not exist!"}
ret_status = status.HTTP_404_NOT_FOUND
return Response(ret_dict, status=ret_status)
# Here translitrartion work ends
@action(detail=True, methods=["POST", "GET"], name="Pull new items")
@project_is_archived
@is_org_owner
Expand Down
2 changes: 2 additions & 0 deletions backend/shoonya_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
ALLOWED_HOSTS = ["127.0.0.1", "localhost", "0.0.0.0", "*"]
else:
ALLOWED_HOSTS = [
'127.0.0.1',
"localhost",
"shoonya.ai4bharat.org",
"0.0.0.0",
"backend.shoonya.ai4bharat.org",
Expand Down
15 changes: 15 additions & 0 deletions load_tests/Pro_setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Pro_setting:

def __init__(self, client, token):
self.client = client
self.token = token


def get_pro(self):
"""
Simulates a GET request to the /workspaces/ endpoint to fetch workspace details.
"""
self.client.get(
"/projects/projects_list/optimized/?",
headers={"Authorization": f"JWT {self.token}"},
)
Empty file added load_tests/admin.py
Empty file.
106 changes: 106 additions & 0 deletions load_tests/admin_tab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
class AdminAPIs:
def __init__(self, client, token):
self.client = client
self.token = token
def get_User_details(self):
"""
Simulates a GET request to the /users/account/user_details/ endpoint to fetch get_User_details.
"""
self.client.get(
"/users/account/user_details/",
headers={"Authorization": f"JWT {self.token}"},
)


# below one iss not working as some json responce 500 error is coming
def get_queued_Tasks(self):
"""
Simulates a GET request to the /tasks/get_celery_tasks/ endpoint to fetch get_queued_Tasks details.
"""
self.client.get(
"/tasks/get_celery_tasks/",
headers={"Authorization": f"JWT {self.token}"},
)

# get Tasks details

def get_tasks_annotations(self):
"""
Simulates a GET request to the /task/3803927/annotations/ endpoint to fetch get_tasks details.
"""
Id = 3803927
self.client.get(
f"/task/{Id}/annotations/",
headers={"Authorization": f"JWT {self.token}"},
)

def get_task_details(self):
"""
Simulates a GET request to the /task/3803927/ endpoint to fetch get_task_details.
"""
Id = 3803927
with self.client.get(
f"/task/{Id}/",
headers={"Authorization": f"JWT {self.token}"},
catch_response=True
) as response:
print(f"Status Code: {response.status_code}")

if response.status_code in (200, 201):
response.success()
else:
response.failure(f"Failed to get task details: {response.status_code}")

# get task annotations details:
def get_task_annotations(self):
"""
Simulates a GET request to the annotation/{Id} endpoint to fetch get_task_annotations details.
"""
Id = 2874181
with self.client.get(
f"/annotation/{Id}/",
headers={"Authorization": f"JWT {self.token}"},
catch_response=True
) as response:
print(f"Status Code: {response.status_code}")

if response.status_code in (200, 201):
response.success()
else:
response.failure(f"Failed to get task annotations: {response.status_code}")

# get Queued Tasks details:
def get_queued_tasks(self):
"""
Simulates a GET request to the /tasks/get_celery_tasks/ endpoint to fetch get_queued_tasks details.
"""
with self.client.get(
"/tasks/get_celery_tasks/",
headers={"Authorization": f"JWT {self.token}"},
catch_response=True
) as response:
print(f"Status Code: {response.status_code}")

if response.status_code in (200, 201):
response.success()
else:
response.failure(f"Failed to get queued tasks: {response.status_code}")

# get useer details:
def get_user_details(self):
"""
Simulates a GET request to the /users/account/user_details/ endpoint to fetch get_user_details.
"""
with self.client.get(
"/users/account/user_details/",
headers={"Authorization": f"JWT {self.token}"},
catch_response=True
) as response:
print(f"Status Code: {response.status_code}")

if response.status_code in (200, 201):
response.success()
else:
response.failure(f"Failed to get User Details: {response.status_code}")

# done
Loading
Loading