py-hostlist package¶
Submodules¶
hostlist.hostlist module¶
A slurm-style hostlist processor.
-
hostlist.hostlist.
append_hostname
(machine_name, num_list)¶ Helper method to append the hostname to node numbers.
Parameters: - machine_name – The name of the cluster.
- num_list – The list of nodes to be appended to the cluster name.
Returns: A hostlist string with the hostname and node numbers.
-
hostlist.hostlist.
compress
(nodelist)¶ compress will return a hostlist string given a list of hostnames.
Param: nodelist: The hostlist string. Returns: The hostlist string.
-
hostlist.hostlist.
compress_range
(nodelist)¶ compress_range will return a compressed hostlist string given a list of hostnames.
Param: nodelist: The expanded hostlist string. Returns: The compressed hostlist string.
-
hostlist.hostlist.
count
(nodelist)¶ count returns the number of hosts.
Param: nodelist: The hostlist string. Returns: The number of nodes in the hostlist string.
-
hostlist.hostlist.
delimiter
(nodelist, d)¶ delimiter sets the output delimiter (default = “,”)
Param: nodelist: The hostlist string. Param: d: The delimiter. Returns: The resulting hostlist string with custom delimiter.
-
hostlist.hostlist.
diff
(*arg)¶ diff will subtract elements in all subsequent lists from list 1 and return the remainder.
Param: nodelist1: The hostlist string to be subtracted from. Param: following nodelists: The other hostlist strings. Returns: The remainding list from subtracting the two original lists.
-
hostlist.hostlist.
exclude
(*arg)¶ excludes all HOSTLIST args from first HOSTLIST
Param: nodelist: The hostlist string. Param: node: The node to be excluded. Returns: The resulting hostlist string without the nodes specified.
-
hostlist.hostlist.
expand
(nodelist)¶ expand takes in a compressed hostlist string and returns all hosts listed.
Param: nodelist: The hostlist string. Returns: The expanded hostlist string.
-
hostlist.hostlist.
filter_python
(nodelist)¶ TODO: filter maps Python code over all hosts in result HOSTLIST
Param: nodelist: The hostlist string.
-
hostlist.hostlist.
find
(nodelist, node)¶ find outputs the position of the node in the nodelist passed in.
Param: nodelist: The hostlist string. Param: node: The host to be searched inside of the hostlist string. Returns: The position of the host within the hostlist string.
-
hostlist.hostlist.
intersect
(*arg)¶ Given references to n lists, intersect return a list of intersecting nodes.
Param: nodelist: Any number of nodelists to be intersected. Returns: The resulting intersected list.
-
hostlist.hostlist.
nth
(nodelist, n)¶ nth returns the nth node from a list of nodes.
Param: nodelist: The hostlist string. Param: n: The index desired. Returns: The host at the specified index.
-
hostlist.hostlist.
quiet
(nodelist=[])¶ quiet will return quiet output (or exit non-zero if there is an empty hostlist)
Param: nodelist: The hostlist string.
-
hostlist.hostlist.
remove_node
(nodelist, node)¶ removes a node from a passed in hostlist.
Param: nodelist: The hostlist string. Param: node: The node to be removed. Returns: The resulting hostlist upon deletion.
-
hostlist.hostlist.
size_hostlist
(nodelist, N)¶ size will output at most N hosts (-N for last N hosts)
Param: nodelist: The hostlist string. Param: N: the number of hosts to print. Returns: The resulting hostlist string with custom size.
-
hostlist.hostlist.
sort_nodes
(nodelist)¶ sort_nodes is a helper method that sorts the nodes in ascending order.
Parameters: nodelist – The hostlist string. Returns: The hostlist string in ascending order.
-
hostlist.hostlist.
union_nodes
(*arg)¶ union_nodes returns the union between n lists of nodes.
Param: nodelist: Any number of nodelists to be combined. Returns: The resulting unioned list.
-
hostlist.hostlist.
xor
(*arg)¶ xor returns the symmetric difference between n lists of nodes.
Param: nodelist: Any number of nodelists to be xor. Returns: The resulting xor list.
hostlist.unittest_hostlist module¶
-
class
hostlist.unittest_hostlist.
TestHostlistMethods
(methodName='runTest')¶ Bases:
unittest.case.TestCase
-
test_compress
()¶
-
test_compress_as_string
()¶
-
test_compress_range_as_string
()¶
-
test_compress_range_mixed
()¶
-
test_compress_range_simple
()¶
-
test_compress_range_suffix
()¶
-
test_compress_range_with_hyphen
()¶
-
test_count
()¶
-
test_count_as_list
()¶
-
test_count_multi_ranges
()¶
-
test_count_with_expand
()¶
-
test_delimiter_as_list
()¶
-
test_delimiter_as_string
()¶
-
test_delimiter_with_expand
()¶
-
test_diff
()¶
-
test_diff_as_string
()¶
-
test_diff_multiple
()¶
-
test_diff_scr
()¶
-
test_diff_with_expand
()¶
-
test_exclude_as_list
()¶
-
test_exclude_as_string
()¶
-
test_exclude_with_expand
()¶
-
test_expand
()¶
-
test_expand_leading_zeros
()¶
-
test_expand_mixed_range
()¶
-
test_expand_multi_range
()¶
-
test_expand_only_commas
()¶
-
test_expand_prefix_and_suffix
()¶
-
test_expand_scr
()¶
-
test_find
()¶
-
test_find_as_list
()¶
-
test_find_as_string
()¶
-
test_find_doesnt_exist
()¶
-
test_instersect_as_string
()¶
-
test_intersect_multiple
()¶
-
test_intersect_scr
()¶
-
test_intersect_simple
()¶
-
test_intersect_with_expand
()¶
-
test_nth
()¶
-
test_nth_as_list
()¶
-
test_nth_as_str
()¶
-
test_nth_doesnt_exist
()¶
-
test_quiet
()¶
-
test_quiet_as_list
()¶
-
test_quiet_empty
()¶
-
test_quiet_with_expand
()¶
-
test_remove_node
()¶
-
test_remove_node_as_list
()¶
-
test_remove_node_with_expand
()¶
-
test_size_as_list
()¶
-
test_size_as_string
()¶
-
test_size_backwards
()¶
-
test_size_with_expand
()¶
-
test_size_with_expand_backwards
()¶
-
test_sort
()¶
-
test_sort_as_string
()¶
-
test_union_as_string
()¶
-
test_union_multiple
()¶
-
test_union_simple
()¶
-
test_union_with_expand
()¶
-
test_xor_as_list
()¶
-
test_xor_as_string
()¶
-
test_xor_with_expand
()¶
-
Module contents¶
A slurm-style hostlist processor.