Skip to content

Commit

Permalink
replace production code asserts w exception raises
Browse files Browse the repository at this point in the history
  • Loading branch information
d33bs committed Dec 16, 2024
1 parent ac0a6c1 commit f3ad866
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions libs/manubot_ai_editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def __init__(self, content_dir: str | Path, config_dir: str | Path = None):
self.config_dir = Path(config_dir) if config_dir is not None else None

metadata_file = self.content_dir / "metadata.yaml"
assert metadata_file.exists(), f"Metadata file {metadata_file} does not exist"
if not metadata_file.exists():
raise FileNotFoundError(f"Metadata file {metadata_file} does not exist")
self.title = get_yaml_field(metadata_file, "title")
self.keywords = get_yaml_field(metadata_file, "keywords")

Expand Down Expand Up @@ -270,10 +271,12 @@ def revise_file(
resolved_prompt (str, optional): A prompt resolved via ai-revision prompt config files, which overrides any custom or section-derived prompts; None if unavailable.
"""
input_filepath = self.content_dir / input_filename
assert input_filepath.exists(), f"Input file {input_filepath} does not exist"
if not input_filepath.exists():
raise FileNotFoundError(f"Input file {input_filepath} does not exist")

output_dir = Path(output_dir).resolve()
assert output_dir.exists(), f"Output directory {output_dir} does not exist"
if not output_dir.exists():
raise FileNotFoundError(f"Output directory {output_dir} does not exist")
output_filepath = output_dir / input_filename

# infer section name from input filename if not provided
Expand Down

0 comments on commit f3ad866

Please sign in to comment.