elastic-kernel 0.0.28__tar.gz → 0.0.30__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.
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/MANIFEST.in +1 -1
- {elastic_kernel-0.0.28/elastic_kernel.egg-info → elastic_kernel-0.0.30}/PKG-INFO +21 -7
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/README.md +20 -6
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel/command.py +0 -9
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel/kernel.py +36 -42
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30/elastic_kernel.egg-info}/PKG-INFO +21 -7
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel.egg-info/SOURCES.txt +17 -4
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel.egg-info/top_level.txt +0 -2
- elastic_kernel-0.0.30/elastic_notebook/LICENSE +201 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/algorithm/optimizer_exact.py +9 -5
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/algorithm/selector.py +9 -19
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/common/checkpoint_file.py +1 -39
- elastic_kernel-0.0.30/elastic_notebook/core/common/logging_setup.py +70 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/common/profile_migration_speed.py +8 -4
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/common/profile_variable_size.py +9 -10
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/graph/cell_execution.py +39 -42
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/graph/graph.py +77 -78
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/graph/variable_snapshot.py +1 -1
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/io/migrate.py +3 -3
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/io/recover.py +5 -12
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/mutation/object_hash.py +3 -1
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/checkpoint.py +18 -3
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/find_input_vars.py +120 -120
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/update_graph.py +49 -49
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/elastic_notebook.py +27 -85
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/pyproject.toml +13 -1
- elastic_kernel-0.0.30/tests/test_checkpoint_file.py +43 -0
- elastic_kernel-0.0.30/tests/test_checkpoint_func.py +32 -0
- elastic_kernel-0.0.30/tests/test_find_input_vars.py +73 -0
- elastic_kernel-0.0.30/tests/test_find_output_vars.py +31 -0
- elastic_kernel-0.0.30/tests/test_graph.py +59 -0
- elastic_kernel-0.0.30/tests/test_id_graph.py +73 -0
- elastic_kernel-0.0.30/tests/test_integration.py +42 -0
- elastic_kernel-0.0.30/tests/test_logging_setup.py +57 -0
- elastic_kernel-0.0.30/tests/test_migrate_resume.py +119 -0
- elastic_kernel-0.0.30/tests/test_object_hash.py +77 -0
- elastic_kernel-0.0.30/tests/test_optimizer.py +40 -0
- elastic_kernel-0.0.30/tests/test_profile_migration_speed.py +31 -0
- elastic_kernel-0.0.30/tests/test_profile_variable_size.py +33 -0
- elastic_kernel-0.0.30/tests/test_skip_record.py +35 -0
- elastic_kernel-0.0.28/elastic_notebook/algorithm/baseline.py +0 -34
- elastic_kernel-0.0.28/elastic_notebook/core/common/profile_graph_size.py +0 -42
- elastic_kernel-0.0.28/elastic_notebook/core/io/pickle.py +0 -75
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/LICENSE +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel/kernel.json +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel.egg-info/dependency_links.txt +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel.egg-info/entry_points.txt +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_kernel.egg-info/requires.txt +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/algorithm/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/common/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/graph/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/io/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/io/adapter.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/io/filesystem_adapter.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/mutation/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/mutation/fingerprint.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/mutation/id_graph.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/__init__.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/find_output_vars.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/core/notebook/restore_notebook.py +0 -0
- {elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: elastic-kernel
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.30
|
|
4
4
|
Summary: An IPython Kernel that automatically saves and restores Jupyter Notebook execution states.
|
|
5
5
|
Author-email: ryutarom <m2002r1028@icloud.com>
|
|
6
6
|
License: Apache License
|
|
@@ -249,12 +249,26 @@ ElasticKernel is a custom IPython kernel that **automatically checkpoints your n
|
|
|
249
249
|
|
|
250
250
|
> 🇯🇵 日本語版は [README.ja.md](README.ja.md) を参照してください。
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
## Demo
|
|
253
|
+
|
|
254
|
+
The same workflow in both clips: define a variable `a = 1`, then **restart the kernel**. The difference is what happens next.
|
|
255
|
+
|
|
256
|
+
<table>
|
|
257
|
+
<tr>
|
|
258
|
+
<th align="center">Standard kernel (<code>ipykernel</code>)</th>
|
|
259
|
+
<th align="center">ElasticKernel</th>
|
|
260
|
+
</tr>
|
|
261
|
+
<tr>
|
|
262
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9ba4d267-20e8-4b06-a3ea-869c19687f81" controls muted></video></td>
|
|
263
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9f3c7acc-2ae9-4f98-873c-60f37f1a434e" controls muted></video></td>
|
|
264
|
+
</tr>
|
|
265
|
+
<tr>
|
|
266
|
+
<td align="center">❌ After the restart, <code>a</code> is <b>gone</b> — <code>%whos</code> reports <i>"Interactive namespace is empty."</i></td>
|
|
267
|
+
<td align="center">✅ After the restart, <code>a</code> is <b>automatically restored</b> — <code>%whos</code> still shows <code>a int 1</code>.</td>
|
|
268
|
+
</tr>
|
|
269
|
+
</table>
|
|
270
|
+
|
|
271
|
+
> If the videos don't play inline, click them to view: [ipykernel](docs/assets/ipykernel.mp4) · [ElasticKernel](docs/assets/elastickernel.mp4).
|
|
258
272
|
|
|
259
273
|
## Why ElasticKernel?
|
|
260
274
|
|
|
@@ -11,12 +11,26 @@ ElasticKernel is a custom IPython kernel that **automatically checkpoints your n
|
|
|
11
11
|
|
|
12
12
|
> 🇯🇵 日本語版は [README.ja.md](README.ja.md) を参照してください。
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
## Demo
|
|
15
|
+
|
|
16
|
+
The same workflow in both clips: define a variable `a = 1`, then **restart the kernel**. The difference is what happens next.
|
|
17
|
+
|
|
18
|
+
<table>
|
|
19
|
+
<tr>
|
|
20
|
+
<th align="center">Standard kernel (<code>ipykernel</code>)</th>
|
|
21
|
+
<th align="center">ElasticKernel</th>
|
|
22
|
+
</tr>
|
|
23
|
+
<tr>
|
|
24
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9ba4d267-20e8-4b06-a3ea-869c19687f81" controls muted></video></td>
|
|
25
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9f3c7acc-2ae9-4f98-873c-60f37f1a434e" controls muted></video></td>
|
|
26
|
+
</tr>
|
|
27
|
+
<tr>
|
|
28
|
+
<td align="center">❌ After the restart, <code>a</code> is <b>gone</b> — <code>%whos</code> reports <i>"Interactive namespace is empty."</i></td>
|
|
29
|
+
<td align="center">✅ After the restart, <code>a</code> is <b>automatically restored</b> — <code>%whos</code> still shows <code>a int 1</code>.</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</table>
|
|
32
|
+
|
|
33
|
+
> If the videos don't play inline, click them to view: [ipykernel](docs/assets/ipykernel.mp4) · [ElasticKernel](docs/assets/elastickernel.mp4).
|
|
20
34
|
|
|
21
35
|
## Why ElasticKernel?
|
|
22
36
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import sys
|
|
2
2
|
from pathlib import Path
|
|
3
3
|
|
|
4
|
-
from setuptools.command.install import install
|
|
5
|
-
|
|
6
4
|
|
|
7
5
|
def install_kernel():
|
|
8
6
|
try:
|
|
@@ -24,13 +22,6 @@ def install_kernel():
|
|
|
24
22
|
return True
|
|
25
23
|
|
|
26
24
|
|
|
27
|
-
class PostInstallCommand(install):
|
|
28
|
-
def run(self):
|
|
29
|
-
install.run(self)
|
|
30
|
-
print("=== Elastic Kernel: Installing Jupyter kernel ===")
|
|
31
|
-
install_kernel()
|
|
32
|
-
|
|
33
|
-
|
|
34
25
|
def main():
|
|
35
26
|
if len(sys.argv) > 1 and sys.argv[1] == "install":
|
|
36
27
|
install_kernel()
|
|
@@ -5,25 +5,14 @@ import os
|
|
|
5
5
|
import time
|
|
6
6
|
import traceback
|
|
7
7
|
import urllib
|
|
8
|
+
import urllib.parse
|
|
9
|
+
import urllib.request
|
|
8
10
|
from datetime import datetime, timedelta, timezone
|
|
9
11
|
|
|
10
12
|
from ipykernel.ipkernel import IPythonKernel
|
|
11
13
|
|
|
12
14
|
from elastic_notebook import ElasticNotebook
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class JSTFormatter(logging.Formatter):
|
|
16
|
-
"""日本時間(JST)用のログフォーマッター"""
|
|
17
|
-
|
|
18
|
-
def converter(self, timestamp):
|
|
19
|
-
dt = datetime.fromtimestamp(timestamp)
|
|
20
|
-
return dt.astimezone(timezone(timedelta(hours=9))) # UTC+9
|
|
21
|
-
|
|
22
|
-
def formatTime(self, record, datefmt=None):
|
|
23
|
-
dt = self.converter(record.created)
|
|
24
|
-
if datefmt:
|
|
25
|
-
return dt.strftime(datefmt)
|
|
26
|
-
return dt.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] # マイクロ秒を3桁まで表示
|
|
15
|
+
from elastic_notebook.core.common.logging_setup import setup_logger
|
|
27
16
|
|
|
28
17
|
|
|
29
18
|
class ElasticKernel(IPythonKernel):
|
|
@@ -69,6 +58,9 @@ class ElasticKernel(IPythonKernel):
|
|
|
69
58
|
# ===========================================
|
|
70
59
|
|
|
71
60
|
# ElasticNotebookをロードする
|
|
61
|
+
# 生成に失敗した場合は None のままにし、以降は「追跡なしの素のカーネル」として
|
|
62
|
+
# 動作を継続する(毎セルで AttributeError を吐き続けないようにする)。(D-13)
|
|
63
|
+
self.elastic_notebook = None
|
|
72
64
|
try:
|
|
73
65
|
self.elastic_notebook = ElasticNotebook(
|
|
74
66
|
shell=self.shell,
|
|
@@ -77,9 +69,14 @@ class ElasticKernel(IPythonKernel):
|
|
|
77
69
|
self.logger.info("ElasticNotebook successfully loaded.")
|
|
78
70
|
except Exception as e:
|
|
79
71
|
self.logger.error(f"Error loading ElasticNotebook: {e}")
|
|
72
|
+
self.logger.error(
|
|
73
|
+
"Continuing without checkpoint tracking (plain kernel mode)."
|
|
74
|
+
)
|
|
80
75
|
|
|
81
76
|
# チェックポイントファイルをロードする
|
|
82
|
-
if os.path.exists(
|
|
77
|
+
if self.elastic_notebook is not None and os.path.exists(
|
|
78
|
+
self.checkpoint_file_path
|
|
79
|
+
):
|
|
83
80
|
self.logger.info("Checkpoint file exists. Loading checkpoint.")
|
|
84
81
|
try:
|
|
85
82
|
start_time = datetime.now(timezone(timedelta(hours=9))).strftime(
|
|
@@ -227,33 +224,14 @@ class ElasticKernel(IPythonKernel):
|
|
|
227
224
|
"""
|
|
228
225
|
ロガーの設定
|
|
229
226
|
"""
|
|
230
|
-
|
|
231
|
-
self.logger = logging.getLogger("ElasticKernelLogger")
|
|
232
|
-
|
|
233
|
-
# 環境変数からログレベルを取得
|
|
234
|
-
log_level_str = os.environ.get("ELASTIC_KERNEL_LOG_LEVEL", "INFO").upper()
|
|
235
|
-
log_level = getattr(logging, log_level_str, logging.INFO)
|
|
236
|
-
self.logger.setLevel(log_level)
|
|
237
|
-
|
|
238
|
-
formatter = JSTFormatter(
|
|
239
|
-
"[%(asctime)s %(name)s %(filename)s:%(lineno)d %(levelname)s] %(message)s",
|
|
240
|
-
"%Y-%m-%d %H:%M:%S.%f",
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
# ローテーティングファイルハンドラー
|
|
244
|
-
rotating_file_handler = logging.handlers.RotatingFileHandler(
|
|
245
|
-
self.log_file_path,
|
|
246
|
-
maxBytes=5 * 1024 * 1024,
|
|
247
|
-
backupCount=5, # 5MBのログサイズでローテーション、5世代保存
|
|
248
|
-
)
|
|
249
|
-
rotating_file_handler.setLevel(log_level)
|
|
250
|
-
rotating_file_handler.setFormatter(formatter)
|
|
251
|
-
self.logger.addHandler(rotating_file_handler)
|
|
227
|
+
self.logger = setup_logger("ElasticKernelLogger", self.log_file_path)
|
|
252
228
|
|
|
253
229
|
def __del_from_user_ns_hidden(self):
|
|
254
230
|
"""
|
|
255
231
|
%whoで表示されるようにするために復元した変数をself.shell.user_ns_hiddenから削除する
|
|
256
232
|
"""
|
|
233
|
+
if self.elastic_notebook is None:
|
|
234
|
+
return
|
|
257
235
|
variable_snapshots = set(
|
|
258
236
|
self.elastic_notebook.dependency_graph.variable_snapshots
|
|
259
237
|
)
|
|
@@ -294,24 +272,34 @@ class ElasticKernel(IPythonKernel):
|
|
|
294
272
|
|
|
295
273
|
self.logger.debug(f"Executing Code:\n{code}")
|
|
296
274
|
|
|
275
|
+
skip_record = self.__skip_record(code)
|
|
276
|
+
|
|
297
277
|
pre_execution_user_ns = (
|
|
298
|
-
set(self.shell.user_ns.keys()) if not
|
|
278
|
+
set(self.shell.user_ns.keys()) if not skip_record else None
|
|
299
279
|
)
|
|
300
|
-
start_time = time.time() if not
|
|
280
|
+
start_time = time.time() if not skip_record else None
|
|
301
281
|
|
|
302
282
|
result = await super().do_execute(
|
|
303
283
|
code, silent, store_history, user_expressions, allow_stdin
|
|
304
284
|
)
|
|
305
285
|
|
|
306
|
-
|
|
286
|
+
# Q3: 実行が成功したセルのみ記録する。失敗したセルを記録すると、依存グラフに
|
|
287
|
+
# 「実行されたセル」として残り、復元のたびに再計算(再実行)されてしまうため。
|
|
288
|
+
execution_succeeded = isinstance(result, dict) and result.get("status") == "ok"
|
|
289
|
+
|
|
290
|
+
if skip_record:
|
|
291
|
+
self.logger.debug("Skipping record event")
|
|
292
|
+
elif not execution_succeeded:
|
|
293
|
+
self.logger.debug("Skipping record event for failed cell execution")
|
|
294
|
+
elif self.elastic_notebook is None:
|
|
295
|
+
self.logger.debug("Skipping record event (ElasticNotebook unavailable)")
|
|
296
|
+
else:
|
|
307
297
|
cell_runtime = time.time() - start_time
|
|
308
298
|
self.logger.debug(f"Cell runtime: {cell_runtime}")
|
|
309
299
|
self.elastic_notebook.record_event(
|
|
310
300
|
code, pre_execution_user_ns, start_time, cell_runtime
|
|
311
301
|
)
|
|
312
302
|
self.logger.debug("Recording event")
|
|
313
|
-
else:
|
|
314
|
-
self.logger.debug("Skipping record event")
|
|
315
303
|
|
|
316
304
|
return result
|
|
317
305
|
|
|
@@ -319,6 +307,12 @@ class ElasticKernel(IPythonKernel):
|
|
|
319
307
|
"""
|
|
320
308
|
カーネル終了時に呼び出されるメソッド
|
|
321
309
|
"""
|
|
310
|
+
# ElasticNotebook の生成に失敗していた場合はチェックポイントを保存できないので
|
|
311
|
+
# スキップして通常のシャットダウンを継続する。(D-13)
|
|
312
|
+
if self.elastic_notebook is None:
|
|
313
|
+
self.logger.info("ElasticNotebook unavailable; skipping checkpoint save.")
|
|
314
|
+
return super().do_shutdown(restart)
|
|
315
|
+
|
|
322
316
|
try:
|
|
323
317
|
start_time = datetime.now(timezone(timedelta(hours=9))).strftime(
|
|
324
318
|
"%Y-%m-%dT%H:%M:%S.%f%z"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: elastic-kernel
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.30
|
|
4
4
|
Summary: An IPython Kernel that automatically saves and restores Jupyter Notebook execution states.
|
|
5
5
|
Author-email: ryutarom <m2002r1028@icloud.com>
|
|
6
6
|
License: Apache License
|
|
@@ -249,12 +249,26 @@ ElasticKernel is a custom IPython kernel that **automatically checkpoints your n
|
|
|
249
249
|
|
|
250
250
|
> 🇯🇵 日本語版は [README.ja.md](README.ja.md) を参照してください。
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
## Demo
|
|
253
|
+
|
|
254
|
+
The same workflow in both clips: define a variable `a = 1`, then **restart the kernel**. The difference is what happens next.
|
|
255
|
+
|
|
256
|
+
<table>
|
|
257
|
+
<tr>
|
|
258
|
+
<th align="center">Standard kernel (<code>ipykernel</code>)</th>
|
|
259
|
+
<th align="center">ElasticKernel</th>
|
|
260
|
+
</tr>
|
|
261
|
+
<tr>
|
|
262
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9ba4d267-20e8-4b06-a3ea-869c19687f81" controls muted></video></td>
|
|
263
|
+
<td width="50%"><video src="https://github.com/user-attachments/assets/9f3c7acc-2ae9-4f98-873c-60f37f1a434e" controls muted></video></td>
|
|
264
|
+
</tr>
|
|
265
|
+
<tr>
|
|
266
|
+
<td align="center">❌ After the restart, <code>a</code> is <b>gone</b> — <code>%whos</code> reports <i>"Interactive namespace is empty."</i></td>
|
|
267
|
+
<td align="center">✅ After the restart, <code>a</code> is <b>automatically restored</b> — <code>%whos</code> still shows <code>a int 1</code>.</td>
|
|
268
|
+
</tr>
|
|
269
|
+
</table>
|
|
270
|
+
|
|
271
|
+
> If the videos don't play inline, click them to view: [ipykernel](docs/assets/ipykernel.mp4) · [ElasticKernel](docs/assets/elastickernel.mp4).
|
|
258
272
|
|
|
259
273
|
## Why ElasticKernel?
|
|
260
274
|
|
|
@@ -12,16 +12,16 @@ elastic_kernel.egg-info/dependency_links.txt
|
|
|
12
12
|
elastic_kernel.egg-info/entry_points.txt
|
|
13
13
|
elastic_kernel.egg-info/requires.txt
|
|
14
14
|
elastic_kernel.egg-info/top_level.txt
|
|
15
|
+
elastic_notebook/LICENSE
|
|
15
16
|
elastic_notebook/__init__.py
|
|
16
17
|
elastic_notebook/elastic_notebook.py
|
|
17
18
|
elastic_notebook/algorithm/__init__.py
|
|
18
|
-
elastic_notebook/algorithm/baseline.py
|
|
19
19
|
elastic_notebook/algorithm/optimizer_exact.py
|
|
20
20
|
elastic_notebook/algorithm/selector.py
|
|
21
21
|
elastic_notebook/core/__init__.py
|
|
22
22
|
elastic_notebook/core/common/__init__.py
|
|
23
23
|
elastic_notebook/core/common/checkpoint_file.py
|
|
24
|
-
elastic_notebook/core/common/
|
|
24
|
+
elastic_notebook/core/common/logging_setup.py
|
|
25
25
|
elastic_notebook/core/common/profile_migration_speed.py
|
|
26
26
|
elastic_notebook/core/common/profile_variable_size.py
|
|
27
27
|
elastic_notebook/core/graph/__init__.py
|
|
@@ -32,7 +32,6 @@ elastic_notebook/core/io/__init__.py
|
|
|
32
32
|
elastic_notebook/core/io/adapter.py
|
|
33
33
|
elastic_notebook/core/io/filesystem_adapter.py
|
|
34
34
|
elastic_notebook/core/io/migrate.py
|
|
35
|
-
elastic_notebook/core/io/pickle.py
|
|
36
35
|
elastic_notebook/core/io/recover.py
|
|
37
36
|
elastic_notebook/core/mutation/__init__.py
|
|
38
37
|
elastic_notebook/core/mutation/fingerprint.py
|
|
@@ -43,4 +42,18 @@ elastic_notebook/core/notebook/checkpoint.py
|
|
|
43
42
|
elastic_notebook/core/notebook/find_input_vars.py
|
|
44
43
|
elastic_notebook/core/notebook/find_output_vars.py
|
|
45
44
|
elastic_notebook/core/notebook/restore_notebook.py
|
|
46
|
-
elastic_notebook/core/notebook/update_graph.py
|
|
45
|
+
elastic_notebook/core/notebook/update_graph.py
|
|
46
|
+
tests/test_checkpoint_file.py
|
|
47
|
+
tests/test_checkpoint_func.py
|
|
48
|
+
tests/test_find_input_vars.py
|
|
49
|
+
tests/test_find_output_vars.py
|
|
50
|
+
tests/test_graph.py
|
|
51
|
+
tests/test_id_graph.py
|
|
52
|
+
tests/test_integration.py
|
|
53
|
+
tests/test_logging_setup.py
|
|
54
|
+
tests/test_migrate_resume.py
|
|
55
|
+
tests/test_object_hash.py
|
|
56
|
+
tests/test_optimizer.py
|
|
57
|
+
tests/test_profile_migration_speed.py
|
|
58
|
+
tests/test_profile_variable_size.py
|
|
59
|
+
tests/test_skip_record.py
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
{elastic_kernel-0.0.28 → elastic_kernel-0.0.30}/elastic_notebook/algorithm/optimizer_exact.py
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# This file has been modified from the original ElasticNotebook.
|
|
2
2
|
# Original: https://github.com/illinoisdata/ElasticNotebook
|
|
3
3
|
|
|
4
|
+
from typing import Union
|
|
5
|
+
|
|
4
6
|
import networkx as nx
|
|
5
7
|
import numpy as np
|
|
6
8
|
from networkx.algorithms.flow import shortest_augmenting_path
|
|
@@ -23,9 +25,6 @@ class OptimizerExact(Selector):
|
|
|
23
25
|
self.active_oes = None
|
|
24
26
|
self.compute_graph = None
|
|
25
27
|
|
|
26
|
-
# CEs required to recompute a variables last modified by a given CE.
|
|
27
|
-
self.recomputation_ces = {}
|
|
28
|
-
|
|
29
28
|
self.idx = 0
|
|
30
29
|
|
|
31
30
|
def get_new_idx(self) -> int:
|
|
@@ -36,7 +35,12 @@ class OptimizerExact(Selector):
|
|
|
36
35
|
self.idx += 1
|
|
37
36
|
return idx
|
|
38
37
|
|
|
39
|
-
def dfs(
|
|
38
|
+
def dfs(
|
|
39
|
+
self,
|
|
40
|
+
current: Union[CellExecution, VariableSnapshot, None],
|
|
41
|
+
visited: set,
|
|
42
|
+
recompute_ces: set,
|
|
43
|
+
):
|
|
40
44
|
"""
|
|
41
45
|
Perform DFS on the Application History Graph for finding the CEs required to recompute a variable.
|
|
42
46
|
Args:
|
|
@@ -71,7 +75,7 @@ class OptimizerExact(Selector):
|
|
|
71
75
|
self.dfs(ce, set(), recompute_ces)
|
|
72
76
|
self.recomputation_ces[ce] = recompute_ces
|
|
73
77
|
|
|
74
|
-
def select_vss(self, notebook_name=None, optimizer_name=None) ->
|
|
78
|
+
def select_vss(self, notebook_name=None, optimizer_name=None) -> tuple:
|
|
75
79
|
self.find_prerequisites()
|
|
76
80
|
|
|
77
81
|
# Construct flow graph for computing mincut
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
# This file has been modified from the original ElasticNotebook.
|
|
2
2
|
# Original: https://github.com/illinoisdata/ElasticNotebook
|
|
3
3
|
|
|
4
|
-
from enum import Enum
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class OptimizerType(Enum):
|
|
8
|
-
"""
|
|
9
|
-
String representations of all implemented optimizers.
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
EXACT = "exact"
|
|
13
|
-
EXACT_C = "exact_c"
|
|
14
|
-
EXACT_R = "exact_r"
|
|
15
|
-
MIGRATE_ALL = "migrate_all"
|
|
16
|
-
RECOMPUTE_ALL = "recompute_all"
|
|
17
|
-
|
|
18
4
|
|
|
19
5
|
class Selector:
|
|
20
6
|
"""
|
|
@@ -32,13 +18,17 @@ class Selector:
|
|
|
32
18
|
self.overlapping_vss = None
|
|
33
19
|
self.migration_speed_bps = migration_speed_bps
|
|
34
20
|
|
|
35
|
-
|
|
21
|
+
# CEs required to recompute a variable last modified by a given CE.
|
|
22
|
+
# Declared on the base so callers (e.g. checkpoint()) can rely on it.
|
|
23
|
+
self.recomputation_ces: dict = {}
|
|
24
|
+
|
|
25
|
+
def select_vss(self, notebook_name=None, optimizer_name=None) -> tuple:
|
|
36
26
|
"""
|
|
37
|
-
Classes that inherit from the `Selector` class (such as `
|
|
38
|
-
|
|
27
|
+
Classes that inherit from the `Selector` class (such as `OptimizerExact`) should
|
|
28
|
+
override `select_vss`.
|
|
39
29
|
|
|
40
30
|
Returns:
|
|
41
|
-
set(VariableSnapshot):
|
|
42
|
-
|
|
31
|
+
Tuple[set(VariableSnapshot), set(CellExecution)]: the VSs selected to migrate and
|
|
32
|
+
the CEs selected to recompute.
|
|
43
33
|
"""
|
|
44
34
|
raise NotImplementedError()
|