Просмотр исходного кода

fix: fetching more than one output image asked for a file named "a.png,b.png"

Downloading a job's outputs failed with a 404 naming a file that was two
paths joined by a comma. The server was fine and so was the job: the paths
setting is a list, and the usual way to fill it is one entry holding an
expression for the job's whole outputs array - so what arrived was a list
containing a list, and the inner list was turned into a single string.

Flattening fixes it. This only ever showed with more than one output, which
is why every batch count of 1 worked and the first job with two did not, and
why waiting longer did not help - the job had finished and the files were on
disk all along.

The error message pointed at {{$json.outputs}}, a variable this engine does
not have, which is no help to someone trying to fill the field in by hand
after a failure. It now names the two forms that work and says why running
the node on its own leaves it empty - there is no job in front of it to read,
which is the second thing that happened here.

Verified against the running server with a batch count of 2: both images
downloaded, 674KB and 699KB. 60/60.
fszontagh 1 месяц назад
Родитель
Сommit
29ab01115e
1 измененных файлов с 14 добавлено и 7 удалено
  1. 14 7
      nodes/sdcpp/sdcpp-fetch-output.js

+ 14 - 7
nodes/sdcpp/sdcpp-fetch-output.js

@@ -44,7 +44,7 @@ const configSchema = {
         paths: {
         paths: {
             type: 'array',
             type: 'array',
             title: 'Output Paths',
             title: 'Output Paths',
-            description: 'Relative output paths from a finished job, normally {{$json.outputs}} from an SD.cpp Wait For Job node. A comma separated string works too',
+            description: 'Relative output paths from a finished job. One entry holding {{data.outputs}} is the usual way - that is the whole list from the SD.cpp Wait For Job node in front of this one. A comma separated string works too',
             items: { type: 'string' }
             items: { type: 'string' }
         },
         },
         limit: {
         limit: {
@@ -181,20 +181,25 @@ function login(server, credential, timeout) {
     return session.token;
     return session.token;
 }
 }
 
 
+// The paths setting is a list, and the usual way to fill it is one entry
+// holding an expression for a job's whole outputs array - so what arrives is a
+// list containing a list. Flattening is not tidiness: without it the inner list
+// becomes one string, "a.png,b.png", and the server is asked for a file by that
+// name and answers 404. It only showed up once a job returned more than one
+// image, which is why a batch count of 1 never hit it.
 function toPathList(value) {
 function toPathList(value) {
     if (value === undefined || value === null || value === '') {
     if (value === undefined || value === null || value === '') {
         return [];
         return [];
     }
     }
+
     if (Array.isArray(value)) {
     if (Array.isArray(value)) {
-        const list = [];
+        let list = [];
         for (let i = 0; i < value.length; i++) {
         for (let i = 0; i < value.length; i++) {
-            const entry = String(value[i] || '').trim();
-            if (entry) {
-                list.push(entry);
-            }
+            list = list.concat(toPathList(value[i]));
         }
         }
         return list;
         return list;
     }
     }
+
     return String(value).split(',')
     return String(value).split(',')
         .map(function (entry) { return entry.trim(); })
         .map(function (entry) { return entry.trim(); })
         .filter(function (entry) { return entry.length > 0; });
         .filter(function (entry) { return entry.length > 0; });
@@ -251,7 +256,9 @@ async function execute(config, input, context) {
     let paths = toPathList(config.paths);
     let paths = toPathList(config.paths);
     if (paths.length === 0) {
     if (paths.length === 0) {
         throw new Error('SD.cpp: no output paths were given. Pass the outputs array from a ' +
         throw new Error('SD.cpp: no output paths were given. Pass the outputs array from a ' +
-            'finished job, such as {{$json.outputs}}');
+            'finished job - {{data.outputs}} when this node follows SD.cpp Wait For Job, or ' +
+            '{{$node["SD.cpp Wait For Job"].outputs}} from anywhere else. Running this node on ' +
+            'its own leaves it empty, because there is no job in front of it to read');
     }
     }
 
 
     const limit = config.limit > 0 ? config.limit : 0;
     const limit = config.limit > 0 ? config.limit : 0;