feat: execute node python version
This commit is contained in:
@@ -33,6 +33,14 @@ export type ScheduleForm = {
|
||||
failurePolicy: "stop" | "continue";
|
||||
};
|
||||
|
||||
export type PythonVersion = "3.8" | "3.10" | "3.12";
|
||||
|
||||
export const PYTHON_VERSION_OPTIONS: readonly PythonVersion[] = [
|
||||
"3.8",
|
||||
"3.10",
|
||||
"3.12",
|
||||
];
|
||||
|
||||
export type NodeForm = {
|
||||
nodeName: string;
|
||||
timeoutSeconds: string;
|
||||
@@ -40,6 +48,7 @@ export type NodeForm = {
|
||||
retryIntervalSec: string;
|
||||
argumentsJson: string;
|
||||
envRefsJson: string;
|
||||
pythonVersion: PythonVersion;
|
||||
};
|
||||
|
||||
export type NodePositionDraft = {
|
||||
@@ -77,6 +86,7 @@ export const EMPTY_NODE_FORM: NodeForm = {
|
||||
retryIntervalSec: "5",
|
||||
argumentsJson: "{}",
|
||||
envRefsJson: "{}",
|
||||
pythonVersion: "3.12",
|
||||
};
|
||||
|
||||
// ---- Module-level non-reactive holders ----
|
||||
@@ -124,6 +134,7 @@ function nodeToForm(node: ScheduleNode): NodeForm {
|
||||
retryIntervalSec: String(node.retry_interval_sec),
|
||||
argumentsJson: JSON.stringify(node.arguments_json ?? {}, null, 2),
|
||||
envRefsJson: JSON.stringify(node.env_refs_json ?? {}, null, 2),
|
||||
pythonVersion: (node.python_version ?? "3.12") as PythonVersion,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -855,6 +866,7 @@ export const useSchedulesStore = create<State & Actions>((set, get) => {
|
||||
position_y: Math.max(20, Math.round(positionY)),
|
||||
arguments_json: {},
|
||||
env_refs_json: {},
|
||||
python_version: "3.12",
|
||||
}),
|
||||
`${artifact.script_name} 已加入画布`,
|
||||
);
|
||||
@@ -883,6 +895,9 @@ export const useSchedulesStore = create<State & Actions>((set, get) => {
|
||||
if (!Number.isInteger(retryIntervalSec) || retryIntervalSec < 0) {
|
||||
throw new Error("重试间隔必须是非负整数");
|
||||
}
|
||||
if (!PYTHON_VERSION_OPTIONS.includes(nodeForm.pythonVersion)) {
|
||||
throw new Error("Python 版本必须是 3.8 / 3.10 / 3.12");
|
||||
}
|
||||
const argumentsJson = parseObject(nodeForm.argumentsJson, "运行参数");
|
||||
const rawEnv = parseObject(nodeForm.envRefsJson, "环境引用");
|
||||
const envRefsJson = Object.fromEntries(
|
||||
@@ -907,6 +922,7 @@ export const useSchedulesStore = create<State & Actions>((set, get) => {
|
||||
retry_interval_sec: retryIntervalSec,
|
||||
arguments_json: argumentsJson,
|
||||
env_refs_json: envRefsJson,
|
||||
python_version: nodeForm.pythonVersion,
|
||||
},
|
||||
),
|
||||
"节点配置已保存",
|
||||
|
||||
Reference in New Issue
Block a user