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, ml_new_users, ml_new_items.

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, ml_new_users, ml_new_items

Query Parameters
  • page (int) – Optional. [min: 1] Page to be listed (default 1)

  • amt (int) – Optional. [min: 1 max: 64] Amount of tasks to return (default 50)

EXAMPLE QUERY PARAMS
  ?page=2&amt=10
Response JSON Object
  • warnings (list-of-string) – Optional. List of warnings

  • has_next (bool) – Indicates whether or not there are more pages to request

  • next_page (int) – Next page to request

  • tasks (list-of-object) –

    Inner fields:

    • warnings (list-of-string) – List of warnings

    • task_id (string) – Background Task ID

    • name (string) – Task name

    • start_time (float64) – [min: -150000000000.0 (year -2786) max: 3500000000.0 (year 2080)] Start timestamp

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

    • progress (string) – Execution progress message

EXAMPLE RESPONSE
  {
      "has_next": false,
      "next_page": 3,
      "tasks": [
          {
              "task_id": "4xBBB6qkqDbGdlyYRAjF",
              "name": "ml_model_retrain",
              "start_time": 123456789,
              "status": "RUNNING",
              "progress": "trained model 38c6744c"
          }
      ]
  }

Errors:

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