Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Marishka17 committed Feb 10, 2025
1 parent 6208de4 commit c9bbe48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions cvat/apps/engine/rq_job_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,22 @@ def reset_meta_on_retry(self) -> dict[RQJobMetaField, Any]:

@attrs.define(kw_only=True)
class RQMetaWithFailureInfo(AbstractRQMeta):

# mutable && optional fields
formatted_exception: str | None = attrs.field(
validator=[optional_str_validator],
default=None,
on_setattr=_update_value,
)
exc_type: str | None = attrs.field(
validator=[optional_str_validator],
exc_type: type[Exception] | None = attrs.field(
default=None,
on_setattr=_update_value,
)
@exc_type.validator
def _check_exc_type(self, attribute: attrs.Attribute, value: Any):
if value is not None and not issubclass(value, Exception):
raise ValueError("Wrong exception type")

exc_args: Iterable | None = attrs.field(default=None, on_setattr=_update_value)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ def perform_destroy(self, instance):
super().perform_destroy(instance)
target.touch()

def rq_exception_handler(rq_job: RQJob, exc_type: type[Exception], exc_value, tb):
def rq_exception_handler(rq_job: RQJob, exc_type: type[Exception], exc_value: Exception, tb):
rq_job_meta = RQMetaWithFailureInfo.from_job(rq_job)
rq_job_meta.formatted_exception = "".join(
traceback.format_exception_only(exc_type, exc_value))
Expand Down
6 changes: 3 additions & 3 deletions cvat/apps/lambda_manager/rq.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
@attrs.define(kw_only=True)
class LambdaRQMeta(BaseRQMeta):
# immutable fields
function_id: int = attrs.field(
validator=[attrs.validators.instance_of(int)], default=None, on_setattr=attrs.setters.frozen
function_id: str = attrs.field(
validator=[attrs.validators.instance_of(str)], default=None, on_setattr=attrs.setters.frozen
)
lambda_: bool = attrs.field(
validator=[attrs.validators.instance_of(bool)],
Expand All @@ -38,7 +38,7 @@ def build_for(
*,
request: PatchedRequest,
db_obj: Model,
function_id: int,
function_id: str,
):
base_meta = BaseRQMeta.build(request=request, db_obj=db_obj)
return cls(
Expand Down

0 comments on commit c9bbe48

Please sign in to comment.