Task Manager (corrections.TaskManager)

class corrections.TaskManager(todo_file, cleanup=False, overwrite=False, cleanup_constraints=None, summary=None, summary_interval=200)[source]

A TaskManager which keeps track of which targets to process.

__init__(todo_file, cleanup=False, overwrite=False, cleanup_constraints=None, summary=None, summary_interval=200)[source]

Initialize the TaskManager which keeps track of which targets to process.

Parameters:
  • todo_file (str) – Path to the TODO-file.

  • cleanup (bool, optional) – Perform cleanup/optimization of TODO-file before during initialization. Default=False.

  • overwrite (bool, optional) – Overwrite any previously calculated results. Default=False.

  • cleanup_constraints (dict, optional) – Dict of constraint for cleanup of the status of previous correction runs. If not specified, all bad results are cleaned up.

  • summary (str, optional) – Path to JSON file which will be periodically updated with a status summary of the corrections.

  • summary_interval (int, optional) – Interval at which summary file is updated. Default=100.

Raises:

FileNotFoundError – If TODO-file could not be found.

close()[source]
get_number_tasks(priority=None, starid=None, sector=None, cadence=None, camera=None, ccd=None, cbv_area=None)[source]

Get number of tasks due to be processed.

Parameters:
  • priority (int, optional) – Only return task matching this priority.

  • starid (int, optional) – Only return tasks matching this starid.

  • sector (int, optional) – Only return tasks matching this Sector.

  • cadence (int, optional) – Only return tasks matching this cadence.

  • camera (int, optional) – Only return tasks matching this camera.

  • ccd (int, optional) – Only return tasks matching this CCD.

Returns:

Number of tasks due to be processed.

Return type:

int

Code author: Rasmus Handberg <rasmush@phys.au.dk>

get_random_task(chunk=1)[source]

Get random task to be processed.

Parameters:

chunk (int, optional) – Chunk of tasks to return. Default is to not chunk (=1).

Returns:

Dictionary of settings for task.

If chunk is larger than one, a list of dicts is retuned instead.

Return type:

dict, list or None

Code author: Rasmus Handberg <rasmush@phys.au.dk>

get_task(priority=None, starid=None, sector=None, cadence=None, camera=None, ccd=None, cbv_area=None, chunk=1)[source]

Get next task to be processed.

Parameters:
  • priority (int, optional) – Only return task matching this priority.

  • starid (int, optional) – Only return tasks matching this starid.

  • sector (int, optional) – Only return tasks matching this Sector.

  • cadence (int, optional) – Only return tasks matching this cadence.

  • camera (int, optional) – Only return tasks matching this camera.

  • ccd (int, optional) – Only return tasks matching this CCD.

  • chunk (int, optional) – Chunk of tasks to return. Default is to not chunk (=1).

Returns:

Dictionary of settings for task.

If chunk is larger than one, a list of dicts is retuned instead.

Return type:

dict, list or None

Code author: Rasmus Handberg <rasmush@phys.au.dk>

save_results(results)[source]

Save result, or list of results, to TaskManager.

Parameters:

results (list or dict)

Code author: Rasmus Handberg <rasmush@phys.au.dk>

save_settings()[source]

Save settings to TODO-file and create method-specific columns in diagnostics_corr table.

Code author: Rasmus Handberg <rasmush@phys.au.dk>

start_task(tasks)[source]

Mark tasks as STARTED in the TODO-list.

Parameters:

tasks (list or dict) – Task or list of tasks coming from get_tasks or get_random_task.

Code author: Rasmus Handberg <rasmush@phys.au.dk>

write_summary()[source]

Write summary of progress to file. The summary file will be in JSON format.