Fix message not reloaded before appending text

This commit is contained in:
allegroai 2023-06-21 08:51:47 +03:00
parent 1da47a20f8
commit ab3c148de2
2 changed files with 21 additions and 1 deletions

View File

@ -644,6 +644,23 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
res = self.send(tasks.GetByIdRequest(task=self.id))
return res.response.task
def _reload_field(self, field):
# type: (str) -> Any
""" Reload the task specific field, dot seperated for nesting"""
with self._edit_lock:
if self._offline_mode:
task_object = self._reload()
else:
res = self.send(tasks.GetAllRequest(id=[self.id], only_fields=[field], search_hidden=True))
task_object = res.response.tasks[0]
for p in field.split("."):
task_object = getattr(task_object, p, None)
if task_object is None:
break
return task_object
def reset(self, set_started_on_success=True, force=False):
# type: (bool, bool) -> ()
"""

View File

@ -3621,7 +3621,10 @@ class Task(_Task):
# at least until we support multiple input models
# notice that we do not check the task's input model because we allow task reuse and overwrite
# add into comment that we are using this model
comment = self.comment or ''
# refresh comment
comment = self._reload_field("comment") or self.comment or ''
if not comment.endswith('\n'):
comment += '\n'
comment += 'Using model id: {}'.format(model.id)