Taskfarm Worker API

class taskfarm_worker.TaskFarm(username, password, uuid=None, numTasks=None, url_base='http://localhost:5000/api/')

a run consisting of a number of tasks

Parameters:
  • username (str) – username for connecting to taskfarm server
  • password (str) – password for connecting to taskfarm server
  • url_base (str) – base URL for taskfarm server API, defaults to ‘http://localhost:5000/api/
  • uuid (str) – when specified load existing run with uuid
  • numTasks (int) – create a new run wtih numTasks tasks

Intantiate a TaskFarm object with either a uuid to load an existing run from the database or create a new run by specifying the number of tasks.

delete()

delete run

getTaskInfo(task, info)

get information about a single task

Parameters:
  • task (int) – the task ID to query
  • info (str) – the information to query
info(info)

get run information

Parameters:info (str) – the information to query
numComputing

the number of tasks being computed

numDone

the number of completed tasks

numTasks

the number of tasks

numWaiting

the number of waiting tasks

percentDone

percentage completed of the run

restart(everything=False)

restart run

Parameters:everything (bool) – when set to True reset all tasks even completed ones, default set to False

The taskfarm does not automaticcaly restart failed tasks. Use this method to restart tasks that are marked computing. Only restart a run when no more workers are computing.

session

the request session

setTaskInfo(task, info, value)

set information about a single task

Parameters:
  • task (int) – the task ID to change
  • info (str) – the information to change
  • value – the value to set it to
token_auth

the auth token

url(url)

construct URL to call

Parameters:url (str) – url end point
Returns:full URL
Return type:str

construct full URL by appending url to url_base

uuid

uuid of the run

class taskfarm_worker.TaskFarmWorker(username, password, uuid, url_base='http://localhost:5000/api/')

taskfarm worker object

Parameters:
  • username (str) – username for connecting to taskfarm server
  • password (str) – password for connecting to taskfarm server
  • url_base (str) – base URL for taskfarm server API, defaults to ‘http://localhost:5000/api/
  • uuid (str) – when specified load existing run with uuid

The taskfarm worker is initialised with the UUID of a run. It provides an interface to the tasks associated with the run.

delete()

delete run

done()

release task

The task is only marked as done if the percentage done is set to 100.

getTaskInfo(task, info)

get information about a single task

Parameters:
  • task (int) – the task ID to query
  • info (str) – the information to query
info(info)

get run information

Parameters:info (str) – the information to query
numComputing

the number of tasks being computed

numDone

the number of completed tasks

numTasks

the number of tasks

numWaiting

the number of waiting tasks

percentDone

percentage completed of the run

restart(everything=False)

restart run

Parameters:everything (bool) – when set to True reset all tasks even completed ones, default set to False

The taskfarm does not automaticcaly restart failed tasks. Use this method to restart tasks that are marked computing. Only restart a run when no more workers are computing.

session

the request session

setTaskInfo(task, info, value)

set information about a single task

Parameters:
  • task (int) – the task ID to change
  • info (str) – the information to change
  • value – the value to set it to
task

the current task associated with the worker

If there is no task associated with the worker request a new task. Return None if there are no more tasks.

tasks

iterator over all remaining tasks

token_auth

the auth token

update(percentage)

update percentage done of current task

Parameters:percentage (float) – the value of the percentage done, must be between 0 and 100
url(url)

construct URL to call

Parameters:url (str) – url end point
Returns:full URL
Return type:str

construct full URL by appending url to url_base

uuid

uuid of the run

worker_uuid

the UUID of the worker

taskfarm_worker.tfRuns(username, password, url_base='http://localhost:5000/api/')

get a list of runs

Parameters:
  • username (str) – username for connecting to taskfarm server
  • password (str) – password for connecting to taskfarm server
  • url_base (str) – base URL for taskfarm server API, defaults to ‘http://localhost:5000/api/
Returns:

list of runs

Return type:

dict