Background Tasks

Trigger Background Task

POST tasks/<str:task_name>/

Note

Authorized Roles: root, manager, backend

Manually trigger a background task.

Warning

DO NOT OVER-USE

All tasks are triggered automatically including the full retraining of all ML models. You should not use this endpoint regularly.

However the API will not trigger a full update of the models when you update only a tiny portion of the ratings. Use this endpoint if you want to be sure the models are using 100% of the ratings.

Allowed task names: 'ml_model_retrain', 'item_popularity_score_recalibrate'.

Errors:

  • DuplicatedError with error name 'TASK_ALREADY_RUNNING' if this task is already running

  • WrongData with error name WRONG_DATA_TYPE if the task name is wrong

List Recent Background Tasks

GET tasks/<str:task_name>/recents/

Note

Authorized Roles: root, manager, backend

List recent background tasks.

Allowed task names: 'ml_model_retrain', 'item_popularity_score_recalibrate'.

Response JSON Object
  • tasks (list-of-object) –

    Inner fields:

    • task_id (string) – Task ID

    • name (string) – Task name

    • start_time (int) – Start timestamp

    • status (enum) – choices: [REQUEST_SENT, RUNNING, FAILED, COMPLETED] Execution status

    • progress (string) – Execution progress message

EXAMPLE RESPONSE
{
  "tasks": [
    {
      "task_id": "4xBBB6qkqDbGdlyYRAjF",
      "name": "ml_model_retrain",
      "start_time": 123456789,
      "status": "RUNNING",
      "progress": "trained model 38c6744c"
    },
    {
      "task_id": "1Jj7kpmBrF2vQaQh-Lfr",
      "name": "ml_model_retrain",
      "start_time": 129876543,
      "status": "COMPLETED",
      "progress": "saved kNN tree"
    }]
  }

Errors:

  • WrongData with error name WRONG_DATA_TYPE if the task name is wrong