-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetect_code_change.py
More file actions
50 lines (28 loc) · 861 Bytes
/
detect_code_change.py
File metadata and controls
50 lines (28 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""Illustrate saving checkpoints and resuming from the last modified function.
Run this code first to generate the call graph and breakpoints. Then modify one
of the functions step0, step1, or step2. When you rerun the code, it will
resume from whichever function you modified.
"""
from generator_checkpointing import resume_and_save_checkpoints
def step0():
print(">step 1")
def step1():
print(">step 2")
def step2():
print(">step 3")
def processing():
print("starting")
if (yield "step0"):
print("Resuming before step0")
step0()
if (yield "step1"):
print("Resuming before step1")
step1()
if (yield "step2"):
print("Resuming before step2")
step2()
print("done")
def main():
resume_and_save_checkpoints(processing(), [__file__])
if __name__ == "__main__":
main()