Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Open
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
12 changes: 12 additions & 0 deletions src/instructlab/schema/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ def _yamllint(self, text: str, taxonomy: Taxonomy) -> None:
line=line,
col=col,
)
elif line.startswith("invalid config:"):
taxonomy.error(
"yamllint_config: %s",
line,
)
return
elif line.startswith("Traceback"):
taxonomy.error(
'yamllint_config: invalid config: "%s"',
self.yamllint_config,
)
return

def _schema_validate(self, text: str, taxonomy: Taxonomy) -> None:
retrieve = functools.partial(_retrieve, f"v{taxonomy.version}")
Expand Down
42 changes: 41 additions & 1 deletion tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_invalid(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path)
filter=self.message_filter(r"created_by.*required property"),
).contains_only(logging.ERROR)

def test_invalid_yamlint_strict(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
def test_invalid_yamllint_strict(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
yamllint_config = "{extends: relaxed, rules: {line-length: {max: 120}}}"
test_yaml = "compositional_skills/invalid_yaml/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
Expand Down Expand Up @@ -107,6 +107,46 @@ def test_invalid_custom_yaml_config(self, caplog: pytest.LogCaptureFixture, test
filter=self.message_filter(r"created_by.*required property"),
).contains_only(logging.ERROR)

def test_empty_yamllint_config(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
yamllint_config = ""
test_yaml = "compositional_skills/skill_valid/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
parser = TaxonomyParser(schema_version=0, message_format="logging", yamllint_config=yamllint_config)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_equal_to(1)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
assert_that(caplog.records).extracting(
"message",
filter=self.message_filter(f"{re.escape(test_yaml)}:"),
).is_length(len(caplog.records))
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"invalid config:"),
).contains_only(logging.ERROR)

def test_invalid_yamllint_config(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
yamllint_config = "a=b"
test_yaml = "compositional_skills/skill_valid/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
parser = TaxonomyParser(schema_version=0, message_format="logging", yamllint_config=yamllint_config)
taxonomy = parser.parse(rel_path)

assert_that(taxonomy.warnings).is_zero()
assert_that(taxonomy.errors).is_equal_to(1)
assert_that(taxonomy.path.as_posix()).is_equal_to(test_yaml)
assert_that(taxonomy.rel_path).is_equal_to(rel_path)
assert_that(caplog.records).extracting(
"message",
filter=self.message_filter(f"{re.escape(test_yaml)}:"),
).is_length(len(caplog.records))
assert_that(caplog.records).extracting(
"levelno",
filter=self.message_filter(r"invalid config:"),
).contains_only(logging.ERROR)

def test_incomplete_skill(self, caplog: pytest.LogCaptureFixture, testdata: pathlib.Path) -> None:
test_yaml = "compositional_skills/skill_incomplete/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
Expand Down