fix: get_module_dbname returns pipeline for all modules

This commit is contained in:
yumoqing 2026-07-18 23:48:23 +08:00
parent 668bc55ed8
commit ffd36a3c51
14 changed files with 124 additions and 20 deletions

View File

@ -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():

View File

@ -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():

View File

@ -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",

View File

@ -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",

View File

@ -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))"
}]
}]
}

View File

@ -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",

View File

@ -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",

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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}
]
}
}

View File

@ -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