Repository navigation
fix: 復元後マジックコマンドのみ実行→shutdown時のKeyErrorを修正 (#26) - #43
Merged
Merged
Conversation
チェックポイント復元直後は fingerprint_dict が空になる。マジックコマンド (%whos 等)は record_event をスキップするため空のまま埋まらず、その状態で checkpoint() を実行すると fingerprint_dict[変数名] への存在チェックなしの アクセスで KeyError が発生していた(アクティブ変数が2個以上で再現)。 - load_checkpoint: 復元した変数の fingerprint を再構築しておく(根本対応) - checkpoint(): overlapping 判定で fingerprint_dict の存在チェックを追加 - checkpoint(): user_ns に無いアクティブ変数はサイズ∞扱いでスキップ(防御) Closes #26 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Issue #26 のチェックポイント保存時
KeyErrorを修正します。症状
%whosなどマジックコマンドのみ実行このとき保存処理で
KeyError(例:KeyError: 'datetime')が発生していた。アクティブ変数が2個以上のとき再現する(1個だとcheckpoint.pyの二重ループでactive_vs1 != active_vs2が常に偽になり、該当アクセスが評価されないため出ない)。原因
復元直後は
fingerprint_dict(変数の指紋)が空。マジックコマンドはrecord_eventをスキップするため空のまま埋まらず、その状態でcheckpoint()がfingerprint_dict[変数名]に存在チェックなしでアクセスして落ちる。修正
elastic_notebook.pyload_checkpoint(根本対応 / 解決方法2): 復元した変数の fingerprint を再構築しておき、以降のcheckpoint()/record_event()が空 dict を踏まないようにする。checkpoint.pyoverlapping 判定(防御 / 解決方法1):fingerprint_dictの存在チェックを追加しKeyErrorを回避。checkpoint.pyサイズ計測ループ(防御):user_nsに存在しないアクティブ変数はサイズ∞(マイグレート対象外)扱いでスキップ。検証
datetime+ 他)でError saving checkpoint: 'datetime'を Docker(公開イメージ相当)で再現。補足(別件)
別途報告のある「再起動後 Run All がセル1で止まる/2回目で通る」現象は、本修正の対象外です。あちらは JupyterLab の再起動時 iopub(PUB/SUB) 再接続レースで、素の
ipykernelでも発生するため本 PR では扱いません。Closes #26
🤖 Generated with Claude Code