2022-09-30 13:44:46 +08:00
|
|
|
from flask_appbuilder import Model
|
2022-10-10 11:44:53 +08:00
|
|
|
|
2022-10-11 14:25:25 +08:00
|
|
|
from sqlalchemy import Text
|
2022-10-10 11:44:53 +08:00
|
|
|
|
2022-10-11 14:25:25 +08:00
|
|
|
from myapp import app
|
2022-09-30 13:44:46 +08:00
|
|
|
from myapp.models.helpers import ImportMixin
|
2022-10-11 14:25:25 +08:00
|
|
|
from sqlalchemy import Column, Integer, String
|
2022-10-10 11:44:53 +08:00
|
|
|
|
2022-09-30 13:44:46 +08:00
|
|
|
from flask import Markup
|
|
|
|
from myapp.models.base import MyappModelBase
|
|
|
|
metadata = Model.metadata
|
|
|
|
conf = app.config
|
2022-10-10 11:44:53 +08:00
|
|
|
|
2022-09-30 13:44:46 +08:00
|
|
|
|
|
|
|
class Aihub(Model,ImportMixin,MyappModelBase):
|
|
|
|
__tablename__ = 'aihub'
|
|
|
|
|
|
|
|
id = Column(Integer, primary_key=True)
|
|
|
|
uuid = Column(String(2000), nullable=True, default='')
|
|
|
|
status = Column(String(200), nullable=True, default='')
|
|
|
|
doc = Column(String(200), nullable=True,default='')
|
|
|
|
name = Column(String(200), nullable=True, default='')
|
|
|
|
field = Column(String(200), nullable=True, default='')
|
|
|
|
scenes = Column(String(200), nullable=True, default='')
|
|
|
|
type = Column(String(200), nullable=True, default='')
|
|
|
|
label = Column(String(200), nullable=True, default='')
|
|
|
|
describe = Column(String(2000), nullable=True, default='')
|
|
|
|
source = Column(String(200), nullable=True, default='')
|
|
|
|
pic = Column(String(500), nullable=True, default='')
|
|
|
|
dataset = Column(Text, nullable=True, default='')
|
|
|
|
notebook = Column(String(2000), nullable=True, default='')
|
|
|
|
job_template = Column(Text, nullable=True, default='')
|
2022-10-10 10:26:11 +08:00
|
|
|
pipeline = Column(Text, nullable=True, default='')
|
2022-09-30 13:44:46 +08:00
|
|
|
pre_train_model = Column(String(2000), nullable=True, default='')
|
|
|
|
inference = Column(Text, nullable=True, default='')
|
|
|
|
service = Column(Text, nullable=True, default='')
|
|
|
|
version = Column(String(200), nullable=True, default='')
|
|
|
|
hot = Column(Integer, default=1)
|
|
|
|
price = Column(Integer, default=1)
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
def card(self):
|
2022-10-10 10:26:11 +08:00
|
|
|
notebook_url = "/aihub/api/notebook/"+self.uuid if self.status=='online' and self.notebook else ""
|
|
|
|
train_url = "/aihub/api/train/" + self.uuid if self.status == 'online' and (self.job_template or self.pipeline) else ""
|
|
|
|
service_url = "/aihub/api/service/" + self.uuid if self.status == 'online' and (self.service or self.inference) else ""
|
|
|
|
|
2022-09-30 13:44:46 +08:00
|
|
|
return Markup(f'''
|
2022-09-30 18:42:41 +08:00
|
|
|
<div style="border: 3px solid rgba({'29,152,29,.9' if self.status=='online' else '0,0,0,.2'});border-radius: 3px;">
|
|
|
|
<a href="{self.doc if self.status=='online' else ''}">
|
|
|
|
<img src="{self.pic}" style="height:200px;width:100%" alt="{self.describe}"/>
|
2022-09-30 18:05:59 +08:00
|
|
|
</a>
|
|
|
|
<br>
|
|
|
|
<div>
|
|
|
|
<div class="p16" alt="{self.describe}">
|
|
|
|
<div class="p-r card-popup ellip1">
|
2022-09-30 18:42:41 +08:00
|
|
|
{("在线:" if self.status=='online' else '待上线:')+self.describe}
|
2022-09-30 18:05:59 +08:00
|
|
|
<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>
|
|
|
|
<div style="border-top: 1px solid rgba(0,0,0,.06);" class="ptb8 d-f ac jc-b">
|
2022-10-10 10:26:11 +08:00
|
|
|
<a class="flex1 ta-c" style="border-right: 1px solid rgba(0,0,0,.06);" href='{notebook_url}'>notebook</a>
|
|
|
|
<a class="flex1 ta-c" style="border-right: 1px solid rgba(0,0,0,.06);" href='{train_url}'>训练</a>
|
|
|
|
<a class="flex1 ta-c" style="border-right: 1px solid rgba(0,0,0,.06);" href='{service_url}'>服务</a>
|
2022-09-30 18:05:59 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-30 13:44:46 +08:00
|
|
|
</div>
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|