Task objects

Summary of task objects

Most operations have an associated Task DbObject throughout the SDK. This object can make your workflow synchronous, especially for longer operations. The Task represents the actual task of your operation.
You can find tasks inside the UI within the notification center.

Methods

The main method associated with a task object is wait_till_done, which waits until the task is completed by periodically querying the server to update the task attributes. This method takes two parameters:

  1. timeout_seconds: Represents the maximum time wait_till_done can block your code. The default value is five minutes, which should be increased for longer tasks.
  2. check_frequency: Defines how often your task queries the server to update the task attributes, which defaults to two seconds. This is useful to limit the amount of API calls against our server in a given time frame.
dataset = client.get_dataset("<dataset id>")

task = dataset.create_data_rows([{
  "row_data": item_url,
  "global_key": "<unique_global_key>"
}])
task.wait_till_done(timeout_seconds=5_000, check_frequency=10)

Task Results

The task result is a collection of details, typically information on the data rows associated with the task.

dataset = client.get_dataset("<dataset id>")

task = dataset.create_data_rows([{
  "row_data": item_url,
  "global_key": "<unique_global_key>"
}])
task.wait_till_done()

print(task.result) # prints the data rows associated with the create_data_rows operation

🚧

Warning

Large results (over 150,000 data rows) can take up to 10 mins to process.

Task Errors

The task errors work similarly to the task results but contain information on any associated errors.

dataset = client.get_dataset("<dataset id>")

task = dataset.create_data_rows([{
  "row_data": item_url,
  "global_key": "<unique_global_key>"
}])
task.wait_till_done()

print(task.errors) # prints the data rows associated with the create_data_rows operation