Repository navigation
refactor/fix: Phase 6 — デッドコード削除と残りの提案実装 (Q1①/D-4/D-11後半/D-12/D-13/D-14) - #42
Merged
Merged
Conversation
リポジトリ内で参照ゼロのコードを削除(挙動同一): - core/io/pickle.py 全体(is_picklable 系) - core/common/profile_graph_size.py 全体("For experiments only") - checkpoint_file.py の to_json_str/from_json + 未使用の import json と KEY_* 定数 (DependencyGraph はJSON化不能で実際には動作しなかった) - command.py の PostInstallCommand と setuptools のランタイムimport (setup.py時代の遺物。CLIが毎回setuptoolsをimportする無駄を解消) - object_hash.py の到達不能な isclass(obj) 分岐を簡約(先行のisclassで処理済み) 検証: flake8 0, mypy 0(33 files), pytest 51 passed, import/uv build OK。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
到達不能だった分岐を整理し、__dict__ を持つカスタムクラスインスタンスは 属性(値)のメモリも再帰計測するよう修正。従来は浅い sys.getsizeof のみで カスタムオブジェクトのサイズを過小評価していた。サイズ推定はオプティマイザの migrate/recompute 判断の入力になるため、チェックポイント構成が変わり得る。 test_profile_variable_size.py を追加。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
従来 read 計測は open→close するだけで1バイトも読んでおらず、read速度が 実質ゼロ計測だった。in_file.read() を計測区間に追加。migration_speed_bps が 変わるため、オプティマイザの判断が変化し得る。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
active VS が fingerprint_dict に無い場合の KeyError を防ぐため、サイズ計測側 (61行)と同様の in チェックを追加。test_checkpoint_func.py で fingerprint 欠落 時も KeyError を出さず checkpoint が成功することを確認。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
生成失敗時 self.elastic_notebook を None に保ち、do_execute/do_shutdown/ __del_from_user_ns_hidden で None ガード。従来は失敗後に全セルで AttributeError を吐き続けたが、「追跡なしの素のカーネル」として動作継続する(エラーはログのみ、 既存の握り潰し方針を踏襲)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e." (D-14) 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.
概要
指示書 §Phase 6 の項目を実装。**Q1承認済みのデッドコード削除(挙動同一)**と、**提案だった残りの修正(一部は挙動変更)**を含む。
① デッドコード削除(挙動同一・Q1承認済み)
core/io/pickle.py全体、core/common/profile_graph_size.py全体を削除checkpoint_file.pyのto_json_str/from_json+ 未使用import json/KEY_*定数を削除(JSON化不能で実際動かなかった)command.pyのPostInstallCommand+setuptoolsランタイムimportを削除object_hash.pyの到達不能isclass(obj)分岐を簡約② 残り提案の実装
profile_variable_sizeがカスタムクラスの__dict__を再帰計測(従来は浅い getsizeof のみ)read()(従来は open→close のみ)checkpointの overlapping 判定に fingerprint 存在ガード追加(KeyError防止)ElasticNotebook生成失敗時のフェイルセーフ(None ガードで素のカーネルとして継続)テスト
test_profile_variable_size.py(D-4: 属性が計上される)、test_checkpoint_func.py(D-12: fingerprint欠落でもKeyError出ず成功)検証結果
uv build実機確認(再実行・全パス)
JPY_SESSION_NAME固定のヘッドレス e2e で x/a/y 復元・%who 表示・ログ ERROR 0件、失敗セル1/0非記録を再確認。Phase 6 の変更で回帰なし。挙動差分の宣言
🤖 Generated with Claude Code