Skip to main content

Data Structure for Tracking Computing Resource Availability

Project description

https://img.shields.io/badge/code%20style-black-000000.svg Documentation Status

Resource Availability Profile

This Python library provides a data structure, termed availability profile, for managing the availability of computing resources. The structure is handy for simulations and experiments where one must track the compute cluster resources allocated to jobs or tasks over time. The following provides examples of using the discrete resource range, set, and profile, which use int as data type, but the same concepts apply to profiles for other data types.

One can use the discrete (int) range, set, and profile to track the availability of, for instance, CPUs or cluster nodes. To create ranges with resources 0..20 and 30..50 and add them to a set:

from availability.sets import DiscreteRange, DiscreteSet
span1 = DiscreteRange(0, 20)
span2 = DiscreteRange(30, 50)
res_set = DiscreteSet([span1, span2])

Although you can create ranges and sets, one will not manipulate them directly. For tracking the resources available over time, one will likely use an availability profile (discrete or continuous, depending on the type of resource they are dealing with). To create an availability profile with a maximum capacity of 100 discrete resources for tracking the availability of cluster nodes, for instance, one can use the following:

from availability.profile import DiscreteProfile
profile = DiscreteProfile(max_capacity=100)

If you are using the profile in a task-scheduling simulation, you can use the method allocate_resources() from the profile to remove the resource range 0..10 assigned to the task:

profile.allocate_resources(
    resources=DiscreteSet(
        [DiscreteRange(0, 10)]
    ),
    start_time=0,
    end_time=10
)

To find the time at which a task requiring 40 resources for 50 time units can start:

slot = profile.find_start_time(
    quantity=40, ready_time=5, duration=50
)

The returned slot will resemble:

TimeSlot(
    period=DiscreteRange(0, 50),
    resources=DiscreteSet([DiscreteRange(10, 100)])
)

The profile provides other methods, such as check_availability() to check whether a given quantity of resources is available over a given period:

slot = profile.check_availability(
    quantity=10, start_time=5, duration=50
)

One can use the methods free_time_slots() or scheduling_options() to obtain the list of time slots and resources available. The main difference between them is that the time slots returned by the latter may overlap as they represent all the scheduling possibilities for scheduling a job, given the resource availability over the specified period:

slots = profile.scheduling_options(
    start_time=10,
    end_time=100,
    min_duration=20,
    min_quantity=5
)

The operations for querying the resources available during a period return the complete set of resources available. This design allows a user to implement their resource selection policy. However, you can use select_resources() or select_slot_resources() to select a given number of resources from a set or slot:

slot = profile.find_start_time(
    quantity=5, ready_time=0, duration=10
)
selected = profile.select_resources(
    resources=slot.resources, quantity=5)
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

availability-profile-0.0.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

availability_profile-0.0.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file availability-profile-0.0.1.tar.gz.

File metadata

  • Download URL: availability-profile-0.0.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for availability-profile-0.0.1.tar.gz
Algorithm Hash digest
SHA256 21f37209d48d54b783b692089996bb17c795c1babd14449fdd974b8e647dfa9b
MD5 b61eaaecf0dc41948d552ec92af4b66e
BLAKE2b-256 afffe2ffe958b243e7e2fc109f8bb529db5422f5838cc9d5a297ea12a38294ee

See more details on using hashes here.

File details

Details for the file availability_profile-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for availability_profile-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ba05d44efbb2f347b814e17a3722e793720685b35bfd6c035970cdbbeceaab3
MD5 fa316ac76507cf518a3cc40325ad1d88
BLAKE2b-256 f4d5ddfe56ea0d1d0acf31c4e44a435b3e2e16125643a67848034dd14ac7fab5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page