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.
Files changed (23) hide show
  1. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/PKG-INFO +1 -1
  2. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/__init__.py +1 -1
  3. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/core.py +6 -3
  4. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/manager.py +3 -2
  5. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/PKG-INFO +1 -1
  6. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/LICENSE +0 -0
  7. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/compare.py +0 -0
  8. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/formats.py +0 -0
  9. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/info.py +0 -0
  10. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/jupyter_utils.py +0 -0
  11. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/serializers.py +0 -0
  12. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/tracer.py +0 -0
  13. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/utils.py +0 -0
  14. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/version_control.py +0 -0
  15. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer.py +0 -0
  16. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer_arrays.py +0 -0
  17. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith/visualizer_generic.py +0 -0
  18. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/SOURCES.txt +0 -0
  19. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/dependency_links.txt +0 -0
  20. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/requires.txt +0 -0
  21. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/SessionSmith.egg-info/top_level.txt +0 -0
  22. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/setup.cfg +0 -0
  23. {sessionsmith-0.1.3 → sessionsmith-0.1.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SessionSmith
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Simple session save/load utility for Jupyter notebooks using pickle
5
5
  Home-page: https://github.com/yut0takagi/SessionSmith
6
6
  Author: YutoTAKAGI
@@ -14,7 +14,7 @@ from .serializers import CustomSerializer
14
14
  from .tracer import AlgorithmTracer
15
15
  from .visualizer import visualize_algorithm_trace, print_trace_summary
16
16
 
17
- __version__ = "0.1.3"
17
+ __version__ = "0.1.4"
18
18
 
19
19
  __all__ = [
20
20
  "save_session",
@@ -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
- result = caller_frame.f_globals.copy()
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
- globals_dict = _get_globals_dict(globals_dict)
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
- result = caller_frame.f_globals.copy()
81
+ # SessionManagerは変数を変更する必要があるため、参照を返す(コピーではない)
82
+ result = caller_frame.f_globals
82
83
  del frame
83
84
  return result
84
85
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SessionSmith
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: Simple session save/load utility for Jupyter notebooks using pickle
5
5
  Home-page: https://github.com/yut0takagi/SessionSmith
6
6
  Author: YutoTAKAGI
File without changes
File without changes
File without changes