Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
Feature: ClusterState enum (#677)
Browse files Browse the repository at this point in the history
* add cluster state enum, update usage

* fix docstrings

* stopping->stopping_resize
  • Loading branch information
jafreck committed Oct 29, 2018
1 parent 8c2bf0c commit e486536
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions aztk/client/base/base_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
1 change: 1 addition & 0 deletions aztk/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions aztk/models/cluster.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
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):
self.id = pool.id
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
Expand Down
8 changes: 8 additions & 0 deletions aztk/models/cluster_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from enum import Enum


class ClusterState(Enum):
deleting = "deleting"
resizing = "resizing"
steady = "steady"
stopping_resize = "stopping"
4 changes: 2 additions & 2 deletions aztk_cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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]):
Expand Down

0 comments on commit e486536

Please sign in to comment.