Merge pull request #657 from HaveAGitGat/tags

Add tags plugins
make-only-subtitle-default
HaveAGitGat 2 years ago committed by GitHub
commit 98858a2542
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'Tags: Requeue',
description: "\nPlace the file back in the staging queue with specific tags.\n\nOnly Nodes/Workers which match the tags will be able to process the file.\n\nThe tags must have one of the following: 'requireCPU', 'requireGPU', or 'requireCPUorGPU'.\n\nThe above tells the server what type of worker is required to process the file.\n\nSubsequent tags must not use the reserved word 'require' in them.\n\nYou can set the 'Node Tags' in the Node options panel.\n\nThe the item tags in the staging section must be a subset of the required tags for a worker to process the file.\n",
style: {
borderColor: 'yellow',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.20.01',
sidebarPosition: -1,
icon: 'faRedo',
inputs: [
{
label: 'Use Basic Queue Tags',
name: 'useBasicQueueTags',
type: 'boolean',
defaultValue: 'true',
inputUI: {
type: 'switch',
},
tooltip: 'Use basic queue tags or custom tags.',
},
{
label: 'Basic Queue Tags',
name: 'basicQueueTags',
type: 'string',
defaultValue: 'requireCPU',
inputUI: {
type: 'dropdown',
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'useBasicQueueTags',
value: 'true',
condition: '===',
},
],
},
],
},
options: [
'requireCPU',
'requireGPU',
'requireGPU:nvenc',
'requireGPU:qsv',
'requireGPU:vaapi',
'requireGPU:videotoolbox',
'requireGPU:amf',
'requireCPUorGPU',
],
},
tooltip: 'Specify tags to requeue file with.',
},
{
label: 'Custom Queue Tags',
name: 'customQueueTags',
type: 'string',
defaultValue: 'requireCPUorGPU,tag1',
inputUI: {
type: 'textarea',
style: {
height: '100px',
},
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'useBasicQueueTags',
value: 'true',
condition: '!==',
},
],
},
],
},
},
tooltip: "\nrequireGPU:nvenc,tag1,tag2\nrequireCPUorGPU,tag1,tag2\nrequireCPU,tag1,tag2\nrequireGPU,tag1,tag2,tag3\nrequireGPU,tag1\nrequireGPU,{{{args.userVariables.global.test}}}\nrequireCPUorGPU,tag1,tag2\n ",
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
}); };
exports.details = details;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var plugin = function (args) {
var lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
var basicQueueTags = String(args.inputs.basicQueueTags);
var customQueueTags = String(args.inputs.customQueueTags);
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = args.inputs.useBasicQueueTags ? basicQueueTags : customQueueTags;
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
exports.plugin = plugin;

@ -0,0 +1,117 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.plugin = exports.details = void 0;
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
var details = function () { return ({
name: 'Tags: Worker Type',
description: "\nRequeues the item into the staging section if the current worker\ndoes not match the required worker type and tags.\n\nYou can set the 'Node Tags' in the Node options panel.\n\nThe current tags must be a subset of the required tags.\n ",
style: {
borderColor: 'yellow',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.20.01',
sidebarPosition: -1,
icon: 'faFilter',
inputs: [
{
label: 'Required Transcode Worker Type',
name: 'requiredWorkerType',
type: 'string',
defaultValue: 'CPUorGPU',
inputUI: {
type: 'dropdown',
options: [
'CPUorGPU',
'CPU',
'GPU',
'GPU:nvenc',
'GPU:qsv',
'GPU:vaapi',
'GPU:videotoolbox',
'GPU:amf',
],
},
tooltip: 'Specify worker type',
},
{
label: 'Required Node Tags',
name: 'requiredNodeTags',
type: 'string',
defaultValue: '',
inputUI: {
type: 'textarea',
style: {
height: '100px',
},
},
tooltip: "\ntag1,tag2\n ",
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
}); };
exports.details = details;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
var plugin = function (args) {
var lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
var requiredWorkerType = String(args.inputs.requiredWorkerType);
var requiredNodeTags = String(args.inputs.requiredNodeTags);
var requiredTags = [];
var currentTags = [];
requiredTags.push("require".concat(requiredWorkerType));
if (requiredNodeTags) {
requiredTags = requiredTags.concat(requiredNodeTags.split(',').map(function (tag) { return tag.trim(); }));
}
var currentWorkerType = args.workerType;
if (requiredWorkerType === 'CPUorGPU') {
currentTags.push('requireCPUorGPU');
}
else if (currentWorkerType === 'transcodecpu') {
currentTags.push('requireCPU');
}
else if (currentWorkerType === 'transcodegpu') {
if (args.nodeHardwareType && args.nodeHardwareType !== '-') {
currentTags.push("requireGPU:".concat(args.nodeHardwareType));
}
else {
currentTags.push('requireGPU');
}
}
if (args.nodeTags) {
currentTags = currentTags.concat(args.nodeTags.split(',').map(function (tag) { return tag.trim(); }));
}
args.jobLog("Required Tags: ".concat(requiredTags.join(',')));
args.jobLog("Current Tags: ".concat(currentTags.join(',')));
var isSubset = true;
for (var i = 0; i < currentTags.length; i += 1) {
if (!requiredTags.includes(currentTags[i])) {
isSubset = false;
break;
}
}
if (isSubset) {
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = '';
args.jobLog('Worker type and tags are subset of required tags');
}
else {
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = requiredTags.join(',');
args.jobLog('Worker type and tags are not subset of required tags,'
+ " requeueing with tags ".concat(args.variables.queueTags));
}
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
exports.plugin = plugin;

@ -0,0 +1,146 @@
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Tags: Requeue',
description: `
Place the file back in the staging queue with specific tags.
Only Nodes/Workers which match the tags will be able to process the file.
The tags must have one of the following: 'requireCPU', 'requireGPU', or 'requireCPUorGPU'.
The above tells the server what type of worker is required to process the file.
Subsequent tags must not use the reserved word 'require' in them.
You can set the 'Node Tags' in the Node options panel.
The the item tags in the staging section must be a subset of the required tags for a worker to process the file.
`,
style: {
borderColor: 'yellow',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.20.01',
sidebarPosition: -1,
icon: 'faRedo',
inputs: [
{
label: 'Use Basic Queue Tags',
name: 'useBasicQueueTags',
type: 'boolean',
defaultValue: 'true',
inputUI: {
type: 'switch',
},
tooltip: 'Use basic queue tags or custom tags.',
},
{
label: 'Basic Queue Tags',
name: 'basicQueueTags',
type: 'string',
defaultValue: 'requireCPU',
inputUI: {
type: 'dropdown',
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'useBasicQueueTags',
value: 'true',
condition: '===',
},
],
},
],
},
options: [
'requireCPU',
'requireGPU',
'requireGPU:nvenc',
'requireGPU:qsv',
'requireGPU:vaapi',
'requireGPU:videotoolbox',
'requireGPU:amf',
'requireCPUorGPU',
],
},
tooltip: 'Specify tags to requeue file with.',
},
{
label: 'Custom Queue Tags',
name: 'customQueueTags',
type: 'string',
defaultValue: 'requireCPUorGPU,tag1',
inputUI: {
type: 'textarea',
style: {
height: '100px',
},
displayConditions: {
logic: 'AND',
sets: [
{
logic: 'AND',
inputs: [
{
name: 'useBasicQueueTags',
value: 'true',
condition: '!==',
},
],
},
],
},
},
tooltip: `
requireGPU:nvenc,tag1,tag2
requireCPUorGPU,tag1,tag2
requireCPU,tag1,tag2
requireGPU,tag1,tag2,tag3
requireGPU,tag1
requireGPU,{{{args.userVariables.global.test}}}
requireCPUorGPU,tag1,tag2
`,
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
const basicQueueTags = String(args.inputs.basicQueueTags);
const customQueueTags = String(args.inputs.customQueueTags);
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = args.inputs.useBasicQueueTags ? basicQueueTags : customQueueTags;
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};

@ -0,0 +1,139 @@
import {
IpluginDetails,
IpluginInputArgs,
IpluginOutputArgs,
} from '../../../../FlowHelpers/1.0.0/interfaces/interfaces';
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = (): IpluginDetails => ({
name: 'Tags: Worker Type',
description: `
Requeues the item into the staging section if the current worker
does not match the required worker type and tags.
You can set the 'Node Tags' in the Node options panel.
The current tags must be a subset of the required tags.
`,
style: {
borderColor: 'yellow',
},
tags: '',
isStartPlugin: false,
pType: '',
requiresVersion: '2.20.01',
sidebarPosition: -1,
icon: 'faFilter',
inputs: [
{
label: 'Required Transcode Worker Type',
name: 'requiredWorkerType',
type: 'string',
defaultValue: 'CPUorGPU',
inputUI: {
type: 'dropdown',
options: [
'CPUorGPU',
'CPU',
'GPU',
'GPU:nvenc',
'GPU:qsv',
'GPU:vaapi',
'GPU:videotoolbox',
'GPU:amf',
],
},
tooltip: 'Specify worker type',
},
{
label: 'Required Node Tags',
name: 'requiredNodeTags',
type: 'string',
defaultValue: '',
inputUI: {
type: 'textarea',
style: {
height: '100px',
},
},
tooltip: `
tag1,tag2
`,
},
],
outputs: [
{
number: 1,
tooltip: 'Continue to next plugin',
},
],
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
const lib = require('../../../../../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
const requiredWorkerType = String(args.inputs.requiredWorkerType);
const requiredNodeTags = String(args.inputs.requiredNodeTags);
let requiredTags = [];
let currentTags = [];
requiredTags.push(`require${requiredWorkerType}`);
if (requiredNodeTags) {
requiredTags = requiredTags.concat(requiredNodeTags.split(',').map((tag) => tag.trim()));
}
const currentWorkerType = args.workerType;
if (requiredWorkerType === 'CPUorGPU') {
currentTags.push('requireCPUorGPU');
} else if (currentWorkerType === 'transcodecpu') {
currentTags.push('requireCPU');
} else if (currentWorkerType === 'transcodegpu') {
if (args.nodeHardwareType && args.nodeHardwareType !== '-') {
currentTags.push(`requireGPU:${args.nodeHardwareType}`);
} else {
currentTags.push('requireGPU');
}
}
if (args.nodeTags) {
currentTags = currentTags.concat(args.nodeTags.split(',').map((tag) => tag.trim()));
}
args.jobLog(`Required Tags: ${requiredTags.join(',')}`);
args.jobLog(`Current Tags: ${currentTags.join(',')}`);
let isSubset = true;
for (let i = 0; i < currentTags.length; i += 1) {
if (!requiredTags.includes(currentTags[i])) {
isSubset = false;
break;
}
}
if (isSubset) {
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = '';
args.jobLog('Worker type and tags are subset of required tags');
} else {
// eslint-disable-next-line no-param-reassign
args.variables.queueTags = requiredTags.join(',');
args.jobLog('Worker type and tags are not subset of required tags,'
+ ` requeueing with tags ${args.variables.queueTags}`);
}
return {
outputFileObj: args.inputFileObj,
outputNumber: 1,
variables: args.variables,
};
};
export {
details,
plugin,
};

@ -101,6 +101,7 @@ export interface Ivariables {
flowFailed: boolean, flowFailed: boolean,
user: Record<string, string>, user: Record<string, string>,
healthCheck?: 'Success', healthCheck?: 'Success',
queueTags?: string,
} }
export interface IpluginOutputArgs { export interface IpluginOutputArgs {
@ -126,6 +127,7 @@ export interface IpluginInputArgs {
originalLibraryFile: IFileObject, originalLibraryFile: IFileObject,
nodeHardwareType: string, nodeHardwareType: string,
workerType: string, workerType: string,
nodeTags?: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
config: any, config: any,
job: Ijob, job: Ijob,

Loading…
Cancel
Save