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[source]
class client.task_resources.TaskResources(requested_resources: Dict[str, Any], queue: jobmon.core.cluster_protocol.ClusterQueue, requester: jobmon.core.requester.Requester | None = None)[source]

An object representing the resources for a specific task.

requested_resources[source]
queue[source]
requester = None[source]
property is_bound: bool[source]

If the TaskResources has been bound to the database.

property id: int[source]

If the task resources has been bound to the database.

bind() None[source]

Bind TaskResources to the database.

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

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[source]

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[source]

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

static convert_runtime_to_s(time_str: str | float | int) int[source]

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

static scale_val(val: int, scaling_factor: float) float[source]

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.

__hash__() int[source]

Determine the hash of a task resources object.

__eq__(other: object) bool[source]

Check equality of task resources objects.

__repr__() str[source]

A representation string for a TaskResources instance.