mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
refactor: Add native Python runner runtime env var (#19109)
This commit is contained in:
@@ -3,7 +3,6 @@ import { NodesConfig, TaskRunnersConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import set from 'lodash/set';
|
||||
import {
|
||||
type INodeProperties,
|
||||
NodeConnectionTypes,
|
||||
UserError,
|
||||
type CodeExecutionMode,
|
||||
@@ -26,7 +25,7 @@ import { PythonTaskRunnerSandbox } from './PythonTaskRunnerSandbox';
|
||||
import { getSandboxContext } from './Sandbox';
|
||||
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 {
|
||||
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 {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Code',
|
||||
@@ -108,7 +70,35 @@ export class Code implements INodeType {
|
||||
],
|
||||
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',
|
||||
name: 'language',
|
||||
|
||||
Reference in New Issue
Block a user