@workglow/task-graph 0.2.18 → 0.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bun.js CHANGED
@@ -1436,6 +1436,7 @@ class TaskRunner {
1436
1436
  timeoutTimer;
1437
1437
  pendingTimeoutError;
1438
1438
  shouldAccumulate = true;
1439
+ runWithPreviews = false;
1439
1440
  telemetrySpan;
1440
1441
  constructor(task) {
1441
1442
  this.task = task;
@@ -1718,6 +1719,7 @@ class TaskRunner {
1718
1719
  this.outputCache = cache;
1719
1720
  }
1720
1721
  this.shouldAccumulate = config.shouldAccumulate !== false;
1722
+ this.runWithPreviews = config.runWithPreviews === true;
1721
1723
  if (config.updateProgress) {
1722
1724
  this.updateProgress = config.updateProgress;
1723
1725
  }
@@ -2889,6 +2891,7 @@ class TaskGraphRunner {
2889
2891
  graph;
2890
2892
  outputCache;
2891
2893
  accumulateLeafOutputs = true;
2894
+ runWithPreviews = false;
2892
2895
  registry = globalServiceRegistry3;
2893
2896
  resourceScope;
2894
2897
  abortController;
@@ -3132,12 +3135,13 @@ class TaskGraphRunner {
3132
3135
  consumerCounts.set(port, (consumerCounts.get(port) ?? 0) + 1);
3133
3136
  }
3134
3137
  for (const [port, count] of consumerCounts) {
3135
- if (count <= 1)
3138
+ const extra = this.runWithPreviews ? count : count - 1;
3139
+ if (extra <= 0)
3136
3140
  continue;
3137
3141
  const value = results[port];
3138
3142
  const ref = asRefcountable(value);
3139
3143
  if (ref)
3140
- ref.retain(count - 1);
3144
+ ref.retain(extra);
3141
3145
  }
3142
3146
  }
3143
3147
  for (const dataflow of dataflows) {
@@ -3309,7 +3313,8 @@ class TaskGraphRunner {
3309
3313
  outputCache: this.outputCache ?? false,
3310
3314
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3311
3315
  registry: this.registry,
3312
- resourceScope: this.resourceScope
3316
+ resourceScope: this.resourceScope,
3317
+ runWithPreviews: this.runWithPreviews
3313
3318
  });
3314
3319
  await this.pushOutputFromNodeToEdges(task, results);
3315
3320
  return {
@@ -3359,7 +3364,8 @@ class TaskGraphRunner {
3359
3364
  shouldAccumulate,
3360
3365
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3361
3366
  registry: this.registry,
3362
- resourceScope: this.resourceScope
3367
+ resourceScope: this.resourceScope,
3368
+ runWithPreviews: this.runWithPreviews
3363
3369
  });
3364
3370
  await this.pushOutputFromNodeToEdges(task, results);
3365
3371
  return {
@@ -3434,6 +3440,17 @@ class TaskGraphRunner {
3434
3440
  }
3435
3441
  }
3436
3442
  resetTask(graph, task, runId) {
3443
+ const previous = task.runOutputData;
3444
+ if (previous) {
3445
+ for (const port of Object.keys(previous)) {
3446
+ const ref = asRefcountable(previous[port]);
3447
+ if (!ref)
3448
+ continue;
3449
+ try {
3450
+ ref.release();
3451
+ } catch {}
3452
+ }
3453
+ }
3437
3454
  task.status = TaskStatus.PENDING;
3438
3455
  task.resetInputData();
3439
3456
  task.runOutputData = {};
@@ -3467,6 +3484,7 @@ class TaskGraphRunner {
3467
3484
  this.resourceScope = config.resourceScope;
3468
3485
  }
3469
3486
  this.accumulateLeafOutputs = config?.accumulateLeafOutputs !== false;
3487
+ this.runWithPreviews = config?.runWithPreviews === true;
3470
3488
  if (config?.outputCache !== undefined) {
3471
3489
  if (typeof config.outputCache === "boolean") {
3472
3490
  if (config.outputCache === true) {
@@ -3566,6 +3584,7 @@ class TaskGraphRunner {
3566
3584
  throw new TaskConfigurationError(`Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`);
3567
3585
  }
3568
3586
  }
3587
+ this.runWithPreviews = false;
3569
3588
  this.previewScheduler.reset();
3570
3589
  this.previewRunning = true;
3571
3590
  }
@@ -3665,7 +3684,8 @@ class GraphAsTaskRunner extends TaskRunner {
3665
3684
  parentSignal: this.abortController?.signal,
3666
3685
  outputCache: this.outputCache,
3667
3686
  registry: this.registry,
3668
- resourceScope: this.resourceScope
3687
+ resourceScope: this.resourceScope,
3688
+ runWithPreviews: this.runWithPreviews
3669
3689
  });
3670
3690
  unsubscribe();
3671
3691
  return results;
@@ -4128,7 +4148,8 @@ class TaskGraph {
4128
4148
  registry: config?.registry,
4129
4149
  timeout: config?.timeout,
4130
4150
  maxTasks: config?.maxTasks,
4131
- resourceScope: config?.resourceScope
4151
+ resourceScope: config?.resourceScope,
4152
+ runWithPreviews: config?.runWithPreviews
4132
4153
  });
4133
4154
  }
4134
4155
  runPreview(input = {}, config = {}) {
@@ -4981,7 +5002,8 @@ class Workflow {
4981
5002
  parentSignal: this._abortController.signal,
4982
5003
  outputCache: this._outputCache,
4983
5004
  registry: config?.registry ?? this._registry,
4984
- resourceScope: config?.resourceScope
5005
+ resourceScope: config?.resourceScope,
5006
+ runWithPreviews: config?.runWithPreviews
4985
5007
  });
4986
5008
  const results = this.graph.mergeExecuteOutputsToRunOutput(output, PROPERTY_ARRAY);
4987
5009
  this.events.emit("complete");
@@ -8408,4 +8430,4 @@ export {
8408
8430
  BROWSER_GRANTS
8409
8431
  };
8410
8432
 
8411
- //# debugId=791136A32061C4D664756E2164756E21
8433
+ //# debugId=AA782C3ACDE0213064756E2164756E21