client.task_resources

The client Task Resources with the resources initiation and binding to Task ID.

Attributes

logger

Classes

TaskResources

An object representing the resources for a specific task.

Module Contents

client.task_resources.logger
class client.task_resources.TaskResources(requested_resources: Dict[str, Any], queue: jobmon.core.cluster_protocol.ClusterQueue, requester: jobmon.core.requester.Requester | None = None)

An object representing the resources for a specific task.

Initialize the task resource object.

requested_resources
queue
requester = None
property is_bound: bool

If the TaskResources has been bound to the database.

property id: int

If the task resources has been bound to the database.

bind() None

Bind TaskResources to the database (synchronous).

async bind_async(session: aiohttp.ClientSession) None

Bind TaskResources to the database (asynchronous).

Parameters:

session – An aiohttp ClientSession for making async HTTP requests.

validate_resources(strict: bool = False) Tuple[bool, str]
coerce_resources() TaskResources

Coerce TaskResources to fit on queue. If resources change return a new object.

adjust_resources(resource_scales: Dict[str, numbers.Number | Callable | Iterator[numbers.Number]], fallback_queues: List[jobmon.core.cluster_protocol.ClusterQueue] | None = None) TaskResources

Adjust TaskResources after a resource error, returning a new object if it changed.

Parameters:
  • resource_scales – Specifies how much to scale the failed Task’s resources by. Scale factor can be a numeric value, a Callable that will be applied to the existing resources, or an Iterator. Any Callable should take a single numeric value as its sole argument. Any Iterator should only yield numeric values. Any Iterable can be easily converted to an Iterator by using the iter() built-in (e.g. iter([80, 160, 190])).

  • fallback_queues – list of queues that users specify. If their jobs exceed the resources of a given queue, Jobmon will try to run their jobs on the fallback queues.

static convert_memory_to_gib(memory_str: str) int

Given a memory request with a unit suffix, convert to GiB.

static convert_runtime_to_s(time_str: str | float | int) int

Given a runtime request, coerce to seconds for recording in the DB.

static scale_val(val: int, scaling_factor: float) float

Used ceil instead of round or floor, to handle case when resources is 1.

For example, if runtime was 1, resource scales was 0.2. Then the resource would adjust to 1.2, which would be truncated to 1 again if using floor/round.