genipe.db package

Module contents

Submodules

genipe.db.utils module

genipe.db.utils.create_task_db(out_dir)[source]

Creates a task DB.

Parameters:out_dir (str) – the directory where the DB will be saved
Returns:the name of the file containing the DB
Return type:str

A SQLITE database will be created in the out_dir directory (with the name tasks.db. The genipe_task table is automatically created.

genipe.db.utils.check_task_completion(task_id, db_name)[source]

Checks if the task exists and if it’s completed.

Parameters:
  • task_id (str) – the ID of the task
  • db_name (str) – the name of the database (usually a file)
Returns:

True if the task exists and is completed, False

otherwise

Return type:

bool

Note

A task is completed if the column completed equals 1. It is not completed otherwise.

genipe.db.utils.create_task_entry(task_id, db_name)[source]

Creates (or updates) a task.

Parameters:
  • task_id (str) – the ID of the task
  • db_name (str) – the name of the database (usually a file)

If the task ID doesn’t exist in the DB, a new one will be created with the current time as launch and start time.

If the task ID already exist, it is presumed that the task will be relaunched, hence the database entry is updated to the current time (for launch and start time) and completed is set to 0.

genipe.db.utils.mark_task_completed(task_id, db_name)[source]

Marks the task as completed.

Parameters:
  • task_id (str) – the ID of the task
  • db_name (str) – the name of the DB (usually a file)

The task entry is modified so that completed=1 and the end time is updated to the current time.

genipe.db.utils.mark_task_incomplete(task_id, db_name)[source]

Marks a task as incomplete.

Parameters:
  • task_id (str) – the ID of the task
  • db_name (str) – the name of the DB (usually a file)

The task entry is set as incomplete by updating the completed value to 0.

genipe.db.utils.get_task_runtime(task_id, db_name)[source]

Gets the task run time.

Parameters:
  • task_id (str) – the ID of the task
  • db_name (str) – the name of the DB (usually a file)
Returns:

the execution time of the task (in seconds)

Return type:

int

genipe.db.utils.get_all_runtimes(db_name)[source]

Gets all tasks execution time.

Parameters:db_name (str) – the name of the DB (usually a file)
Returns:the execution time (seconds) of all the tasks in the database
Return type:dict

This function returns a dictionary of task ID (keys) pointing to execution time (in second) (int).

genipe.db.utils.mark_drmaa_task_completed(task_id, launch_time, start_time, end_time, db_name)[source]

Marks a task run by DRMAA as completed (while updating times).

Parameters:
  • task_id (str) – the ID of the task
  • launch_time (float) – the launch time (according to DRMAA)
  • start_time (float) – the start time (according to DRMAA)
  • end_time (float) – the end time (according to DRMAA)
  • db_name (str) – the name of the DB (usually a file)

The task entry is updated with the launch, start and end time. Those times come from the DRMAA library. The launch time is the time at which the task was launched to the scheduler. The start time correspond to the time that the scheduler started the job on the cluster. Finally, the end time is the time that the job was completed.