Skip to content

Commit f482e09

Browse files
fix: extend atomic writes to parser, reporter, and experiment outputs
Applies atomic_write_json to the remaining final pipeline outputs that were still using plain write_json: - core/reporter.py: pipeline_output.json (final report, ensure_ascii=False) - core/parser_adapter.py: dataset.json and analyzer_output.json (parse outputs consumed by subsequent expensive LLM stages) - experiment.py: experiment results (legacy direct-run path) Skipped: checkpoint files (designed for incremental writes), scanner intermediate state, and the diff_filter sidecar report (cheap to regenerate, not consumed downstream).
1 parent eefafbd commit f482e09

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

libs/openant-core/core/parser_adapter.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from pathlib import Path
1919

2020
from core.schemas import ParseResult
21+
from utilities.atomic_io import atomic_write_json
2122
from utilities.file_io import open_utf8, read_json, write_json
2223

2324
# Root of openant-core (where parsers/ lives)
@@ -173,7 +174,7 @@ def _maybe_apply_diff_filter(
173174

174175
stats = apply_diff_filter(units, manifest)
175176

176-
write_json(result.dataset_path, dataset)
177+
atomic_write_json(result.dataset_path, dataset)
177178
# Expose stats on the ParseResult via a side-channel file; the parse
178179
# step_context reads this when assembling parse.report.json.
179180
diff_report_path = os.path.join(output_dir, "diff_filter.report.json")
@@ -363,8 +364,8 @@ def _parse_python(repo_path: str, output_dir: str, processing_level: str, skip_t
363364
dataset = _apply_reachability_filter(dataset, output_dir, processing_level)
364365

365366
# Write outputs
366-
write_json(dataset_path, dataset)
367-
write_json(analyzer_output_path, analyzer_output)
367+
atomic_write_json(dataset_path, dataset)
368+
atomic_write_json(analyzer_output_path, analyzer_output)
368369
units_count = len(dataset.get("units", []))
369370
print(f" Python parser complete: {units_count} units", file=sys.stderr)
370371

libs/openant-core/core/reporter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pathlib import Path
2020

2121
from core.schemas import ReportResult
22+
from utilities.atomic_io import atomic_write_json
2223
from utilities.file_io import open_utf8, read_json, write_json
2324

2425
# Root of openant-core
@@ -367,7 +368,7 @@ def build_pipeline_output(
367368
print(_banner, file=sys.stderr)
368369

369370
os.makedirs(os.path.dirname(os.path.abspath(output_path)), exist_ok=True)
370-
write_json(output_path, pipeline_output, ensure_ascii=False)
371+
atomic_write_json(output_path, pipeline_output, ensure_ascii=False)
371372
print(f" pipeline_output.json: {len(findings_data)} findings", file=sys.stderr)
372373
print(f" Written to {output_path}", file=sys.stderr)
373374

libs/openant-core/experiment.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from pathlib import Path
3636

3737
from utilities.llm_client import AnthropicClient, get_global_tracker
38+
from utilities.atomic_io import atomic_write_json
3839
from utilities.file_io import read_json, write_json
3940
from prompts.prompt_selector import get_analysis_prompt
4041
from prompts.vulnerability_analysis import get_system_prompt as get_stage1_system_prompt
@@ -1033,7 +1034,7 @@ def main():
10331034
suffix = "" if args.no_enhanced else "_enhanced"
10341035
output_path = f"experiment_{args.dataset}_{args.model}{suffix}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
10351036

1036-
write_json(output_path, experiment)
1037+
atomic_write_json(output_path, experiment)
10371038
print()
10381039
print(f"Results saved to: {output_path}")
10391040

0 commit comments

Comments
 (0)