From 172017b9bdb733924b511816b41bab32b2222a21 Mon Sep 17 00:00:00 2001 From: cdllp2 Date: Sun, 28 Aug 2022 20:24:32 +0800 Subject: [PATCH] change view to api --- myapp/models/model_serving.py | 5 +++++ myapp/views/view_docker.py | 2 +- myapp/views/view_etl_pipeline.py | 1 - myapp/views/view_images.py | 2 +- myapp/views/view_metadata_metric.py | 4 ++-- myapp/views/view_nni.py | 3 +-- myapp/views/view_notebook.py | 4 ++-- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/myapp/models/model_serving.py b/myapp/models/model_serving.py index ef995d14..a3811b29 100644 --- a/myapp/models/model_serving.py +++ b/myapp/models/model_serving.py @@ -201,6 +201,11 @@ class InferenceService(Model,AuditMixinNullable,MyappModelBase,service_common): url = self.project.cluster['K8S_DASHBOARD_CLUSTER'] + '#/search?namespace=%s&q=%s' % (conf.get('SERVICE_NAMESPACE'), self.name.replace('_', '-')) return Markup(f'{self.model_name}') + @property + def replicas_html(self): + return "%s~%s"%(self.min_replicas,self.max_replicas) + + @property def resource(self): return 'cpu:%s,memory:%s,gpu:%s'%(self.resource_cpu,self.resource_memory,self.resource_gpu) diff --git a/myapp/views/view_docker.py b/myapp/views/view_docker.py index f65482e1..d0cca77a 100644 --- a/myapp/views/view_docker.py +++ b/myapp/views/view_docker.py @@ -348,7 +348,7 @@ class Docker_ModelView_Base(): class Docker_ModelView(Docker_ModelView_Base,MyappModelView,DeleteMixin): datamodel = SQLAInterface(Docker) -appbuilder.add_view(Docker_ModelView,"镜像调试",href="/docker_modelview/list/",icon = 'fa-cubes',category = '在线开发',category_icon = 'fa-glass') +appbuilder.add_view_no_menu(Docker_ModelView) # 添加api class Docker_ModelView_Api(Docker_ModelView_Base,MyappModelRestApi): diff --git a/myapp/views/view_etl_pipeline.py b/myapp/views/view_etl_pipeline.py index b4a039ab..8a9179b4 100644 --- a/myapp/views/view_etl_pipeline.py +++ b/myapp/views/view_etl_pipeline.py @@ -1742,7 +1742,6 @@ class ETL_Pipeline_ModelView(ETL_Pipeline_ModelView_Base,MyappModelView,DeleteMi # order_columns = ['changed_on'] -# appbuilder.add_view(ETL_Pipeline_ModelView,"数据计算",href="/etl_pipeline_modelview/list/",icon = 'fa-usb',category = 'data') appbuilder.add_view_no_menu(ETL_Pipeline_ModelView) diff --git a/myapp/views/view_images.py b/myapp/views/view_images.py index b0942036..29dcf9eb 100644 --- a/myapp/views/view_images.py +++ b/myapp/views/view_images.py @@ -217,7 +217,7 @@ class Images_ModelView_Base(): class Images_ModelView(Images_ModelView_Base,MyappModelView,DeleteMixin): datamodel = SQLAInterface(Images) -appbuilder.add_view(Images_ModelView,"模板镜像",href="/images_modelview/list/?_flt_2_name=",icon = 'fa-file-image-o',category = '训练') +appbuilder.add_view_no_menu(Images_ModelView) class Images_ModelView_Api(Images_ModelView_Base,MyappModelRestApi): diff --git a/myapp/views/view_metadata_metric.py b/myapp/views/view_metadata_metric.py index 1789dc14..14bfea9b 100644 --- a/myapp/views/view_metadata_metric.py +++ b/myapp/views/view_metadata_metric.py @@ -86,8 +86,7 @@ class Metadata_metric_ModelView_base(): label_title='指标' datamodel = SQLAInterface(Metadata_metric) base_permissions = ['can_add','can_show','can_edit','can_list','can_delete'] - base_order = ("changed_on", "desc") - # order_columns = ['id','changed_on'] + base_order = ("id", "desc") order_columns = ['id'] search_columns=['metric_data_type','metric_responsible','app','name','label','describe','metric_type','metric_level','task_id','caliber'] show_columns=['id','app','metric_data_type','name','label','describe','metric_type','metric_level','metric_dim','metric_responsible','caliber','task_id','public'] @@ -188,6 +187,7 @@ class Metadata_metric_ModelView_base(): edit_form_extra_fields = add_form_extra_fields import_data=True + download_data=True def pre_upload(self,data): diff --git a/myapp/views/view_nni.py b/myapp/views/view_nni.py index 8c6ed5aa..8daa0d8a 100644 --- a/myapp/views/view_nni.py +++ b/myapp/views/view_nni.py @@ -717,10 +717,9 @@ class NNI_ModelView(NNI_ModelView_Base,MyappModelView): conv = GeneralModelConverter(datamodel) -appbuilder.add_separator("训练") # 在指定菜单栏下面的每个子菜单中间添加一个分割线的显示。 # 添加视图和菜单 # appbuilder.add_view(NNI_ModelView,"nni超参搜索",icon = 'fa-shopping-basket',category = '超参搜索',category_icon = 'fa-share-alt') -appbuilder.add_view(NNI_ModelView,"nni超参搜索",icon = 'fa-shopping-basket',category = '训练') +appbuilder.add_view_no_menu(NNI_ModelView) # appbuilder.add_view_no_menu(NNI_ModelView) # 添加api diff --git a/myapp/views/view_notebook.py b/myapp/views/view_notebook.py index 909f8c90..34a6e46c 100644 --- a/myapp/views/view_notebook.py +++ b/myapp/views/view_notebook.py @@ -267,7 +267,7 @@ class Notebook_ModelView_Base(): db.session.commit() def post_list(self,items): - flash('注意:notebook会定时清理,如要运行长期任务请在pipeline中创建任务流进行。个人持久化目录在/mnt/%s/下'%g.user.username,category='warning') + flash('注意:notebook会定时清理,如要运行长期任务请在pipeline中创建任务流进行。
个人持久化目录在/mnt/%s/下'%g.user.username,category='warning') # items.sort(key=lambda item:item.created_by.username==g.user.username,reverse=True) return items @@ -549,7 +549,7 @@ class Notebook_ModelView_Base(): class Notebook_ModelView(Notebook_ModelView_Base,MyappModelView,DeleteMixin): datamodel = SQLAInterface(Notebook) # 添加视图和菜单 -appbuilder.add_view(Notebook_ModelView,"notebook",href="/notebook_modelview/list/?_flt_0_created_by=",icon = 'fa-file-code-o',category = '在线开发',category_icon = 'fa-code') +appbuilder.add_view_no_menu(Notebook_ModelView) # 添加api