Skip to content

Commit cd93721

Browse files
fix: simplify default filename to avoid redundant "output" prefix
When no input filename can be derived (e.g. raw markdown string), the auto-generated name is now {method}_output.json instead of the redundant output_{method}_output.json. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bf45581 commit cd93721

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/landingai_ade/_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ def _save_response(
128128
save_path.write_text(result.to_json())
129129
else:
130130
save_path.mkdir(parents=True, exist_ok=True)
131-
output_path = save_path / f"{filename}_{method_name}_output.json"
131+
if filename == "output":
132+
output_path = save_path / f"{method_name}_output.json"
133+
else:
134+
output_path = save_path / f"{filename}_{method_name}_output.json"
132135
output_path.write_text(result.to_json())
133136
except OSError as exc:
134137
raise LandingAiadeError(f"Failed to save {method_name} response to {save_to}: {exc}") from exc

tests/test_save_to.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ def test_accepts_string_path(self, tmp_path: Path) -> None:
160160
expected_file = tmp_path / "strpath_split_output.json"
161161
assert expected_file.exists()
162162

163+
def test_output_filename_skips_redundant_prefix(self, tmp_path: Path) -> None:
164+
"""Test that 'output' stem produces '{method}_output.json', not 'output_{method}_output.json'."""
165+
mock_result = MagicMock()
166+
mock_result.to_json.return_value = "{}"
167+
168+
for method in ["parse", "extract", "split"]:
169+
_save_response(tmp_path, "output", method, mock_result)
170+
expected = tmp_path / f"{method}_output.json"
171+
assert expected.exists(), f"Expected {expected} to exist"
172+
redundant = tmp_path / f"output_{method}_output.json"
173+
assert not redundant.exists(), f"Redundant {redundant} should NOT exist"
174+
163175
def test_full_json_path_saves_to_exact_location(self, tmp_path: Path) -> None:
164176
"""Test that a path ending in .json is used as the exact output file."""
165177
output_file = tmp_path / "custom_name.json"

0 commit comments

Comments
 (0)