wmaee.codes.pyiron.pyiron_cluster
1from pyiron_base import state 2 3def assign_partition_mulhpc(): 4 """ 5 Assigns a free partition from available partitions `p11` or `p12`. 6 7 This function queries the remote system for idle partitions and assigns one of the available 8 partitions (`p11` or `p12`). If neither partition is available, it defaults to returning `p11`. 9 10 Returns 11 ------- 12 str 13 The name of the assigned partition (`p11` or `p12`). 14 If no free partition is found, returns `p11` by default. 15 16 Notes 17 ----- 18 - The function relies on the `sinfo` command to retrieve the state of partitions. 19 - Partitions are considered free if they are marked as "idle" in the output of `sinfo`. 20 - If the partition name ends with an asterisk (`*`), it is stripped out before returning. 21 22 Examples 23 -------- 24 >>> assign_partition_mulhpc() 25 'p11' # or 'p12', depending on availability 26 """ 27 free_partitions = state.queue_adapter._adapter._execute_remote_command("sinfo | grep idle").split("\n") 28 for partition in free_partitions: 29 if partition: 30 parts = partition.split() 31 if "p11" in parts[0] or "p12" in parts[0]: 32 use_part = parts[0].split("*")[0] # p11 is always written like p11* 33 else: 34 use_part = "p11" 35 return use_part
def
assign_partition_mulhpc():
4def assign_partition_mulhpc(): 5 """ 6 Assigns a free partition from available partitions `p11` or `p12`. 7 8 This function queries the remote system for idle partitions and assigns one of the available 9 partitions (`p11` or `p12`). If neither partition is available, it defaults to returning `p11`. 10 11 Returns 12 ------- 13 str 14 The name of the assigned partition (`p11` or `p12`). 15 If no free partition is found, returns `p11` by default. 16 17 Notes 18 ----- 19 - The function relies on the `sinfo` command to retrieve the state of partitions. 20 - Partitions are considered free if they are marked as "idle" in the output of `sinfo`. 21 - If the partition name ends with an asterisk (`*`), it is stripped out before returning. 22 23 Examples 24 -------- 25 >>> assign_partition_mulhpc() 26 'p11' # or 'p12', depending on availability 27 """ 28 free_partitions = state.queue_adapter._adapter._execute_remote_command("sinfo | grep idle").split("\n") 29 for partition in free_partitions: 30 if partition: 31 parts = partition.split() 32 if "p11" in parts[0] or "p12" in parts[0]: 33 use_part = parts[0].split("*")[0] # p11 is always written like p11* 34 else: 35 use_part = "p11" 36 return use_part
Assigns a free partition from available partitions p11 or p12.
This function queries the remote system for idle partitions and assigns one of the available
partitions (p11 or p12). If neither partition is available, it defaults to returning p11.
Returns
- str: The name of the assigned partition (
p11orp12). If no free partition is found, returnsp11by default.
Notes
- The function relies on the
sinfocommand to retrieve the state of partitions. - Partitions are considered free if they are marked as "idle" in the output of
sinfo. - If the partition name ends with an asterisk (
*), it is stripped out before returning.
Examples
>>> assign_partition_mulhpc()
'p11' # or 'p12', depending on availability