Skip to content

Commit b850d9a

Browse files
Add map_function to get_history. (Comfy-Org#9056)
1 parent c60467a commit b850d9a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

execution.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ def delete_queue_item(self, function):
10971097
return True
10981098
return False
10991099

1100-
def get_history(self, prompt_id=None, max_items=None, offset=-1):
1100+
def get_history(self, prompt_id=None, max_items=None, offset=-1, map_function=None):
11011101
with self.mutex:
11021102
if prompt_id is None:
11031103
out = {}
@@ -1106,13 +1106,21 @@ def get_history(self, prompt_id=None, max_items=None, offset=-1):
11061106
offset = len(self.history) - max_items
11071107
for k in self.history:
11081108
if i >= offset:
1109-
out[k] = self.history[k]
1109+
p = self.history[k]
1110+
if map_function is not None:
1111+
p = map_function(p)
1112+
out[k] = p
11101113
if max_items is not None and len(out) >= max_items:
11111114
break
11121115
i += 1
11131116
return out
11141117
elif prompt_id in self.history:
1115-
return {prompt_id: copy.deepcopy(self.history[prompt_id])}
1118+
p = self.history[prompt_id]
1119+
if map_function is None:
1120+
p = copy.deepcopy(p)
1121+
else:
1122+
p = map_function(p)
1123+
return {prompt_id: p}
11161124
else:
11171125
return {}
11181126

0 commit comments

Comments
 (0)