From ffd36a3c51adf6548a9f35977dd75a8e543f9be2 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 18 Jul 2026 23:48:23 +0800 Subject: [PATCH] fix: get_module_dbname returns pipeline for all modules --- app/global_func.py | 4 +- app/pipeline_app.py | 6 +- pipeline_core/wwwroot/pipeline_steps/index.ui | 2 +- .../wwwroot/pipeline_versions/index.ui | 2 +- pipeline_core/wwwroot/pipelines/index.ui | 22 ++++++- .../wwwroot/pipeline_capacity/index.ui | 4 +- .../wwwroot/pipeline_pricing/index.ui | 8 +-- .../wwwroot/pipeline_usage_log/index.ui | 4 +- .../pipelines/create_pipeline.dspy | 5 ++ .../pipelines/delete_pipeline.dspy | 5 ++ .../pipeline_core/pipelines/get_llm_list.dspy | 8 +++ .../pipelines/get_pipelines.dspy | 11 ++++ wwwroot/pipeline_core/pipelines/index.ui | 58 +++++++++++++++++++ .../pipelines/update_pipeline.dspy | 5 ++ 14 files changed, 124 insertions(+), 20 deletions(-) create mode 100644 wwwroot/pipeline_core/pipelines/create_pipeline.dspy create mode 100644 wwwroot/pipeline_core/pipelines/delete_pipeline.dspy create mode 100644 wwwroot/pipeline_core/pipelines/get_llm_list.dspy create mode 100644 wwwroot/pipeline_core/pipelines/get_pipelines.dspy create mode 100644 wwwroot/pipeline_core/pipelines/index.ui create mode 100644 wwwroot/pipeline_core/pipelines/update_pipeline.dspy diff --git a/app/global_func.py b/app/global_func.py index 5ac05c7..fdf8779 100644 --- a/app/global_func.py +++ b/app/global_func.py @@ -12,9 +12,7 @@ def password_encode(s): def get_module_dbname(mname): - if 'pipeline' in mname: - return 'pipeline' - return 'sage' + return 'pipeline' def set_globalvariable(): diff --git a/app/pipeline_app.py b/app/pipeline_app.py index d7d371d..5c8ef16 100644 --- a/app/pipeline_app.py +++ b/app/pipeline_app.py @@ -12,10 +12,8 @@ from ahserver.serverenv import ServerEnv def get_module_dbname(mname): - """Map module name to database. Pipeline business modules use 'pipeline', shared services use 'sage'.""" - if 'pipeline' in mname: - return 'pipeline' - return 'sage' + """All modules use the pipeline database.""" + return 'pipeline' def init(): diff --git a/pipeline_core/wwwroot/pipeline_steps/index.ui b/pipeline_core/wwwroot/pipeline_steps/index.ui index 4e2f82d..f0e6f1f 100644 --- a/pipeline_core/wwwroot/pipeline_steps/index.ui +++ b/pipeline_core/wwwroot/pipeline_steps/index.ui @@ -89,7 +89,7 @@ "valueField": "pipeline_id", "textField": "pipeline_id_text", "params": { - "dbname": "{{get_module_dbname('pipeline_core')}}", + "dbname": "{{'sage'}}", "table": "pipelines", "tblvalue": "id", "tbltext": "name", diff --git a/pipeline_core/wwwroot/pipeline_versions/index.ui b/pipeline_core/wwwroot/pipeline_versions/index.ui index 05c27a9..79265b7 100644 --- a/pipeline_core/wwwroot/pipeline_versions/index.ui +++ b/pipeline_core/wwwroot/pipeline_versions/index.ui @@ -87,7 +87,7 @@ "valueField": "pipeline_id", "textField": "pipeline_id_text", "params": { - "dbname": "{{get_module_dbname('pipeline_core')}}", + "dbname": "{{'sage'}}", "table": "pipelines", "tblvalue": "id", "tbltext": "name", diff --git a/pipeline_core/wwwroot/pipelines/index.ui b/pipeline_core/wwwroot/pipelines/index.ui index 436c9b7..1f7e465 100644 --- a/pipeline_core/wwwroot/pipelines/index.ui +++ b/pipeline_core/wwwroot/pipelines/index.ui @@ -18,6 +18,16 @@ "css":"card", + "toolbar":{ + "tools":[ + { + "name":"publish", + "label":"发布", + "selected_row":true + } + ] + }, + "editable":{ "new_data_url":"{{entire_url('add_pipelines.dspy')}}", @@ -98,7 +108,7 @@ "valueField": "pipeline_type", "textField": "pipeline_type_text", "params": { - "dbname": "{{get_module_dbname('pipeline_core')}}", + "dbname": "{{{{get_module_dbname('pipeline_core')}}}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", @@ -131,7 +141,7 @@ "valueField": "status", "textField": "status_text", "params": { - "dbname": "{{get_module_dbname('pipeline_core')}}", + "dbname": "{{{{get_module_dbname('pipeline_core')}}}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", @@ -222,7 +232,13 @@ "cache_limit":5 } - ,"binds":[] + ,"binds":[{ + "wid":"self", + "event":"publish", + "actiontype":"script", + "target":"self", + "script":"var d=this.select_row.user_data;fetch('{{entire_url('../api/pipeline_publish.dspy')}}',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'pipeline_id='+encodeURIComponent(d.id)}).then(function(r){return r.json()}).then(function(r){if(r.success){this.render({})}else{bricks.show_error({title:'发布失败',message:r.message||'未知错误'})}}.bind(this))" + }] }] } \ No newline at end of file diff --git a/pipeline_ops/wwwroot/pipeline_capacity/index.ui b/pipeline_ops/wwwroot/pipeline_capacity/index.ui index 635448f..b23b9fe 100644 --- a/pipeline_ops/wwwroot/pipeline_capacity/index.ui +++ b/pipeline_ops/wwwroot/pipeline_capacity/index.ui @@ -88,7 +88,7 @@ "valueField": "pipeline_id", "textField": "pipeline_id_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "pipelines", "tblvalue": "id", "tbltext": "name", @@ -153,7 +153,7 @@ "valueField": "status", "textField": "status_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", diff --git a/pipeline_ops/wwwroot/pipeline_pricing/index.ui b/pipeline_ops/wwwroot/pipeline_pricing/index.ui index 9a54979..924fd5d 100644 --- a/pipeline_ops/wwwroot/pipeline_pricing/index.ui +++ b/pipeline_ops/wwwroot/pipeline_pricing/index.ui @@ -109,7 +109,7 @@ "valueField": "pipeline_id", "textField": "pipeline_id_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "pipelines", "tblvalue": "id", "tbltext": "name", @@ -129,7 +129,7 @@ "valueField": "pricing_type", "textField": "pricing_type_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", @@ -177,7 +177,7 @@ "valueField": "currency", "textField": "currency_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", @@ -225,7 +225,7 @@ "valueField": "status", "textField": "status_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", diff --git a/pipeline_ops/wwwroot/pipeline_usage_log/index.ui b/pipeline_ops/wwwroot/pipeline_usage_log/index.ui index 50bc9e2..52c8778 100644 --- a/pipeline_ops/wwwroot/pipeline_usage_log/index.ui +++ b/pipeline_ops/wwwroot/pipeline_usage_log/index.ui @@ -102,7 +102,7 @@ "valueField": "pipeline_id", "textField": "pipeline_id_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "pipelines", "tblvalue": "id", "tbltext": "name", @@ -183,7 +183,7 @@ "valueField": "status", "textField": "status_text", "params": { - "dbname": "{{get_module_dbname('pipeline_ops')}}", + "dbname": "{{'sage'}}", "table": "appcodes_kv", "tblvalue": "k", "tbltext": "v", diff --git a/wwwroot/pipeline_core/pipelines/create_pipeline.dspy b/wwwroot/pipeline_core/pipelines/create_pipeline.dspy new file mode 100644 index 0000000..ef6e24b --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/create_pipeline.dspy @@ -0,0 +1,5 @@ +func = create_pipeline +if func is None: + return json.dumps({'status': 'error', 'message': 'function not found'}) +result = await func(params_kw) +return result diff --git a/wwwroot/pipeline_core/pipelines/delete_pipeline.dspy b/wwwroot/pipeline_core/pipelines/delete_pipeline.dspy new file mode 100644 index 0000000..3a07d83 --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/delete_pipeline.dspy @@ -0,0 +1,5 @@ +func = delete_pipeline +if func is None: + return json.dumps({'status': 'error', 'message': 'function not found'}) +result = await func(params_kw) +return result diff --git a/wwwroot/pipeline_core/pipelines/get_llm_list.dspy b/wwwroot/pipeline_core/pipelines/get_llm_list.dspy new file mode 100644 index 0000000..aae52b1 --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/get_llm_list.dspy @@ -0,0 +1,8 @@ +from sqlor.dbpools import DBPools + +async def main(): + dbname = get_module_dbname('pipeline_core') + async with DBPools().sqlorContext(dbname) as sor: + recs = await sor.R('llm', {'status': 'active'}) + result = [{'value': r.api_base or '', 'text': r.name, 'api_base': r.api_base or '', 'name': r.name, 'provider': r.provider} for r in recs] + return json.dumps(result) diff --git a/wwwroot/pipeline_core/pipelines/get_pipelines.dspy b/wwwroot/pipeline_core/pipelines/get_pipelines.dspy new file mode 100644 index 0000000..3e2f2b8 --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/get_pipelines.dspy @@ -0,0 +1,11 @@ +from sqlor.dbpools import DBPools + +async def main(): + dbname = get_module_dbname('pipeline_core') + async with DBPools().sqlorContext(dbname) as sor: + recs = await sor.R('pipelines', {'status': 'published'}) + if not recs: + recs = await sor.R('pipelines', {}) + if not recs: + recs = [] + return recs diff --git a/wwwroot/pipeline_core/pipelines/index.ui b/wwwroot/pipeline_core/pipelines/index.ui new file mode 100644 index 0000000..0cb6ec3 --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/index.ui @@ -0,0 +1,58 @@ +{ + "widgettype": "Tabular", + "id": "pipelines_tbl", + "options": { + "width": "100%", + "title": "产线定义", + "css": "card", + "data_url": "{{entire_url('./get_pipelines.dspy')}}", + "data_method": "GET", + "editable": { + "new_data_url": "{{entire_url('./create_pipeline.dspy')}}", + "update_data_url": "{{entire_url('./update_pipeline.dspy')}}", + "delete_data_url": "{{entire_url('./delete_pipeline.dspy')}}" + }, + "browserfields": { + "exclouded": ["id", "model_api_key", "pipeline_config"], + "alters": { + "pipeline_type": { + "uitype": "code", + "data": [ + {"value": "dev", "text": "开发"}, + {"value": "test", "text": "测试"}, + {"value": "ktv", "text": "KTV"}, + {"value": "deploy", "text": "部署"}, + {"value": "ops", "text": "运维"} + ] + }, + "status": { + "uitype": "code", + "data": [ + {"value": "draft", "text": "草稿"}, + {"value": "published", "text": "已发布"}, + {"value": "archived", "text": "已归档"} + ] + }, + "model_api_url": { + "uitype": "code", + "dataurl": "{{entire_url('./get_llm_list.dspy')}}", + "valueField": "api_base", + "textField": "name" + } + } + }, + "editexclouded": ["id", "created_at", "updated_at"], + "fields": [ + {"name": "id", "title": "ID", "type": "str", "cwidth": 0}, + {"name": "name", "title": "产线名称", "type": "str", "cwidth": 18}, + {"name": "description", "title": "描述", "type": "str", "cwidth": 18}, + {"name": "pipeline_type", "title": "产线类型", "type": "str", "cwidth": 12}, + {"name": "version", "title": "版本", "type": "str", "cwidth": 10}, + {"name": "status", "title": "状态", "type": "str", "cwidth": 10}, + {"name": "org_id", "title": "所属机构", "type": "str", "cwidth": 10}, + {"name": "created_by", "title": "创建人", "type": "str", "cwidth": 10}, + {"name": "created_at", "title": "创建时间", "type": "str", "cwidth": 14}, + {"name": "updated_at", "title": "更新时间", "type": "str", "cwidth": 14} + ] + } +} diff --git a/wwwroot/pipeline_core/pipelines/update_pipeline.dspy b/wwwroot/pipeline_core/pipelines/update_pipeline.dspy new file mode 100644 index 0000000..ed3b6c0 --- /dev/null +++ b/wwwroot/pipeline_core/pipelines/update_pipeline.dspy @@ -0,0 +1,5 @@ +func = update_pipeline +if func is None: + return json.dumps({'status': 'error', 'message': 'function not found'}) +result = await func(params_kw) +return result