feat(task): auto-inject scheduling params into script template via scheduling_map
Add scheduling_map field to ParameterSchema so Application creators can declare that a parameter (e.g. NP) maps to a scheduling field (e.g. cpus). The backend auto-injects the scheduling value into script template variables before rendering, eliminating duplicate user input. The frontend hides mapped parameters from the form and injects their values on submit.
This commit is contained in:
@@ -6,6 +6,7 @@ export interface ParameterSchema {
|
||||
default?: string
|
||||
options?: string[]
|
||||
description?: string
|
||||
scheduling_map?: string
|
||||
}
|
||||
|
||||
export interface Application {
|
||||
|
||||
@@ -124,7 +124,7 @@ const selectedApp = computed(() => appList.value.find(a => a.id === selectedAppI
|
||||
const autoParams = new Set(['WORK_DIR'])
|
||||
|
||||
const visibleParams = computed(() =>
|
||||
(selectedApp.value?.parameters || []).filter((p: any) => !autoParams.has(p.name))
|
||||
(selectedApp.value?.parameters || []).filter((p: any) => !autoParams.has(p.name) && !p.scheduling_map)
|
||||
)
|
||||
|
||||
const fileParams = computed(() =>
|
||||
@@ -159,12 +159,32 @@ onMounted(async () => {
|
||||
}
|
||||
})
|
||||
|
||||
const resolveSchedMapValue = (mapField: string): string | undefined => {
|
||||
switch (mapField) {
|
||||
case 'cpus': return form.cpus != null ? String(form.cpus) : undefined
|
||||
case 'memory_per_node': return form.memory_per_node != null ? String(form.memory_per_node) : undefined
|
||||
case 'nodes': return form.nodes || undefined
|
||||
case 'tasks': return form.tasks != null ? String(form.tasks) : undefined
|
||||
case 'cpus_per_task': return form.cpus_per_task != null ? String(form.cpus_per_task) : undefined
|
||||
case 'partition': return form.partition || undefined
|
||||
default: return undefined
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!selectedAppId.value) { ElMessage.warning('请选择应用'); return }
|
||||
submitting.value = true
|
||||
try {
|
||||
const taskName = form.task_name.trim() || `task_${selectedAppId.value}_${Date.now()}`
|
||||
const mergedValues = { ...values.value, ...fileParamMapping.value }
|
||||
// Auto-inject scheduling_map values
|
||||
const schedParams = (selectedApp.value?.parameters || []).filter((p: any) => p.scheduling_map)
|
||||
for (const p of schedParams) {
|
||||
const val = resolveSchedMapValue(p.scheduling_map)
|
||||
if (val !== undefined && val !== '') {
|
||||
mergedValues[p.name] = val
|
||||
}
|
||||
}
|
||||
const resp = await createTask({ ...form, task_name: taskName, job_name: taskName, app_id: selectedAppId.value, values: mergedValues, file_ids: selectedFiles.value.map(f => f.id) })
|
||||
if (resp.success) {
|
||||
ElMessage.success('任务提交成功')
|
||||
|
||||
Reference in New Issue
Block a user