mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor: Add native Python runner runtime env var (#19109)
This commit is contained in:
@@ -60,6 +60,7 @@ export interface FrontendSettings {
|
|||||||
versionCli: string;
|
versionCli: string;
|
||||||
nodeJsVersion: string;
|
nodeJsVersion: string;
|
||||||
concurrency: number;
|
concurrency: number;
|
||||||
|
isNativePythonRunnerEnabled: boolean;
|
||||||
authCookie: {
|
authCookie: {
|
||||||
secure: boolean;
|
secure: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ export class FrontendService {
|
|||||||
nodeJsVersion: process.version.replace(/^v/, ''),
|
nodeJsVersion: process.version.replace(/^v/, ''),
|
||||||
versionCli: N8N_VERSION,
|
versionCli: N8N_VERSION,
|
||||||
concurrency: this.globalConfig.executions.concurrency.productionLimit,
|
concurrency: this.globalConfig.executions.concurrency.productionLimit,
|
||||||
|
isNativePythonRunnerEnabled:
|
||||||
|
this.globalConfig.taskRunners.enabled && process.env.N8N_NATIVE_PYTHON_RUNNER === 'true',
|
||||||
authCookie: {
|
authCookie: {
|
||||||
secure: this.globalConfig.auth.cookie.secure,
|
secure: this.globalConfig.auth.cookie.secure,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ export const defaultSettings: FrontendSettings = {
|
|||||||
versionCli: '',
|
versionCli: '',
|
||||||
nodeJsVersion: '',
|
nodeJsVersion: '',
|
||||||
concurrency: -1,
|
concurrency: -1,
|
||||||
|
isNativePythonRunnerEnabled: false,
|
||||||
versionNotifications: {
|
versionNotifications: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
endpoint: '',
|
endpoint: '',
|
||||||
|
|||||||
@@ -241,6 +241,11 @@ const parameterOptions = computed(() => {
|
|||||||
const options = hasRemoteMethod.value ? remoteParameterOptions.value : props.parameter.options;
|
const options = hasRemoteMethod.value ? remoteParameterOptions.value : props.parameter.options;
|
||||||
const safeOptions = (options ?? []).filter(isValidParameterOption);
|
const safeOptions = (options ?? []).filter(isValidParameterOption);
|
||||||
|
|
||||||
|
// temporary filter until native Python runner is GA
|
||||||
|
if (props.parameter.name === 'language' && !settingsStore.isNativePythonRunnerEnabled) {
|
||||||
|
return safeOptions.filter((o) => o.value !== 'pythonNative');
|
||||||
|
}
|
||||||
|
|
||||||
return safeOptions;
|
return safeOptions;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
|||||||
|
|
||||||
const concurrency = computed(() => settings.value.concurrency);
|
const concurrency = computed(() => settings.value.concurrency);
|
||||||
|
|
||||||
|
const isNativePythonRunnerEnabled = computed(() => settings.value.isNativePythonRunnerEnabled);
|
||||||
|
|
||||||
const isConcurrencyEnabled = computed(() => concurrency.value !== -1);
|
const isConcurrencyEnabled = computed(() => concurrency.value !== -1);
|
||||||
|
|
||||||
const isPublicApiEnabled = computed(() => api.value.enabled);
|
const isPublicApiEnabled = computed(() => api.value.enabled);
|
||||||
@@ -329,6 +331,7 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, () => {
|
|||||||
security,
|
security,
|
||||||
nodeJsVersion,
|
nodeJsVersion,
|
||||||
concurrency,
|
concurrency,
|
||||||
|
isNativePythonRunnerEnabled,
|
||||||
isConcurrencyEnabled,
|
isConcurrencyEnabled,
|
||||||
isPublicApiEnabled,
|
isPublicApiEnabled,
|
||||||
isSwaggerUIEnabled,
|
isSwaggerUIEnabled,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { NodesConfig, TaskRunnersConfig } from '@n8n/config';
|
|||||||
import { Container } from '@n8n/di';
|
import { Container } from '@n8n/di';
|
||||||
import set from 'lodash/set';
|
import set from 'lodash/set';
|
||||||
import {
|
import {
|
||||||
type INodeProperties,
|
|
||||||
NodeConnectionTypes,
|
NodeConnectionTypes,
|
||||||
UserError,
|
UserError,
|
||||||
type CodeExecutionMode,
|
type CodeExecutionMode,
|
||||||
@@ -26,7 +25,7 @@ import { PythonTaskRunnerSandbox } from './PythonTaskRunnerSandbox';
|
|||||||
import { getSandboxContext } from './Sandbox';
|
import { getSandboxContext } from './Sandbox';
|
||||||
import { addPostExecutionWarning, standardizeOutput } from './utils';
|
import { addPostExecutionWarning, standardizeOutput } from './utils';
|
||||||
|
|
||||||
const { CODE_ENABLE_STDOUT, N8N_NATIVE_PYTHON_RUNNER } = process.env;
|
const { CODE_ENABLE_STDOUT } = process.env;
|
||||||
|
|
||||||
class PythonDisabledError extends UserError {
|
class PythonDisabledError extends UserError {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -36,43 +35,6 @@ class PythonDisabledError extends UserError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getV2LanguageProperty = (): INodeProperties => {
|
|
||||||
const options = [
|
|
||||||
{
|
|
||||||
name: 'JavaScript',
|
|
||||||
value: 'javaScript',
|
|
||||||
action: 'Code in JavaScript',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Python (Beta)',
|
|
||||||
value: 'python',
|
|
||||||
action: 'Code in Python (Beta)',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
if (N8N_NATIVE_PYTHON_RUNNER === 'true') {
|
|
||||||
options.push({
|
|
||||||
name: 'Python (Native) (Beta)',
|
|
||||||
value: 'pythonNative',
|
|
||||||
action: 'Code in Python (Native) (Beta)',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
displayName: 'Language',
|
|
||||||
name: 'language',
|
|
||||||
type: 'options',
|
|
||||||
noDataExpression: true,
|
|
||||||
displayOptions: {
|
|
||||||
show: {
|
|
||||||
'@version': [2],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
options,
|
|
||||||
default: 'javaScript',
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export class Code implements INodeType {
|
export class Code implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'Code',
|
displayName: 'Code',
|
||||||
@@ -108,7 +70,35 @@ export class Code implements INodeType {
|
|||||||
],
|
],
|
||||||
default: 'runOnceForAllItems',
|
default: 'runOnceForAllItems',
|
||||||
},
|
},
|
||||||
getV2LanguageProperty(),
|
{
|
||||||
|
displayName: 'Language',
|
||||||
|
name: 'language',
|
||||||
|
type: 'options',
|
||||||
|
noDataExpression: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'@version': [2],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'JavaScript',
|
||||||
|
value: 'javaScript',
|
||||||
|
action: 'Code in JavaScript',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Python (Beta)',
|
||||||
|
value: 'python',
|
||||||
|
action: 'Code in Python (Beta)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Python (Native) (Beta)',
|
||||||
|
value: 'pythonNative',
|
||||||
|
action: 'Code in Python (Native) (Beta)',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'javaScript',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Language',
|
displayName: 'Language',
|
||||||
name: 'language',
|
name: 'language',
|
||||||
|
|||||||
Reference in New Issue
Block a user