Skip to content

Separate CalledProcessError and FileNotFoundError exceptions #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 8 additions & 4 deletions src/instructlab/schema/taxonomy.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,15 @@ def _schema_validate(self, text: str, taxonomy: Taxonomy) -> None:
yq_expression = f"{yaml_path} | line"
line = subprocess.check_output(["yq", yq_expression], input=text, text=True)
line = line.strip() if line else 1
except (subprocess.CalledProcessError, FileNotFoundError) as e:
if isinstance(e, FileNotFoundError):
self.yq_available = False
except subprocess.CalledProcessError as e_yq:
logger.warning(
"could not run yq command",
f"Failed to validate file {taxonomy.path}, error: {e_yq}\n"
f"Failed command: yq \"{yq_expression}\" {taxonomy.path}"
)
except FileNotFoundError as e:
self.yq_available = False
logger.warning(
"Missing yq command, could not run yq command",
exc_info=True,
)
if validation_error.validator == "minItems":
Expand Down