This is an automated email from the ASF dual-hosted git repository.
ka94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new d75a547ec fix: Create SubtaskRun table for pydevlake (#5354)
d75a547ec is described below
commit d75a547ec1d28d21450c7a2a102fdb416104ac14
Author: Camille Teruel <[email protected]>
AuthorDate: Mon Jun 5 23:02:17 2023 +0200
fix: Create SubtaskRun table for pydevlake (#5354)
SubtaskRun is not created since the new go-side migration PR.
Co-authored-by: Camille Teruel <[email protected]>
---
backend/python/pydevlake/pydevlake/ipc.py | 3 +++
backend/python/pydevlake/pydevlake/model.py | 7 ++++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/backend/python/pydevlake/pydevlake/ipc.py
b/backend/python/pydevlake/pydevlake/ipc.py
index d783800a7..9b0e851dd 100644
--- a/backend/python/pydevlake/pydevlake/ipc.py
+++ b/backend/python/pydevlake/pydevlake/ipc.py
@@ -27,6 +27,7 @@ from sqlalchemy.engine import Engine
from pydevlake.context import Context
from pydevlake.message import Message
from pydevlake.stream import DomainType
+from pydevlake.model import SubtaskRun
def plugin_method(func):
@@ -135,6 +136,8 @@ def create_db_engine(db_url) -> Engine:
del connect_args['parseTime']
try:
engine = create_engine(base_url, connect_args=connect_args)
+ tables = SubtaskRun.metadata.tables
+ tables[SubtaskRun.__tablename__].create(engine, checkfirst=True)
return engine
except Exception as e:
raise Exception(f"Unable to make a database connection") from e
diff --git a/backend/python/pydevlake/pydevlake/model.py
b/backend/python/pydevlake/pydevlake/model.py
index 2c576a12e..81b10deaf 100644
--- a/backend/python/pydevlake/pydevlake/model.py
+++ b/backend/python/pydevlake/pydevlake/model.py
@@ -21,8 +21,8 @@ from datetime import datetime
import inflect
from pydantic import AnyUrl, SecretStr, validator
-from sqlalchemy import Column, DateTime
-from sqlalchemy.orm import declared_attr, Session
+from sqlalchemy import Column, DateTime, Text
+from sqlalchemy.orm import declared_attr
from sqlalchemy.inspection import inspect
from sqlmodel import SQLModel, Field
@@ -169,6 +169,7 @@ def _get_plugin_name(cls):
class SubtaskRun(SQLModel, table=True):
+ __tablename__ = '_pydevlake_subtask_runs'
"""
Table storing information about the execution of subtasks.
"""
@@ -177,4 +178,4 @@ class SubtaskRun(SQLModel, table=True):
connection_id: int
started: datetime
completed: Optional[datetime]
- state: str # JSON encoded dict of atomic values
+ state: str = Field(sa_column=Column(Text)) # JSON encoded dict of atomic
values