matrice.compute module#
- class matrice.compute.ComputeInstance(session, alias)[source]#
Bases:
object
Represents a single compute instance and allows performing operations on the instance such as update, delete, and refresh.
- Alias#
str
- Status#
str
- Price_Hour#
float
- Machine_EFF#
float
- Service_Provider#
str
- Launched_At#
str
- Launch_Duration#
int
- Shutdown_Threshold#
int
- GPU_Type#
str
- GPU_Memory#
int
- CPU#
str
- Cores#
int
- Memory_GB#
int
- Storage_GB#
int
- Storage_Type#
str
- class datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])#
Bases:
date
The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.
- astimezone()#
tz -> convert to local time in new timezone tz
- combine()#
date, time -> datetime with same date and time fields
- ctime()#
Return ctime() style string.
- date()#
Return date object with same year, month and day.
- dst()#
Return self.tzinfo.dst(self).
- fromisoformat()#
string -> datetime from a string in most ISO 8601 formats
- fromtimestamp()#
timestamp[, tz] -> tz’s local time from POSIX timestamp.
- isoformat()#
[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.
- now()#
Returns new datetime object representing current time local to tz.
- tz
Timezone object.
If no tz is specified, uses local timezone.
- replace()#
Return datetime with new specified fields.
- strptime()#
string, format -> new datetime parsed from a string (like time.strptime()).
- time()#
Return time object with same time but with tzinfo=None.
- timestamp()#
Return POSIX timestamp as float.
- timetuple()#
Return time tuple, compatible with time.localtime().
- timetz()#
Return time object with same time and tzinfo.
- tzname()#
Return self.tzinfo.tzname(self).
- utcfromtimestamp()#
Construct a naive UTC datetime from a POSIX timestamp.
- utcnow()#
Return a new datetime representing UTC day and time.
- utcoffset()#
Return self.tzinfo.utcoffset(self).
- utctimetuple()#
Return UTC time tuple, compatible with time.localtime().
- fold#
- hour#
- max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)#
- microsecond#
- min = datetime.datetime(1, 1, 1, 0, 0)#
- minute#
- resolution = datetime.timedelta(microseconds=1)#
- second#
- tzinfo#
- class timedelta#
Bases:
object
Difference between two datetime values.
timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
All arguments are optional and default to 0. Arguments may be integers or floats, and may be positive or negative.
- total_seconds()#
Total seconds in the duration.
- days#
Number of days.
- max = datetime.timedelta(days=999999999, seconds=86399, microseconds=999999)#
- microseconds#
Number of microseconds (>= 0 and less than 1 second).
- min = datetime.timedelta(days=-999999999)#
- resolution = datetime.timedelta(microseconds=1)#
- seconds#
Number of seconds (>= 0 and less than 1 day).
- __init__(session, alias)[source]#
Initialize the ComputeInstance object by fetching the compute instance details from the server based on the provided alias.
- Parameters:
session (object) – The session object containing account and RPC information.
alias (str) – The alias of the compute instance to fetch details for.
- delete()[source]#
Update the compute instance attributes if it is not a dedicated instance.
- Returns:
Server response indicating the result of the update request, or None if update is not allowed or fails.
- Return type:
dict or None
- class matrice.compute.ComputeType(session, instance_type, price_hour, service_provider, machine_eff, compute_eff, gpu_type, gpu_memory, cpu, cores, memory_mb, storage_gb, storage_type)[source]#
Bases:
object
Initialize a ComputeType instance with the provided attributes.
- Parameters:
session (object) – The session object containing account and RPC information.
instance_type (str) – The type of compute instance.
price_hour (float) – Hourly price of the instance.
service_provider (str) – Service provider offering the instance.
machine_eff (float) – Efficiency rating of the machine.
compute_eff (float) – Efficiency rating of the compute.
gpu_type (str) – Type of GPU in the instance.
gpu_memory (int) – GPU memory in GB.
cpu (str) – CPU type in the instance.
cores (int) – Number of CPU cores.
memory_mb (int) – Memory size in MB.
storage_gb (int) – Storage size in GB.
storage_type (str) – Type of storage in the instance.
- matrice.compute.add_on_demand_instance(session, alias, compute_type, service_provider, launch_duration_hours, shutdown_thres_minutes)[source]#
Add an on-demand instance.
- Parameters:
session (object) – The session object containing account and RPC information.
alias (str) – Alias for the new compute instance.
compute_type (str) – Type of compute instance to launch.
service_provider (str) – Service provider offering the instance.
launch_duration_hours (int) – Duration in hours for the compute instance.
shutdown_thres_minutes (int) – Shutdown threshold in minutes for automatic shutdown.
- Returns:
Server response indicating the result of the add request, or None if an error occurred.
- Return type:
dict or None
- matrice.compute.get_compute_status_summary(session, lease_type='on-demand')[source]#
Get a summary of compute statuses for the current account based on the lease type.
- Parameters:
session (object) – The session object containing account and RPC information.
lease_type (str, optional) – The lease type of computes (e.g., ‘dedicated’, ‘shared’). Default is ‘on-demand’.
- Returns:
An ordered dictionary with compute statuses and their counts.
- Return type:
OrderedDict
- matrice.compute.list_account_compute(session, status='all')[source]#
List all compute instances associated with an account, with an optional status filter.
- Parameters:
session (object) – The session object containing account and RPC information.
status (str, optional) – Status filter for instances (e.g., ‘all’, ‘active’, ‘terminated’).
- Returns:
Dictionary of ComputeInstance objects indexed by alias, or None if no data is available.
- Return type:
dict or None
- matrice.compute.list_instance_types(session, providers=None, gpu_types=None, price_range=None, page_size=10, page_num=0)[source]#
List all available compute types on the platform with optional filters.
- Parameters:
session (object) – The session object containing account and RPC information.
providers (list, optional) – List of service providers to filter instances.
gpu_types (list, optional) – List of GPU types to filter instances.
price_range (tuple, optional) – A tuple containing min and max price to filter instances by price range.
page_size (int, optional) – The number of instances to return per page.
page_num (int, optional) – The page number for pagination.
- Returns:
Dictionary of ComputeType objects indexed by instanceType, or None if no data is available.
- Return type:
dict or None