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

Commit c91806e

Browse files
committed
Only warn about scheduling once in verbose job output
1 parent 782c320 commit c91806e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

cli/utils.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ def print_job(client, job: models.Job, apps: bool):
274274
if apps:
275275
print_applications(applications)
276276
log.info("")
277+
else:
278+
warn_scheduling(applications)
277279

278280

279281
def node_state_count(cluster: models.Cluster):
@@ -303,12 +305,9 @@ def application_summary(applications: Dict[str, aztk.spark.models.Application]):
303305
for state in batch_models.TaskState:
304306
states[state.name] = 0
305307

306-
warn_scheduling = False
307-
308308
for name, application in applications.items():
309309
if application is None:
310310
states["scheduling"] += 1
311-
warn_scheduling = True
312311
else:
313312
states[application.state] += 1
314313

@@ -319,16 +318,23 @@ def application_summary(applications: Dict[str, aztk.spark.models.Application]):
319318
if states[state] > 0:
320319
log.info(print_format.format(state + ":", states[state]))
321320

322-
if warn_scheduling:
321+
322+
def warn_scheduling(applications: Dict[str, aztk.spark.models.Application]):
323+
warn = False
324+
for application in applications.values():
325+
if application is None:
326+
warn = True
327+
break
328+
if warn:
323329
log.warning("\nNo Spark applications will be scheduled until the master is selected.")
324330

331+
325332
def print_applications(applications: Dict[str, aztk.spark.models.Application]):
326333
print_format = '{:<36}| {:<15}| {:<16} | {:^9} |'
327334
print_format_underline = '{:-<36}|{:-<16}|{:-<18}|{:-<11}|'
328335
log.info(print_format.format("Applications", "State", "Transition Time", "Exit Code"))
329336
log.info(print_format_underline.format('', '', '', ''))
330337

331-
warn_scheduling = False
332338
for name, application in applications.items():
333339
if application is None:
334340
log.info(
@@ -339,7 +345,6 @@ def print_applications(applications: Dict[str, aztk.spark.models.Application]):
339345
"-"
340346
)
341347
)
342-
warn_scheduling = True
343348
else:
344349
log.info(
345350
print_format.format(
@@ -349,8 +354,7 @@ def print_applications(applications: Dict[str, aztk.spark.models.Application]):
349354
application.exit_code if application.exit_code is not None else "-"
350355
)
351356
)
352-
if warn_scheduling:
353-
log.warning("\nNo Spark applications will be scheduled until the master is selected.")
357+
warn_scheduling(applications)
354358

355359
def print_application(application: models.Application):
356360
print_format = '{:<30}| {:<15}'

0 commit comments

Comments
 (0)