2021-08-17 17:00:34 +08:00
|
|
|
from flask_appbuilder import Model
|
|
|
|
from flask_babel import lazy_gettext as _
|
|
|
|
import re
|
2021-09-07 18:09:47 +08:00
|
|
|
from myapp.utils import core
|
2021-08-17 17:00:34 +08:00
|
|
|
|
|
|
|
class MyappModelBase():
|
|
|
|
|
|
|
|
label_columns={
|
|
|
|
"name": "名称",
|
|
|
|
"name_url": "名称",
|
|
|
|
"name_title": "名称(移动鼠标,查看描述)",
|
|
|
|
'job_type': '任务类型',
|
|
|
|
"project": "项目组",
|
|
|
|
"project_url":"项目组",
|
|
|
|
"namespace": "命名空间",
|
|
|
|
"namespace_url": "命名空间",
|
|
|
|
"describe": "描述",
|
|
|
|
"describe_url": "描述",
|
|
|
|
"password": '密码',
|
|
|
|
"workdir":"工作目录",
|
|
|
|
"images": "镜像",
|
|
|
|
"repository": "仓库",
|
|
|
|
"args": "启动参数",
|
|
|
|
"args_html": "启动参数",
|
|
|
|
"demo": "参数示例",
|
|
|
|
"demo_html": "参数示例",
|
|
|
|
"entrypoint": '启动命令',
|
|
|
|
"dockerfile": 'Dockerfile',
|
|
|
|
"gitpath": 'git地址',
|
|
|
|
"env": "环境变量",
|
|
|
|
"privileged": "特权模式",
|
|
|
|
"accounts": "k8s账号",
|
|
|
|
"images_url": "镜像",
|
|
|
|
"hostAliases": "host",
|
|
|
|
"overwrite_entrypoint": "覆盖原始启动命令",
|
|
|
|
"command": "启动命令",
|
|
|
|
"working_dir": "启动目录",
|
|
|
|
"volume_mount": "挂载目录",
|
|
|
|
"node_selector": "调度机器",
|
|
|
|
"image_pull_policy": "镜像拉取策略",
|
|
|
|
"resource_memory": "内存申请",
|
|
|
|
"resource_cpu": "cpu申请",
|
|
|
|
"resource_gpu": "gpu申请",
|
|
|
|
"resource":"资源",
|
|
|
|
"timeout": "超时中断",
|
|
|
|
"retry": "重试次数",
|
|
|
|
"outputs": "输出",
|
|
|
|
"version": "版本",
|
|
|
|
"model_name":"模型名称",
|
2022-02-26 22:36:57 +08:00
|
|
|
"model_version": "模型版本",
|
2021-08-17 17:00:34 +08:00
|
|
|
"model_path":"模型地址",
|
2022-02-26 22:36:57 +08:00
|
|
|
"model_name_url": "模型名称",
|
|
|
|
"model_version_url": "模型版本",
|
|
|
|
"model_path_url": "模型地址",
|
2021-08-17 17:00:34 +08:00
|
|
|
"embedding_file_path":"embedding文件地址",
|
|
|
|
"is_fallback":"兜底版本",
|
|
|
|
"check_service":"检查服务",
|
|
|
|
"status": "状态",
|
2022-02-26 22:36:57 +08:00
|
|
|
"model_status":"状态",
|
2021-09-07 18:09:47 +08:00
|
|
|
"status_url":"状态",
|
|
|
|
"final_status":"最终状态",
|
2021-08-17 17:00:34 +08:00
|
|
|
"pipeline": "任务流",
|
|
|
|
"pipeline_url": "任务流",
|
2022-08-02 16:02:22 +08:00
|
|
|
"etl_pipeline_url": "任务流",
|
2022-02-26 22:36:57 +08:00
|
|
|
"service_pipeline_url": "推理编排",
|
2021-08-17 17:00:34 +08:00
|
|
|
"run_id": "kfp运行id",
|
|
|
|
"run_time": "kfp运行时间",
|
|
|
|
"type": "类型",
|
|
|
|
"reset": "重置",
|
|
|
|
"user": "用户",
|
|
|
|
"role": "角色",
|
|
|
|
"dag_json": "流向图",
|
|
|
|
"dag_json_html": "流向图",
|
|
|
|
"username": "用户",
|
|
|
|
"schedule_type": "调度类型",
|
|
|
|
"cron_time": "调度周期",
|
|
|
|
"global_args": "全局参数",
|
|
|
|
"global_env": "全局环境变量",
|
|
|
|
"parallelism": "任务并行数",
|
|
|
|
"run_pipeline": "运行",
|
|
|
|
"status_more": "状态详情",
|
|
|
|
"status_more_html": "状态详情",
|
2021-09-07 18:09:47 +08:00
|
|
|
"execution_date":"执行时间",
|
|
|
|
"base_image":"基础镜像",
|
|
|
|
"tag":"tag",
|
|
|
|
"save":"保存",
|
|
|
|
"history":"历史",
|
|
|
|
"consecutive_build":"连续构建",
|
2021-10-14 17:33:57 +08:00
|
|
|
"need_gpu":"需要gpu",
|
|
|
|
"last_image":"最新镜像",
|
2021-11-25 18:04:34 +08:00
|
|
|
"expired_limit":"有效实例数目",
|
2022-02-26 22:36:57 +08:00
|
|
|
"canary":"分流",
|
2022-07-26 20:47:49 +08:00
|
|
|
"shadow": "流量复制",
|
2021-08-17 17:00:34 +08:00
|
|
|
"log": "日志",
|
|
|
|
"pod": "容器",
|
2021-09-07 18:09:47 +08:00
|
|
|
"ide_type": "IDE类型",
|
2021-08-17 17:00:34 +08:00
|
|
|
"annotations": "注释",
|
|
|
|
"annotations_html": "注释",
|
|
|
|
"spec": "属性",
|
|
|
|
"spec_html": "属性",
|
|
|
|
"info_json": "通知",
|
|
|
|
"info_json_html": "通知",
|
|
|
|
"labels": "标签",
|
|
|
|
"label": "标签",
|
|
|
|
"labels_html": "标签",
|
|
|
|
"label_url": "标签",
|
|
|
|
"add_row_time": "添加时间",
|
|
|
|
"experiment_id": "kfp实验id",
|
|
|
|
"pipeline_file": "workflow yaml",
|
|
|
|
"pipeline_file_html": "workflow yaml",
|
|
|
|
"pipeline_argo_id": "kfp任务流id",
|
|
|
|
"version_id": "kfp版本id",
|
|
|
|
"job_template": "任务模板",
|
|
|
|
"job_template_url": "任务模板",
|
2022-07-26 20:47:49 +08:00
|
|
|
"template": "功能模板",
|
2021-08-17 17:00:34 +08:00
|
|
|
"alert_status": "监控状态",
|
2022-07-26 20:47:49 +08:00
|
|
|
"task_args":"任务参数",
|
|
|
|
"url_html": "网址",
|
|
|
|
"url": "网址",
|
|
|
|
"public":"公开",
|
2021-09-07 18:09:47 +08:00
|
|
|
|
2021-08-17 17:00:34 +08:00
|
|
|
"alert_user": "通知用户",
|
|
|
|
"experiment": "Experiment yaml",
|
|
|
|
"experiment_html": "Experiment yaml",
|
|
|
|
"train_model": "训练模型",
|
|
|
|
"ip": "ip",
|
|
|
|
"deploy_time": "部署时间",
|
|
|
|
"host": "域名",
|
|
|
|
"host_url": "域名",
|
2022-02-26 22:36:57 +08:00
|
|
|
"inference_host_url":"域名:测试(test.xx)/调试(debug.xx)",
|
2021-08-17 17:00:34 +08:00
|
|
|
"deploy": "部署",
|
|
|
|
"test_deploy": "测试部署",
|
|
|
|
"prod_deploy": "生产部署",
|
|
|
|
"check_test_service": '检测测试服务',
|
|
|
|
"min_replicas": "最低副本数",
|
|
|
|
"max_replicas": "最高副本数",
|
2022-02-26 22:36:57 +08:00
|
|
|
"replicas": "副本数",
|
2021-08-17 17:00:34 +08:00
|
|
|
"ports": "端口",
|
|
|
|
"roll": "滚动发布",
|
|
|
|
"k8s_yaml": "yaml",
|
|
|
|
"service": "服务",
|
|
|
|
"download_url": "下载地址",
|
|
|
|
"metrics": "指标",
|
2022-02-26 22:36:57 +08:00
|
|
|
"metrics_html":"指标",
|
|
|
|
"operate_html":"操作",
|
2021-08-17 17:00:34 +08:00
|
|
|
"md5": "md5",
|
|
|
|
"service_type": "服务类型",
|
|
|
|
"job_args_definition":"模板参数定义示例",
|
|
|
|
"job_describe":"模板描述",
|
|
|
|
"job_args_demo": "模板参数示例",
|
|
|
|
"stop":"停止",
|
|
|
|
"parallel_trial_count": "并行搜索次数",
|
|
|
|
"max_trial_count": "最多搜索次数",
|
|
|
|
"max_failed_trial_count": "最多失败搜索次数",
|
|
|
|
"objective_type": "目标函数类型",
|
|
|
|
"objective_goal": "目标值",
|
|
|
|
"objective_metric_name": "目标度量",
|
|
|
|
"objective_additional_metric_names": "附加目标度量",
|
|
|
|
"algorithm_name": "搜索算法",
|
|
|
|
"algorithm_setting": "搜索算法配置",
|
|
|
|
"parameters": "超参数配置",
|
|
|
|
"parameters_demo": "超参配置示例",
|
|
|
|
"parameters_html": "超参数配置",
|
|
|
|
"job_json": "搜索任务配置",
|
|
|
|
"trial_spec": "任务 yaml",
|
|
|
|
"trial_spec_html": "任务 yaml",
|
|
|
|
"create_experiment": "启动调度",
|
|
|
|
"run_instance":"运行实例",
|
|
|
|
"monitoring": "监控",
|
|
|
|
"monitoring_html":"监控",
|
2021-11-25 18:04:34 +08:00
|
|
|
"monitoring_url":"监控",
|
2021-08-17 17:00:34 +08:00
|
|
|
"link": "链接",
|
|
|
|
"clear": "清理",
|
|
|
|
"expand":"扩展",
|
|
|
|
"expand_html":"扩展",
|
2021-09-07 18:09:47 +08:00
|
|
|
"parameter": "扩展参数",
|
|
|
|
"parameter_html": "扩展参数",
|
2021-08-17 17:00:34 +08:00
|
|
|
"renew":"续期",
|
|
|
|
"api_type":"接口类型",
|
|
|
|
"code_dir":"代码目录",
|
|
|
|
"id_url":"id",
|
|
|
|
"debug": "调试",
|
|
|
|
"run": "运行",
|
|
|
|
"run_url":"运行",
|
2021-09-07 18:09:47 +08:00
|
|
|
"depends_on_past":"过往依赖",
|
|
|
|
"max_active_runs": "最大激活运行数",
|
|
|
|
"des_image":"目标镜像",
|
|
|
|
"target_image":"目标镜像",
|
2021-11-25 18:04:34 +08:00
|
|
|
"image_history":"镜像历史",
|
|
|
|
"elapsed_time":"耗时",
|
|
|
|
"task_status":"任务状态",
|
2022-02-26 22:36:57 +08:00
|
|
|
"hpa":"弹性伸缩容",
|
|
|
|
"health":"健康检查",
|
|
|
|
"transformer":"处理变换",
|
|
|
|
"deploy_history":"部署记录",
|
|
|
|
"model_input": "模型输入",
|
|
|
|
"input_html":"输入",
|
|
|
|
"model_output": "模型输出",
|
|
|
|
"output_html": "输出",
|
|
|
|
"config":"配置",
|
|
|
|
"config_html": "配置",
|
|
|
|
"app":"产品",
|
2022-08-02 16:02:22 +08:00
|
|
|
"field": "领域",
|
2022-02-26 22:36:57 +08:00
|
|
|
"cluster": "集群",
|
|
|
|
"db_name":"数据库",
|
2022-07-26 20:47:49 +08:00
|
|
|
"database":"数据库",
|
2022-02-26 22:36:57 +08:00
|
|
|
"db": "数据库",
|
|
|
|
"metadata_db": "数据库",
|
|
|
|
"security_level":"安全等级",
|
|
|
|
"value_score":"价值评分",
|
|
|
|
"storage_size": "存储大小",
|
|
|
|
"warehouse_level": "数仓类型",
|
|
|
|
"crontab": "调度周期",
|
|
|
|
"cost":"数据成本",
|
|
|
|
"column_type": "列类型",
|
|
|
|
"remark":"备注",
|
|
|
|
"ttl": "保留时长",
|
|
|
|
"sql": "sql",
|
2022-08-02 16:02:22 +08:00
|
|
|
"sql_html": "sql",
|
2022-02-26 22:36:57 +08:00
|
|
|
"primary_part_col_name":"主分区列",
|
2022-08-02 16:02:22 +08:00
|
|
|
"app_group":"应用组",
|
|
|
|
"sql_demo":"sql示例",
|
|
|
|
"create_table_ddl":"建表sql",
|
|
|
|
"insert_sql": "数据导入sql",
|
|
|
|
"metric_type": "指标类型",
|
|
|
|
"metric_data_type":"指标数据类型",
|
|
|
|
"metric_dim": "指标维度",
|
|
|
|
"metric_level": "指标级别",
|
|
|
|
"metric_responsible":"指标责任人",
|
|
|
|
"caliber":"口径",
|
|
|
|
"is_partition":"是否分区列",
|
|
|
|
"partition_type":"分区类型",
|
|
|
|
"c_org_fullname":"组织架构",
|
|
|
|
"lifecycle":"当前生命周期(天)",
|
|
|
|
"rec_lifecycle":"推荐生命周期(天)",
|
|
|
|
"storage_cost":"存储成本(元/月)",
|
|
|
|
"visits_seven":"7日访问次数",
|
|
|
|
"recent_visit":"最近访问日期",
|
|
|
|
"partition_start":"分区开始时间",
|
|
|
|
"partition_end":"分区结束时间",
|
|
|
|
"visits_thirty":"30天访问次数",
|
|
|
|
"product_name":"产品名",
|
|
|
|
"product_id":"产品id",
|
|
|
|
"product_desc":"产品描述",
|
|
|
|
"active":"激活",
|
|
|
|
"job_worker_image":"工作镜像",
|
|
|
|
"job_worker_command": "启动命令",
|
|
|
|
"source_type":"数据源类型",
|
|
|
|
"priority":"优先级",
|
|
|
|
"owner": "责任人",
|
|
|
|
"industry":"行业",
|
2022-08-28 20:24:10 +08:00
|
|
|
"skip":"跳过",
|
2022-08-02 16:02:22 +08:00
|
|
|
"etl_pipeline": "任务流",
|
|
|
|
"etl_pipeline_id": "任务流id",
|
|
|
|
"etl_task": "任务",
|
|
|
|
"etl_task_id": "任务id",
|
2022-02-26 22:36:57 +08:00
|
|
|
"access":"接入",
|
2022-08-02 16:02:22 +08:00
|
|
|
"inference_config": "推理配置",
|
|
|
|
"file_type":"文件类型",
|
2022-02-26 22:36:57 +08:00
|
|
|
"responsible":"责任人",
|
2022-08-02 16:02:22 +08:00
|
|
|
"cycle_unit":"周期单位",
|
|
|
|
"task_type":"任务类型",
|
2022-08-22 13:28:23 +08:00
|
|
|
"help":"帮助",
|
2021-08-17 17:00:34 +08:00
|
|
|
"creator": "创建者",
|
|
|
|
"created_by": "创建者",
|
|
|
|
"changed_by": "修改者",
|
|
|
|
"created_on": "创建时间",
|
|
|
|
"create_time": "创建时间",
|
2022-08-02 16:02:22 +08:00
|
|
|
"update_time":"更新时间",
|
2021-08-17 17:00:34 +08:00
|
|
|
"changed_on": "修改时间",
|
2021-09-07 18:09:47 +08:00
|
|
|
"change_time":"更新时间",
|
2022-08-28 20:24:10 +08:00
|
|
|
"modified": "修改时间",
|
|
|
|
"cronjob_start_time":"补录起点"
|
2021-08-17 17:00:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# 获取列的中文显示
|
|
|
|
# @staticmethod
|
|
|
|
def lab(col,label_columns=label_columns):
|
|
|
|
if col in label_columns:
|
|
|
|
return _(label_columns[col])
|
|
|
|
return _(re.sub("[._]", " ", col).title())
|
2021-09-07 18:09:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
def get_default_node_selector(self,node_selector,resource_gpu,model_type):
|
2022-08-08 20:11:53 +08:00
|
|
|
# prefer already defined selectors
|
2021-09-07 18:09:47 +08:00
|
|
|
if not node_selector:
|
|
|
|
node_selector=''
|
|
|
|
|
2022-08-08 20:11:53 +08:00
|
|
|
# completely determined by the platform
|
2021-09-07 18:09:47 +08:00
|
|
|
if core.get_gpu(resource_gpu)[0]:
|
|
|
|
node_selector = node_selector.replace('cpu=true', 'gpu=true') + ",gpu=true,%s=true"%model_type
|
|
|
|
else:
|
|
|
|
node_selector = node_selector.replace('gpu=true', 'cpu=true') + ",cpu=true,%s=true"%model_type
|
|
|
|
if 'org' not in node_selector:
|
|
|
|
node_selector += ',org=public'
|
|
|
|
node_selector = re.split(',|;|\n|\t', str(node_selector))
|
|
|
|
node_selector = [selector.strip() for selector in node_selector if selector.strip()]
|
|
|
|
node_selector = ','.join(list(set(node_selector)))
|
|
|
|
return node_selector
|
|
|
|
|
|
|
|
|
|
|
|
|