update model col

This commit is contained in:
cdllp2 2022-11-23 16:58:45 +08:00
parent 7c80213f0b
commit 363444bb49
6 changed files with 21 additions and 45 deletions

View File

@ -12,7 +12,7 @@ metadata = Model.metadata
conf = app.config
class Aihub(Model,ImportMixin,MyappModelBase):
class Aihub(Model,MyappModelBase):
__tablename__ = 'aihub'
id = Column(Integer, primary_key=True)
@ -54,7 +54,7 @@ class Aihub(Model,ImportMixin,MyappModelBase):
<div>
<div class="p16" alt="{self.describe}">
<div class="p-r card-popup ellip1">
{("在线:" if self.status=='online' else '待上线:')+self.describe}
{ self.name+": "+self.describe }
<div class="p-a card-popup-target d-n" style="top:100%;left:0;background:rgba(0,0,0,0.5);color:#fff;border-radius:3px;">{self.describe}</div>
</div>
</div>

View File

@ -41,9 +41,9 @@ class Dimension_table(Model,ImportMixin,MyappModelBase):
@property
def operate_html(self):
url='''
<a target=_blank href="/dimension_table_modelview/api/create_external_table/%s">创建远程表</a> | <a target=_blank href="/dimension_table_modelview/api/external/%s">建外表示例</a> | <a href="/dimension_table_modelview/api/clear/%s">清空表记录</a>
'''%(self.id,self.id,self.id)
url=f'''
<a target=_blank href="/dimension_table_modelview/api/create_external_table/%s">创建远程表</a> | <a target=_blank href="/dimension_table_modelview/api/external/%s">建外表示例</a>
'''%(self.id,self.id)
return Markup(url)

View File

@ -25,6 +25,7 @@ class ETL_Pipeline(Model,ImportMixin,AuditMixinNullable,MyappModelBase):
project = relationship(
"Project", foreign_keys=[project_id]
)
workflow = Column(String(200),nullable=True) # 调度引擎
dag_json = Column(Text(65536),nullable=True,default='{}') # pipeline的上下游关系
config = Column(Text(65536),default='{}') # pipeline的全局配置
expand = Column(Text(65536),default='[]')
@ -36,40 +37,10 @@ class ETL_Pipeline(Model,ImportMixin,AuditMixinNullable,MyappModelBase):
@property
def etl_pipeline_url(self):
pipeline_url="/etl_pipeline_modelview/web/" +str(self.id)
pipeline_url="/etl_pipeline_modelview/api/web/" +str(self.id)
return Markup(f'<a target=_blank href="{pipeline_url}">{self.describe}</a>')
@renders('dag_json')
def dag_json_html(self):
dag_json = self.dag_json or '{}'
return Markup('<pre><code>' + dag_json + '</code></pre>')
@renders('config')
def config_html(self):
config = self.config or '{}'
return Markup('<pre><code>' + config + '</code></pre>')
@renders('expand')
def expand_html(self):
return Markup('<pre><code>' + self.expand + '</code></pre>')
@renders('parameter')
def parameter_html(self):
return Markup('<pre><code>' + self.parameter + '</code></pre>')
@property
def run_instance(self):
# workflow = db.session.query(Workflow).filter_by(foreign_key= str(self.id)).filter_by(status= 'Running').filter_by(create_time > datetime.datetime.now().strftime("%Y-%m-%d")).all()
# workflow_num = len(workflow) if workflow else 0
# url = '/workflow_modelview/list/?_flt_2_name=%s'%self.name.replace("_","-")[:54]
url_path = conf.get('MODEL_URLS', {}).get("etl_task_instance")
# print(url)
return Markup(f"<a target=_blank href='{url_path}'>任务实例</a>")
def clone(self):
return ETL_Pipeline(
name=self.name.replace('_', '-'),
@ -86,10 +57,11 @@ class ETL_Task(Model,ImportMixin,AuditMixinNullable,MyappModelBase):
id = Column(Integer, primary_key=True)
name = Column(String(100),nullable=False,unique=True)
describe = Column(String(200),nullable=False)
etl_pipeline_id = Column(Integer, ForeignKey('etl_pipeline.id'),nullable=False) # 定义外键
etl_pipeline = relationship(
"ETL_Pipeline", foreign_keys=[etl_pipeline_id]
)
# etl_pipeline_id = Column(Integer, ForeignKey('etl_pipeline.id'),nullable=False) # 定义外键
# etl_pipeline = relationship(
# "ETL_Pipeline", foreign_keys=[etl_pipeline_id]
# )
etl_pipeline_id = Column(Integer)
template = Column(String(100),nullable=False)
task_args = Column(Text(65536),default='{}')
etl_task_id = Column(String(100),nullable=False)
@ -102,10 +74,6 @@ class ETL_Task(Model,ImportMixin,AuditMixinNullable,MyappModelBase):
def __repr__(self):
return self.name
@property
def etl_pipeline_url(self):
pipeline_url="/etl_pipeline_modelview/web/" +str(self.etl_pipeline.id)
return Markup(f'<a target=_blank href="{pipeline_url}">{self.etl_pipeline.describe}</a>')

View File

@ -186,12 +186,14 @@ class Pipeline(Model,ImportMixin,AuditMixinNullable,MyappModelBase):
parallelism = Column(Integer, nullable=False,default=1) # 同一个pipeline最大并行的task数目
alert_status = Column(String(100), default='Pending,Running,Succeeded,Failed,Terminated') # 哪些状态会报警Pending,Running,Succeeded,Failed,Unknown,Waiting,Terminated
alert_user = Column(String(300), default='')
expand = Column(Text(65536),default='[]')
depends_on_past = Column(Boolean, default=False)
max_active_runs = Column(Integer, nullable=False,default=3) # 最大同时运行的pipeline实例
expired_limit = Column(Integer, nullable=False, default=1) # 过期保留个数此数值有效时会优先使用覆盖max_active_runs的功能
parameter = Column(Text(65536), default='{}')
def __repr__(self):
return self.name

View File

@ -1,4 +1,5 @@
from flask_appbuilder import Model
from flask import Markup
from sqlalchemy import (
Boolean,
Text,
@ -30,10 +31,14 @@ class Metadata_metric(Model,AuditMixinNullable,ImportMixin,MyappModelBase):
status = Column(String(100), nullable=True, default='') # 状态 下线 上线 创建中
task_id = Column(String(200), nullable=True, default='') # 所有相关任务id
public = Column(Boolean, default=True) # 是否公开
remark = Column(Text(65536), nullable=True,default='') # 备注
expand = Column(Text(65536), nullable=True,default='{}')
def __repr__(self):
return self.name
@property
def remark_html(self):
return "<br>".join(self.remark.split('\n'))
def clone(self):
return Metadata_metric(

View File

@ -99,7 +99,8 @@ class Notebook(Model,AuditMixinNullable,MyappModelBase):
status = pods[0]['status']
if g.user.is_admin():
k8s_dash_url = self.cluster.get('K8S_DASHBOARD_CLUSTER') + "#/search?namespace=jupyter&q=" + self.name
url = Markup(f'<a target=_blank href="{k8s_dash_url}">{status}</a>')
url = Markup(f'<a target=_blank style="color:#008000;" href="{k8s_dash_url}">{status}</a>')
return url
return status