Skip to content

Commit

Permalink
XXX_FETCHED の状態を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
n-kakuko authored Oct 9, 2024
1 parent 20afe5f commit fff8584
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions backend/oqtopus_cloud/user/routers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ def __init__(self, detail: str):

def create_sampling_task_info(task: Task) -> SamplingTaskInfo:
status = task.status
if task.status == "QUEUED_FETCHED":
status = "QUEUED"
elif task.status == "CANCELIING_FETCHED":
status = "CANCELLING"
return SamplingTaskInfo(
taskId=TaskId(task.id),
code=task.code,
Expand Down Expand Up @@ -122,10 +118,6 @@ def serialize_operator(operator: Operator) -> str | BadRequestResponse:

def create_estimation_task_info(task: Task) -> EstimationTaskInfo:
status = task.status
if task.status == "QUEUED_FETCHED":
status = "QUEUED"
elif task.status == "CANCELIING_FETCHED":
status = "CANCELLING"

return EstimationTaskInfo(
taskId=TaskId(task.id),
Expand Down Expand Up @@ -550,10 +542,10 @@ def cancel_sampling_task(
if (
task.owner != owner
or task.action != "sampling"
or task.status not in ["QUEUED_FETCHED", "QUEUED", "RUNNING"]
or task.status not in ["QUEUED", "RUNNING"]
):
return NotFoundErrorResponse(
detail=f"{taskId} task is not in valid status for cancellation (valid statuses for cancellation: 'QUEUED_FETCHED', 'QUEUED' and 'RUNNING')"
detail=f"{taskId} task is not in valid status for cancellation (valid statuses for cancellation: 'QUEUED' and 'RUNNING')"
)
if task.status == "QUEUED":
logger.info("task is in QUEUED state, so it will be cancelled")
Expand All @@ -562,9 +554,9 @@ def cancel_sampling_task(
)
db.add(result)
db.commit()
elif task.status in ["QUEUED_FETCHED", "RUNNING"]:
elif task.status in ["RUNNING"]:
logger.info(
"task is in QUEUED_FETCHED or RUNNING state, so it will be marked as CANCELLING"
"task is in RUNNING state, so it will be marked as CANCELLING"
)
task.status = "CANCELLING"
db.commit()
Expand Down Expand Up @@ -868,10 +860,10 @@ def cancel_estimation_task(
if (
task.owner != owner
or task.action != "estimation"
or task.status not in ["QUEUED_FETCHED", "QUEUED", "RUNNING"]
or task.status not in ["QUEUED", "RUNNING"]
):
return NotFoundErrorResponse(
detail=f"{taskId} task is not in valid status for cancellation (valid statuses for cancellation: 'QUEUED_FETCHED', 'QUEUED' and 'RUNNING')"
detail=f"{taskId} task is not in valid status for cancellation (valid statuses for cancellation: 'QUEUED' and 'RUNNING')"
)
if task.status == "QUEUED":
logger.info("task is in QUEUED state, so it will be cancelled")
Expand All @@ -880,9 +872,9 @@ def cancel_estimation_task(
)
db.add(result)
db.commit()
elif task.status in ["QUEUED_FETCHED", "RUNNING"]:
elif task.status in ["RUNNING"]:
logger.info(
"task is in QUEUED_FETCHED or RUNNING state, so it will be marked as CANCELLING"
"task is in RUNNING state, so it will be marked as CANCELLING"
)
task.status = "CANCELLING"
db.commit()
Expand Down

0 comments on commit fff8584

Please sign in to comment.