Prewarming API Reference

dt.scheduler.estimate_required_machines()

The estimate_required_machines function calculates the number of machines needed to run a specified number of jobs based on the CPU and Memory requirements of each job. Either the type of machine or its exact CPU and Memory can be specified. If the available resources on the machine are insufficient to run even a single job, the function returns -1.

Examples:

from dt.scheduler import estimate_required_machines

machines_needed = estimate_required_machines(
    job_cpu=4 * 3.5,                 # Each job requires 14 GHz of CPU (4 cores at 3.5 GHz each)
    job_memory=16,                   # Each job requires 16 GB of memory
    num_jobs=1000,                   # Total number of jobs to run
    instance_type='c6i.32xlarge',    # AWS instance type specifying machine's CPU and memory
    # machine_cpu=64 * 3.5,          # Ignored since instance_type is specified
    # machine_memory=128             # Ignored since instance_type is specified
)

print(f"Number of machines required: {machines_needed}")

Parameters:

  • job_cpu (float): The amount of CPU required by a single job, specified in GHz.
  • job_memory (float): The amount of Memory required by a single job, specified in GB.
  • num_jobs (int): The total number of jobs that need to be run.
  • machine_reserve_cpu (float, optional): The amount of CPU reserved by Datatailr, specified in GHz. This reserved amount is subtracted from the total CPU available on the machine for running jobs. The default value is 1.5 GHz.
  • machine_reserve_memory (float, optional): The amount of Memory reserved by Datatailr, specified in GB. This reserved amount is subtracted from the total Memory available on the machine for running jobs. The default value is 4.5 GB.
  • instance_type (str, optional): The AWS instance type that defines the machine's CPU and Memory specifications. If instance_type is provided, the machine_cpu and machine_memory parameters are ignored.
  • machine_cpu (float, optional): The total CPU available on a machine, specified in GHz. This parameter is required if instance_type is not provided.
  • machine_memory (float, optional): The total Memory available on a machine, specified in GB. This parameter is required if instance_type is not provided.

Returns:

  • (int): The number of machines required to run the specified number of jobs. If the available resources on a machine (after accounting for reserved CPU and Memory) are insufficient to run even one job, the function returns -1.

dt.scheduler.prewarming.get_num_instances()

The get_num_instances function calculates the number of machines required to run specified jobs. Unlike estimate_required_machines, it takes a list of Task/ParallelTask objects from dt.scheduler as an input argument, and it uses a default instance family specified in the Settings app for calculations.

Parameters:

  • jobs (List): a list of Task/ParallelTask objects from dt.scheduler.api, for which the number of instances has to be calculated

Returns:

  • (str): Message containing the number of instances along with the instance type.

dt.scheduler.schedule_prewarm()

The schedule_prewarm function schedules a pre-warm operation for the specified Batch Job in a corresponding environment at given time. This function should be used when a Batch Job doesn't run on Schedule (e.g. event-based Run-After jobs), but you want it to have the required compute waiting for the job at its runtime, so the job can start running immediately.

Note – The pre-warm request should be issued at least 5-10 minutes before the runtime to ensure that required compute resources can be prepared in a timely manner.

Note – After the pre-warm request is fulfilled, you will get a notification in the Notifications center.

Examples:

The following issues a pre-warming request for the "My Batch" job in dev environment 10 minutes from now –

from dt.scheduler import schedule_prewarm

schedule_prewarm('My Batch', 'dev', 10)

Parameters:

  • batch_name (str): The name of the Batch Job to pre-warm the compute instances for.
  • tag (str): The environment tag (dev, pre or prod) where the Batch Job will be executed.
  • minutes_to_start (int): The number of minutes from the current time when the job is expected to start.

Returns:

  • (bool): True if the request was successfully recorded, else False.

dt.scheduler.list_prewarm_entries()

The list_prewarm_entries function lists pre-warming entries. By default, only non-deleted entries are retrieved.

Parameters:

  • include_deleted (bool, optional): If set to True, all entries including the deleted ones are retrieved. The default value is False.

Returns:

  • (List[dict]): A list of dictionaries containing the details of each entry.

dt.scheduler.cancel_prewarm_request()

The cancel_prewarm_request function marks a specific pre-warming entry as "deleted".

Parameters:

  • entry_id (int): The ID of the entry to be deleted.

Returns:

  • (bool): True if the operation was successful, else False.