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

Commit 72c7833

Browse files
brettsimonsjafreck
authored andcommitted
Fix: list_applications throwing error (#692)
* Fixed Client.cluster.list_applications function to return [aztk.models.Task] since it was previously throwing errors. * Updated documentation for the base _list_applications function. * Updated to return a list of aztk.spark.models.Application instances instead of the raw tasks as would be expected by the name. Also updated documentation to reflect this change.
1 parent 1f6fc8b commit 72c7833

3 files changed

Lines changed: 24 additions & 19 deletions

File tree

aztk/spark/client/base/helpers/list_applications.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@
22
from azure.batch.models import BatchErrorException
33

44
from aztk import error
5-
from aztk.spark import models
5+
from aztk.spark.models import Application, SchedulingTarget
66
from aztk.utils import helpers
77

88

9-
def _list_applications(core_operations, id):
10-
# info about the app
11-
scheduling_target = core_operations.get_cluster_configuration(id).scheduling_target
12-
if scheduling_target is not models.SchedulingTarget.Any:
13-
return models.Application(core_operations.list_applications(id))
14-
15-
recent_run_job = core_operations.get_recent_job(id)
16-
return core_operations.list_batch_tasks(id=recent_run_job.id)
17-
18-
19-
def list_applications(core_operations, id):
9+
def list_applications(core_operations, cluster_id):
2010
try:
21-
return models.Application(_list_applications(core_operations, id))
11+
scheduling_target = core_operations.get_cluster_configuration(cluster_id).scheduling_target
12+
if scheduling_target is not SchedulingTarget.Any:
13+
tasks = core_operations.list_task_table_entries(cluster_id)
14+
else:
15+
tasks = core_operations.list_batch_tasks(cluster_id)
16+
return [Application(task) for task in tasks]
2217
except BatchErrorException as e:
2318
raise error.AztkError(helpers.format_batch_exception(e))

aztk/spark/client/base/operations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,13 @@ def _generate_application_task(self, core_base_operations, container_id, applica
7272
return generate_application_task.generate_application_task(core_base_operations, container_id, application,
7373
remote)
7474

75-
def list_applications(self, id):
76-
"""Get information on a submitted application
75+
def _list_applications(self, core_base_operations, id):
76+
"""Get information on tasks submitted to a cluster
7777
7878
Args:
79-
id (:obj:`str`): the name of the job the application was submitted to
80-
application_name (:obj:`str`): the name of the application to get
79+
id (:obj:`str`): the name of the cluster the tasks belong to
8180
8281
Returns:
83-
:obj:`aztk.spark.models.Application`: object representing that state and output of an application
82+
:obj:`[aztk.spark.models.Application]`: list of aztk applications
8483
"""
85-
return list_applications.list_applications(self, id)
84+
return list_applications.list_applications(core_base_operations, id)

aztk/spark/client/cluster/operations.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ def get_application_state(self, id: str, application_name: str):
117117
"""
118118
return get_application_state.get_application_state(self._core_cluster_operations, id, application_name)
119119

120+
def list_applications(self, id: str):
121+
"""Get all tasks that have been submitted to the cluster
122+
123+
Args:
124+
id (:obj:`str`): the name of the cluster the tasks belong to
125+
126+
Returns:
127+
:obj:`[aztk.spark.models.Application]`: list of aztk applications
128+
"""
129+
return self._list_applications(self._core_cluster_operations, id)
130+
120131
def run(self, id: str, command: str, host=False, internal: bool = False, timeout=None):
121132
"""Run a bash command on every node in the cluster
122133

0 commit comments

Comments
 (0)