SessionSmith 0.1.3__tar.gz → 0.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/PKG-INFO +1 -1
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/__init__.py +1 -1
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/core.py +6 -3
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/manager.py +3 -2
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/PKG-INFO +1 -1
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/LICENSE +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/compare.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/formats.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/info.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/jupyter_utils.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/serializers.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/tracer.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/utils.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/version_control.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer_arrays.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer_generic.py +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/SOURCES.txt +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/dependency_links.txt +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/requires.txt +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/top_level.txt +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/setup.cfg +0 -0
- {sessionsmith-0.1.3 → sessionsmith-0.1.4}/setup.py +0 -0
|
@@ -101,13 +101,14 @@ def _validate_on_error_option(on_error: str) -> str:
|
|
|
101
101
|
return on_error
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
def _get_globals_dict(globals_dict: Optional[Dict[str, Any]], depth: int = 2) -> Dict[str, Any]:
|
|
104
|
+
def _get_globals_dict(globals_dict: Optional[Dict[str, Any]], depth: int = 2, copy: bool = True) -> Dict[str, Any]:
|
|
105
105
|
"""
|
|
106
106
|
グローバル変数辞書を取得します
|
|
107
107
|
|
|
108
108
|
Args:
|
|
109
109
|
globals_dict: グローバル変数辞書(Noneの場合は自動取得)
|
|
110
110
|
depth: 呼び出し元からのフレーム深度(デフォルトは2:_get_globals_dict -> save/load_session -> ユーザーコード)
|
|
111
|
+
copy: Trueの場合はコピーを返す(save_session用)、Falseの場合は参照を返す(load_session用)
|
|
111
112
|
|
|
112
113
|
Returns:
|
|
113
114
|
dict: グローバル変数辞書
|
|
@@ -129,7 +130,8 @@ def _get_globals_dict(globals_dict: Optional[Dict[str, Any]], depth: int = 2) ->
|
|
|
129
130
|
raise RuntimeError("Cannot access calling frame at specified depth")
|
|
130
131
|
caller_frame = caller_frame.f_back
|
|
131
132
|
|
|
132
|
-
|
|
133
|
+
# save_sessionはコピー(安全な読み取り)、load_sessionは参照(変更を反映)
|
|
134
|
+
result = caller_frame.f_globals.copy() if copy else caller_frame.f_globals
|
|
133
135
|
del frame
|
|
134
136
|
return result
|
|
135
137
|
except Exception as e:
|
|
@@ -334,7 +336,8 @@ def load_session(
|
|
|
334
336
|
if not file_path.is_file():
|
|
335
337
|
raise ValueError(f"'{file_path}' is not a file.")
|
|
336
338
|
|
|
337
|
-
|
|
339
|
+
# load_sessionでは元のグローバル変数を変更する必要があるため、copy=False
|
|
340
|
+
globals_dict = _get_globals_dict(globals_dict, copy=False)
|
|
338
341
|
|
|
339
342
|
if include is not None and not isinstance(include, list):
|
|
340
343
|
raise TypeError(f"include must be a list, got {type(include).__name__}")
|
|
@@ -59,7 +59,7 @@ class SessionManager:
|
|
|
59
59
|
depth: 呼び出し元からのフレーム深度(デフォルトは2:_get_globals_dict -> __init__ -> ユーザーコード)
|
|
60
60
|
|
|
61
61
|
Returns:
|
|
62
|
-
dict:
|
|
62
|
+
dict: グローバル変数辞書(参照、コピーではない)
|
|
63
63
|
"""
|
|
64
64
|
if globals_dict is not None:
|
|
65
65
|
if not isinstance(globals_dict, dict):
|
|
@@ -78,7 +78,8 @@ class SessionManager:
|
|
|
78
78
|
raise RuntimeError("Cannot access calling frame at specified depth")
|
|
79
79
|
caller_frame = caller_frame.f_back
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
# SessionManagerは変数を変更する必要があるため、参照を返す(コピーではない)
|
|
82
|
+
result = caller_frame.f_globals
|
|
82
83
|
del frame
|
|
83
84
|
return result
|
|
84
85
|
except Exception as e:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|