FIX DB修改job_id类型,增加status字段
This commit is contained in:
parent
473ca10397
commit
0435df9a84
14
__init__.py
14
__init__.py
|
|
@ -319,9 +319,10 @@ class Task(Base):
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
gmt_create = Column(DateTime(timezone=True), server_default=func.now())
|
gmt_create = Column(DateTime(timezone=True), server_default=func.now())
|
||||||
gmt_modified = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
gmt_modified = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||||
prompt_id = Column(String, index=True, nullable=False)
|
prompt_id = Column(String, index=True, nullable=False, unique=True)
|
||||||
result = Column(String, nullable=True)
|
result = Column(String, nullable=True)
|
||||||
job_id = Column(String, index=True, nullable=False)
|
job_id = Column(Integer, index=True, nullable=False, unique=True)
|
||||||
|
status = Column(Integer)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"{self.id},{self.gmt_create},{self.gmt_modified},{self.prompt_id},{self.result}"
|
return f"{self.id},{self.gmt_create},{self.gmt_modified},{self.prompt_id},{self.result}"
|
||||||
|
|
@ -334,6 +335,7 @@ class LogToDB:
|
||||||
"required": {
|
"required": {
|
||||||
"job_id": ("STRING",{"forceInput": True}),
|
"job_id": ("STRING",{"forceInput": True}),
|
||||||
"log": ("STRING",{"forceInput": True}),
|
"log": ("STRING",{"forceInput": True}),
|
||||||
|
"status": ("INT",{"default": 1, "max": 1}),
|
||||||
},
|
},
|
||||||
"hidden": {
|
"hidden": {
|
||||||
"unique_id": "UNIQUE_ID",
|
"unique_id": "UNIQUE_ID",
|
||||||
|
|
@ -351,7 +353,8 @@ class LogToDB:
|
||||||
|
|
||||||
CATEGORY = "不忘科技-自定义节点🚩"
|
CATEGORY = "不忘科技-自定义节点🚩"
|
||||||
|
|
||||||
def log2db(self, job_id, log, unique_id):
|
def log2db(self, job_id, log, status, unique_id):
|
||||||
|
job_id = int(job_id)
|
||||||
# 获取comfy服务器队列信息
|
# 获取comfy服务器队列信息
|
||||||
(_, prompt_id, prompt, extra_data, outputs_to_execute) = next(
|
(_, prompt_id, prompt, extra_data, outputs_to_execute) = next(
|
||||||
iter(server.PromptServer.instance.prompt_queue.currently_running.values()))
|
iter(server.PromptServer.instance.prompt_queue.currently_running.values()))
|
||||||
|
|
@ -371,11 +374,12 @@ class LogToDB:
|
||||||
}
|
}
|
||||||
if len(tasks) == 0:
|
if len(tasks) == 0:
|
||||||
# 不存在插入
|
# 不存在插入
|
||||||
task = Task(prompt_id=prompt_id, job_id=job_id, result=json.dumps(result))
|
task = Task(prompt_id=prompt_id, job_id=job_id, result=json.dumps(result), status=status)
|
||||||
session.add(task)
|
session.add(task)
|
||||||
elif len(tasks) == 1:
|
elif len(tasks) == 1:
|
||||||
# 存在更新
|
# 存在更新
|
||||||
session.query(Task).filter(Task.prompt_id == prompt_id).update({"result": json.dumps(result)})
|
session.query(Task).filter(Task.prompt_id == prompt_id).update({"result": json.dumps(result),
|
||||||
|
"status": status})
|
||||||
else:
|
else:
|
||||||
# 异常报错
|
# 异常报错
|
||||||
raise RuntimeError("状态数据库prompt_id不唯一, 无法记录状态!")
|
raise RuntimeError("状态数据库prompt_id不唯一, 无法记录状态!")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue