Skip to content

Commit 1449ea7

Browse files
bencliffordyadudoc
andauthored
Remove task_id param from memo functions, as whole task record is available (#2080)
When these functions need the task id, they can extract it from the task record. see #2014 Co-authored-by: Yadu Nand Babuji <[email protected]>
1 parent 20e4543 commit 1449ea7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

parsl/dataflow/dflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def handle_app_update(self, task_record, future):
413413
if not task_record['app_fu'] == future:
414414
logger.error("Internal consistency error: callback future is not the app_fu in task structure, for task {}".format(task_id))
415415

416-
self.memoizer.update_memo(task_id, task_record, future)
416+
self.memoizer.update_memo(task_record, future)
417417

418418
if self.checkpoint_mode == 'task_exit':
419419
self.checkpoint(tasks=[task_id])
@@ -557,7 +557,7 @@ def launch_task(self, task_record, executable, *args, **kwargs):
557557
task_id = task_record['id']
558558
task_record['try_time_launched'] = datetime.datetime.now()
559559

560-
memo_fu = self.memoizer.check_memo(task_id, task_record)
560+
memo_fu = self.memoizer.check_memo(task_record)
561561
if memo_fu:
562562
logger.info("Reusing cached result for task {}".format(task_id))
563563
task_record['from_memo'] = True

parsl/dataflow/memoization.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def make_hash(self, task):
206206
hashedsum = hashlib.md5(x).hexdigest()
207207
return hashedsum
208208

209-
def check_memo(self, task_id, task):
209+
def check_memo(self, task):
210210
"""Create a hash of the task and its inputs and check the lookup table for this hash.
211211
212212
If present, the results are returned. The result is a tuple indicating whether a memo
@@ -221,6 +221,9 @@ def check_memo(self, task_id, task):
221221
222222
This call will also set task['hashsum'] to the unique hashsum for the func+inputs.
223223
"""
224+
225+
task_id = task['id']
226+
224227
if not self.memoize or not task['memoize']:
225228
task['hashsum'] = None
226229
logger.debug("Task {} will not be memoized".format(task_id))
@@ -254,11 +257,10 @@ def hash_lookup(self, hashsum):
254257
"""
255258
return self.memo_lookup_table[hashsum]
256259

257-
def update_memo(self, task_id, task, r):
260+
def update_memo(self, task, r):
258261
"""Updates the memoization lookup table with the result from a task.
259262
260263
Args:
261-
- task_id (int): Integer task id
262264
- task (dict) : A task dict from dfk.tasks
263265
- r (Result future): Result future
264266
@@ -267,6 +269,9 @@ def update_memo(self, task_id, task, r):
267269
"""
268270
# TODO: could use typeguard
269271
assert isinstance(r, Future)
272+
273+
task_id = task['id']
274+
270275
if not self.memoize or not task['memoize'] or 'hashsum' not in task:
271276
return
272277

0 commit comments

Comments
 (0)