from flask_appbuilder import Model from sqlalchemy import Text from myapp import app from myapp.models.helpers import ImportMixin from sqlalchemy import Column, Integer, String from flask import Markup from myapp.models.base import MyappModelBase metadata = Model.metadata conf = app.config 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='') pipeline = Column(Text, nullable=True, default='') 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): 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 "" return Markup(f'''
''')