diff --git a/aztk/client/base/base_operations.py b/aztk/client/base/base_operations.py index 89727520..a1cff5be 100644 --- a/aztk/client/base/base_operations.py +++ b/aztk/client/base/base_operations.py @@ -329,7 +329,7 @@ def list_batch_tasks(self, id: str): id (:obj:`str`): the name of the cluster the task was submitted to Returns: - :obj:`str`: the status state of the task + :obj:`[aztk.models.Task]`: list of aztk tasks """ return task_table.list_batch_tasks(self.batch_client, id) @@ -341,6 +341,6 @@ def get_batch_task(self, id: str, task_id: str): task_id (:obj:`str`): the name of the task to get Returns: - :obj:`str`: the status state of the task + :obj:`aztk.models.Task`: aztk Task representing the Batch Task """ return task_table.get_batch_task(self.batch_client, id, task_id) diff --git a/aztk/models/__init__.py b/aztk/models/__init__.py index b968dc52..7bf13ca8 100644 --- a/aztk/models/__init__.py +++ b/aztk/models/__init__.py @@ -1,6 +1,7 @@ from .application_log import ApplicationLog from .cluster import Cluster from .cluster_configuration import ClusterConfiguration +from .cluster_state import ClusterState from .file import File from .file_share import FileShare from .node_output import NodeOutput diff --git a/aztk/models/cluster.py b/aztk/models/cluster.py index ca48f887..b4699508 100644 --- a/aztk/models/cluster.py +++ b/aztk/models/cluster.py @@ -1,5 +1,7 @@ import azure.batch.models as batch_models +from .cluster_state import ClusterState + class Cluster: def __init__(self, pool: batch_models.CloudPool, nodes: batch_models.ComputeNodePaged = None): @@ -7,10 +9,10 @@ def __init__(self, pool: batch_models.CloudPool, nodes: batch_models.ComputeNode self.pool = pool self.nodes = nodes self.vm_size = pool.vm_size - if pool.state.value is batch_models.PoolState.active: - self.visible_state = pool.allocation_state.value + if pool.state is batch_models.PoolState.active: + self.state = ClusterState(pool.allocation_state.value) else: - self.visible_state = pool.state.value + self.state = ClusterState(pool.state.value) self.total_current_nodes = pool.current_dedicated_nodes + pool.current_low_priority_nodes self.total_target_nodes = pool.target_dedicated_nodes + pool.target_low_priority_nodes self.current_dedicated_nodes = pool.current_dedicated_nodes diff --git a/aztk/models/cluster_state.py b/aztk/models/cluster_state.py new file mode 100644 index 00000000..040afe16 --- /dev/null +++ b/aztk/models/cluster_state.py @@ -0,0 +1,8 @@ +from enum import Enum + + +class ClusterState(Enum): + deleting = "deleting" + resizing = "resizing" + steady = "steady" + stopping_resize = "stopping" diff --git a/aztk_cli/utils.py b/aztk_cli/utils.py index 1ba17716..55a6d949 100644 --- a/aztk_cli/utils.py +++ b/aztk_cli/utils.py @@ -48,7 +48,7 @@ def print_cluster(client, cluster: models.Cluster, internal: bool = False): log.info("") log.info("Cluster %s", cluster.id) log.info("------------------------------------------") - log.info("State: %s", cluster.visible_state) + log.info("State: %s", cluster.state.value) log.info("Node Size: %s", cluster.vm_size) log.info("Nodes: %s", node_count) log.info("| Dedicated: %s", __pretty_dedicated_node_count(cluster)) @@ -114,7 +114,7 @@ def print_clusters(clusters: List[models.Cluster]): for cluster in clusters: node_count = __pretty_node_count(cluster) - log.info(print_format.format(cluster.id, cluster.visible_state, cluster.vm_size, node_count)) + log.info(print_format.format(cluster.id, cluster.state.value, cluster.vm_size, node_count)) def print_clusters_quiet(clusters: List[models.Cluster]):