@@ -8,10 +8,14 @@ reuse the result from the first invocation without executing the app again.
88
99This can save time and computational resources.
1010
11- This is done in two ways:
11+ The memoization and checkpointing system is pluggable, with basic behaviour
12+ provided by the `BasicMemoizer `. The rest of this chapter refers to the
13+ behaviour of the `BasicMemoizer `.
14+
15+ Memoization and checkpointing is done in two ways:
1216
1317* Firstly, *app caching * will allow reuse of results and exceptions within
14- the same run.
18+ the same run. This is also referred to as * memoization *.
1519
1620* Building on top of that, *checkpointing * will store results (but not
1721 exceptions) on the filesystem and reuse those results in later runs.
@@ -39,8 +43,8 @@ decorator to ``True`` (by default it is ``False``).
3943 def hello (msg , stdout = None ):
4044 return ' echo {} ' .format(msg)
4145
42- App caching can be globally disabled by setting `` app_cache=False ``
43- in the :class: `~parsl.config.Config `.
46+ App caching can be globally disabled by supplying a new memoizer in
47+ :class: `~parsl.config.Config ` defined as `` BasicMemoizer(memoize=False) ` `.
4448
4549App caching can be particularly useful when developing interactive programs such as when
4650using a Jupyter notebook. In this case, cells containing apps are often re-executed
@@ -158,26 +162,25 @@ use the hash of the app and the invocation input parameters to identify previous
158162results. If multiple checkpoints exist for an app (with the same hash)
159163the most recent entry will be used.
160164
161- Parsl provides four checkpointing modes:
165+ Parsl provides four checkpointing modes, which can be specified using the ``checkpoint_mode ``
166+ parameter to ``memoizer=BasicMemoizer(...) ``
162167
1631681. ``task_exit ``: a checkpoint is created each time an app completes or fails
164169 (after retries if enabled). This mode minimizes the risk of losing information
165170 from completed tasks.
166171
167172 .. code-block :: python
168173
169- from parsl.configs.local_threads import config
170- config.checkpoint_mode = ' task_exit'
174+ BasicMemoizer(checkpoint_mode = ' task_exit' )
171175
172176 2. ``periodic ``: a checkpoint is created periodically using a user-specified
173177 checkpointing interval. Results will be saved to the checkpoint file for
174178 all tasks that have completed during this period.
175179
176180 .. code-block :: python
177181
178- from parsl.configs.local_threads import config
179- config.checkpoint_mode = ' periodic'
180- config.checkpoint_period = " 01:00:00"
182+ BasicMemoizer(checkpoint_mode = ' periodic' ,
183+ checkpoint_period = ' 01:00:00' )
181184
182185 3. ``dfk_exit ``: checkpoints are created when Parsl is
183186 about to exit. This reduces the risk of losing results due to
@@ -187,19 +190,14 @@ Parsl provides four checkpointing modes:
187190
188191 .. code-block :: python
189192
190- from parsl.configs.local_threads import config
191- config.checkpoint_mode = ' dfk_exit'
193+ BasicMemoizer(checkpoint_mode = ' dfk_exit' )
192194
193195 4. ``manual ``: in addition to these automated checkpointing modes, it is also possible
194196 to manually initiate a checkpoint by calling ``DataFlowKernel.checkpoint() `` in the
195197 Parsl program code.
196198
197199 .. code-block :: python
198200
199- import parsl
200- from parsl.configs.local_threads import config
201- dfk = parsl.load(config)
202- ... .
203201 dfk.checkpoint()
204202
205203 In all cases the checkpoint file is written out to the ``runinfo/RUN_ID/checkpoint/ `` directory.
@@ -286,11 +284,11 @@ from the checkpoint file are are immediately returned.
286284 from parsl.tests.configs.local_threads import config
287285 from parsl.utils import get_all_checkpoints
288286
289- config.checkpoint_files = get_all_checkpoints()
287+ config.memoizer = BasicMemoizer( checkpoint_files = get_all_checkpoints() )
290288
291289 parsl.load(config)
292290
293- # Rerun the same workflow
291+ # Rerun the same workflow
294292 d = []
295293 for i in range (5 ):
296294 d.append(slow_double(i))
0 commit comments