fix(automl): safely append training logs - #1615
林SO (Linxiushen) wants to merge 2 commits into
Conversation
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review of the complete PR: changes are required.
flaml/automl/training_log.py:74: appending after a valid final JSON record without a trailing newline concatenates records as}{and corrupts all subsequent log readers. Detect an unterminated nonempty tail and add a newline before writing; test record and checkpoint tails.flaml/automl/training_log.py:68-74: concurrent appenders scan and allocate IDs without a lock, so both can choose the same next ID. Hold a cross-process lock from ID discovery through writer close and add a two-writer uniqueness regression.
Posted by thinkall-agent-auto-reviewer
|
Addressed both findings in the follow-up commit:
The original follow-up regressions fail on Linux with corrupt JSON and duplicate IDs ( The PR description now reflects the locking behavior, expanded validation, and remaining validation limits. Ready for another review. |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review of the complete current PR: approved.
The writer lock now covers ID discovery through file close, preventing duplicate IDs across concurrent writers. Appends safely insert separators after valid unterminated record or checkpoint tails. Regression and stress coverage exercises missing/existing logs, legacy sparse IDs, LF/CRLF/CR/no terminator, threads/processes, malformed files, failed opens, crash recovery, and retrain/log readers. No blocking issues found.
Posted by thinkall-agent-auto-reviewer
Why are these changes needed?
Appending to an AutoML training log restarts
record_idat zero, so the appended run's checkpoint can reconstruct an older configuration. Resume IDs after the greatest existing ID, skipping checkpoints and retaining each run's own best-loss state. Existing duplicate IDs are not rewritten.The writer also handles an existing final record or checkpoint without a trailing newline, and serializes writers sharing a log with a cross-process sidecar lock. Both normal and append writers acquire the lock before opening or scanning the log and keep it through flush and close.
filelockis added to the AutoML and test extras; core-only imports remain supported. Theappend_logdocs explain that waiting for another writer counts towardtime_budget, and concurrent runs should use distinct log files.Validation:
16bc42e071b3320625dc8358f52e241a88de3b19.[0, 0]and[0, 1, 1].AutoML.get_estimator_from_logreconstruction, sparse/existing duplicate IDs, line endings, real concurrent writers, independent files, and lock release on failure.CreateProcessreturningWinError 5, so the four multiprocessing cases were excluded from the final Windows runs; their passing concurrency results are from Linux.filelockinstalled.The existing log is read once when opening for append. Malformed logs fail without appending content. Full AutoML, forecasting, and Spark suites were not run. An additional small random-forest
AutoML.fitsmoke reaches an existing_t1attribute error before writing any records, both with the original training-log module and with this change; no successful fit smoke is claimed.Checks