Skip to content

Commit 513db23

Browse files
authored
Fix cn_metrics.py not to fail on empty yaml input (#342)
* Fix cn_metrics.py not to fail if there are no nodes in the yaml output. Signed-off-by: Greg Becker <[email protected]> * Fix list item test. Signed-off-by: Greg Becker <[email protected]>
1 parent 336b9f9 commit 513db23

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/scripts/cn_metrics.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import json
1313
import pathlib
1414
import signal
15-
from typing import Any, Dict, OrderedDict, Optional
15+
from typing import Any, Optional
16+
17+
try:
18+
from typing import OrderedDict
19+
except ImportError:
20+
from typing import Dict as OrderedDict
1621

1722
desc = (
1823
"print cn tree shape\n\n"
@@ -69,6 +74,9 @@ def full_tree(ybuf: Optional[OrderedDict[str, Any]], opt):
6974
if ybuf["info"]["open"] == False:
7075
return
7176

77+
if not ybuf.get("nodes", []):
78+
return
79+
7280
# Print info for each node in the kvs.
7381
#
7482
for node in ybuf["nodes"]:

0 commit comments

Comments
 (0)