Skip to content

Commit

Permalink
backend: allow reset_task script to reset tasks with any state
Browse files Browse the repository at this point in the history
  • Loading branch information
rroohhh committed Feb 28, 2024
1 parent c4a031d commit cc24299
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/scripts/reset_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,20 @@
parser.add_argument(
"--uuid", required=True, type=uuid.UUID, help="Task UUID or Document UUID"
)
parser.add_argument(
"--state",
type=TaskState,
choices=list(TaskState),
default=TaskState.FAILED,
help="State of tasks to reset",
)
args = parser.parse_args()
with SessionContextManager(path="management_command:reset_task") as session:
task = session.execute(
update(Task)
.where(
or_(Task.id == args.uuid, Task.document_id == args.uuid),
Task.state == TaskState.FAILED,
Task.state == args.state,
)
.values(state=TaskState.NEW, remaining_attempts=settings.task_attempt_limit)
)
Expand Down
3 changes: 3 additions & 0 deletions backend/transcribee_backend/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class TaskState(enum.Enum):
COMPLETED = "COMPLETED"
FAILED = "FAILED"

def __str__(self):
return self.value


class TaskBase(SQLModel):
task_type: TaskType
Expand Down

0 comments on commit cc24299

Please sign in to comment.