Skip to content

Commit f07446e

Browse files
authored
Merge pull request #134 from felix5572/master
fix #126 add load_from_json for class Task
2 parents 4c173f4 + 8dfcb40 commit f07446e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

dpdispatcher/submission.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ def __getitem__(self, key):
394394
def get_hash(self):
395395
return sha1(str(self.serialize()).encode('utf-8')).hexdigest()
396396

397+
@classmethod
398+
def load_from_json(cls, json_file):
399+
with open(json_file, 'r') as f:
400+
task_dict = json.load(f)
401+
task = cls.deserialize(task_dict=task_dict)
402+
return task
403+
397404
@classmethod
398405
def deserialize(cls, task_dict):
399406
"""convert the task_dict to a Task class object
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# mock file for unittest; test when dpdispatcher need recover tasks

0 commit comments

Comments
 (0)