Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.
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
2 changes: 1 addition & 1 deletion src/instructlab/schema/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,6 @@ def parse(self, path: str | pathlib.Path) -> Taxonomy:

self._schema_validate(text=text, taxonomy=taxonomy)
except Exception as e:
raise TaxonomyReadingException from e
raise TaxonomyReadingException(str(e)) from e

return taxonomy
16 changes: 16 additions & 0 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ def test_parser_init_fails_when_schema_version_not_found(self, mock_schema_versi
assert_that(str(exc_info.value)).matches(r'Schema base ".*" does not contain any schema versions')


class TestTaxonomyReadingExceptionDisplay:
def test_invalid_yaml_with_taxonomy_reading_exception(self, testdata: pathlib.Path) -> None:
test_yaml = "compositional_skills/invalid_yaml_1/qna.yaml"
rel_path = testdata.joinpath(test_yaml)
parser = TaxonomyParser(schema_version=2)

with pytest.raises(TaxonomyReadingException) as exc_info:
parser.parse(rel_path)

exception = exc_info.value
assert_that(exception).is_instance_of(TaxonomyReadingException)
assert_that(str(exception)).contains("while scanning a simple key")
assert_that(str(exception)).contains("seed_examples:xx")
assert_that(str(exception.__cause__)).contains("could not find expected ':'")


class TestParsingLogging:
def message_filter(self, regex: str) -> Callable[[logging.LogRecord], bool]:
pattern = re.compile(regex)
Expand Down
18 changes: 18 additions & 0 deletions tests/testdata/compositional_skills/invalid_yaml_1/qna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: Apache-2.0

createdby: invalid_key_1
version: 2
seed_examples:xx
- question: What is this skill about?
answer: It's a skill that makes the tests more skillful
- answer: "answer2"
question: "question2"
- answer: "answer6"
question: "This is for a unit test and has a line with 124 characters! It is too long for the default rules but not too long for the customer rules!"
- answer: "answer3"
question: "question3"
- answer: "answer4"
question: "question4"
- answer: "answer5"
question: "question5"
task_description: For TaxonomyReadingException test
Loading