Skip to content

Commit e248e40

Browse files
authored
fix: Enhance parser IlabConfigShow (#4426)
- to skip irrelevant lines Signed-off-by: jiazhang <[email protected]> rh-pre-commit.version: 2.3.1 rh-pre-commit.check-secrets: ENABLED
1 parent d7292d4 commit e248e40

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

insights/parsers/ilab.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
IlabConfigShow - command ``/usr/bin/ilab config show``
1010
------------------------------------------------------
1111
"""
12-
from insights import YAMLParser
13-
from insights.core import CommandParser
12+
from insights.core import CommandParser, YAMLParser
1413
from insights.core.plugins import parser
1514
from insights.core.exceptions import SkipComponent, ParseException
1615
from insights.specs import Specs
@@ -70,6 +69,8 @@ class IlabConfigShow(CommandParser, YAMLParser):
7069
7170
Sample output from ``/usr/bin/ilab config show``::
7271
72+
time="2025-04-15T08:23:44Z" level=warning msg="The input device is not a TTY. The --tty and --interactive flags might not work properly"
73+
# Chat configuration section.
7374
chat:
7475
context: default
7576
logs_dir: /root/.local/share/instructlab/chatlogs
@@ -99,4 +100,4 @@ class IlabConfigShow(CommandParser, YAMLParser):
99100
Attributes:
100101
data(dict): The ilab config information
101102
"""
102-
pass
103+
ignore_lines = ['time=']

insights/tests/parsers/test_ilab.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@
3838
ILAB_MODULE_LIST_EMPTY = ""
3939

4040
ILAB_CONFIG_SHOW = """
41+
time="2025-04-15T08:23:44Z" level=warning msg="The input device is not a TTY. The --tty and --interactive flags might not work properly"
42+
# Chat configuration section.
4143
chat:
44+
# Predefined setting or environment that influences the behavior and responses of
45+
# the chat assistant. Each context is associated with a specific prompt that
46+
# guides the assistant on how to respond to user inputs. Available contexts:
4247
context: default
4348
logs_dir: /root/.local/share/instructlab/chatlogs
4449
max_tokens:
@@ -60,6 +65,7 @@
6065
""".strip()
6166

6267
ILAB_CONFIG_SHOW_ERROR = ILAB_MODULE_LIST_ERROR
68+
ILAB_CONFIG_SHOW_EMPTY = ILAB_MODULE_LIST_EMPTY
6369

6470

6571
def test_ilab_model_list():
@@ -88,6 +94,9 @@ def test_ilab_config_show():
8894
with pytest.raises(ParseException):
8995
IlabConfigShow(context_wrap(ILAB_CONFIG_SHOW_ERROR))
9096

97+
with pytest.raises(SkipComponent):
98+
IlabModuleList(context_wrap(ILAB_CONFIG_SHOW_EMPTY))
99+
91100

92101
def test_ilab_doc_examples():
93102
env = {

0 commit comments

Comments
 (0)