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

Fix: list_applications throwing error #692

Merged
merged 3 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions aztk/spark/client/base/helpers/list_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@
from azure.batch.models import BatchErrorException

from aztk import error
from aztk.spark import models
from aztk.spark.models import Application, SchedulingTarget
from aztk.utils import helpers


def _list_applications(core_operations, id):
# info about the app
scheduling_target = core_operations.get_cluster_configuration(id).scheduling_target
if scheduling_target is not models.SchedulingTarget.Any:
return models.Application(core_operations.list_applications(id))

recent_run_job = core_operations.get_recent_job(id)
return core_operations.list_batch_tasks(id=recent_run_job.id)


def list_applications(core_operations, id):
def list_applications(core_operations, cluster_id):
try:
return models.Application(_list_applications(core_operations, id))
scheduling_target = core_operations.get_cluster_configuration(cluster_id).scheduling_target
if scheduling_target is not SchedulingTarget.Any:
tasks = core_operations.list_task_table_entries(cluster_id)
else:
tasks = core_operations.list_batch_tasks(cluster_id)
return [Application(task) for task in tasks]
except BatchErrorException as e:
raise error.AztkError(helpers.format_batch_exception(e))
11 changes: 5 additions & 6 deletions aztk/spark/client/base/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,13 @@ def _generate_application_task(self, core_base_operations, container_id, applica
return generate_application_task.generate_application_task(core_base_operations, container_id, application,
remote)

def list_applications(self, id):
"""Get information on a submitted application
def _list_applications(self, core_base_operations, id):
"""Get information on tasks submitted to a cluster

Args:
id (:obj:`str`): the name of the job the application was submitted to
application_name (:obj:`str`): the name of the application to get
id (:obj:`str`): the name of the cluster the tasks belong to

Returns:
:obj:`aztk.spark.models.Application`: object representing that state and output of an application
:obj:`[aztk.spark.models.Application]`: list of aztk applications
"""
return list_applications.list_applications(self, id)
return list_applications.list_applications(core_base_operations, id)
11 changes: 11 additions & 0 deletions aztk/spark/client/cluster/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ def get_application_state(self, id: str, application_name: str):
"""
return get_application_state.get_application_state(self._core_cluster_operations, id, application_name)

def list_applications(self, id: str):
"""Get all tasks that have been submitted to the cluster

Args:
id (:obj:`str`): the name of the cluster the tasks belong to

Returns:
:obj:`[aztk.spark.models.Application]`: list of aztk applications
"""
return self._list_applications(self._core_cluster_operations, id)

def run(self, id: str, command: str, host=False, internal: bool = False, timeout=None):
"""Run a bash command on every node in the cluster

Expand Down