Skip to content

Commit

Permalink
Log warnings for UserError exceptions + handle UserError from GPU
Browse files Browse the repository at this point in the history
  • Loading branch information
devxpy committed Jul 29, 2024
1 parent 1eba458 commit 1b33914
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions celeryapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.db.models import Sum
from django.utils import timezone
from fastapi import HTTPException
from loguru import logger

from app_users.models import AppUser, AppUserTransaction
from bots.admin_links import change_obj_url
Expand Down Expand Up @@ -95,6 +96,7 @@ def save_on_step(yield_val: str | tuple[str, dict] = None, *, done: bool = False
except Exception as e:
if isinstance(e, UserError):
sentry_level = e.sentry_level
logger.warning(e)
else:
sentry_level = "error"
traceback.print_exc()
Expand Down
7 changes: 5 additions & 2 deletions daras_ai_v2/gpu_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from daras_ai.image_input import storage_blob_for
from daras_ai_v2 import settings
from daras_ai_v2.exceptions import GPUError
from daras_ai_v2.exceptions import GPUError, UserError
from gooeysite.bg_db_conn import get_celery_result_db_safe


Expand Down Expand Up @@ -94,7 +94,10 @@ def call_celery_task(
try:
result.maybe_throw()
except Exception as e:
raise GPUError(f"Error in GPU Task {queue}:{task_name} - {e}") from e
if type(e).__name__ == "UserError" and e.args and isinstance(e.args[0], dict):
raise UserError(**e.args[0])
else:
raise GPUError(f"Error in GPU Task {queue}:{task_name} - {e}") from e
record_cost_auto(
model=queue, sku=ModelSku.gpu_ms, quantity=int((time() - s) * 1000)
)
Expand Down

0 comments on commit 1b33914

Please sign in to comment.