@forzalabs/remora 1.0.9 → 1.0.11

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.
@@ -62,6 +62,7 @@ class ExecutorOrchestratorClass {
62
62
  this.init();
63
63
  const executorResults = [];
64
64
  const sourceFilesByProducer = yield this.readySourceFiles(consumer);
65
+ let globalWorkerIndex = 0;
65
66
  for (const pair of sourceFilesByProducer) {
66
67
  const { prod, cProd, response } = pair;
67
68
  // Make sure that the data files are there, if missing and isOptional = true, then skip
@@ -75,12 +76,15 @@ class ExecutorOrchestratorClass {
75
76
  const firstLine = (yield DriverHelper_1.default.quickReadFile(response.files[0].fullUri, 1))[0];
76
77
  const header = ProducerExecutor_1.default.processHeader(firstLine, prod);
77
78
  const prodDimensions = ProducerExecutor_1.default.reconcileHeader(header, prod);
78
- for (const file of response.files) {
79
+ const totalFiles = response.files.length;
80
+ for (const [fileIndex, file] of response.files.entries()) {
79
81
  const chunks = ExecutorOrchestrator.scopeWork(file.fullUri);
80
82
  const workerThreads = [];
81
- for (const [index, chunk] of chunks.entries()) {
83
+ for (const chunk of chunks) {
82
84
  // Spawn off thread
83
- const workerId = `${usageId}_${index}`;
85
+ const workerId = `${usageId}_${globalWorkerIndex}`;
86
+ const currentWorkerIndex = globalWorkerIndex;
87
+ globalWorkerIndex++;
84
88
  const workerData = {
85
89
  chunk,
86
90
  consumer,
@@ -89,10 +93,10 @@ class ExecutorOrchestratorClass {
89
93
  workerId: workerId,
90
94
  options: options
91
95
  };
92
- _progress.register((index + 1).toString());
96
+ _progress.register((currentWorkerIndex + 1).toString(), prod.name, fileIndex, totalFiles);
93
97
  workersId.push(workerId);
94
98
  workerThreads.push(this._executorPool.exec('executor', [workerData], {
95
- on: payload => this.onWorkAdvanced(payload, index, _progress)
99
+ on: payload => this.onWorkAdvanced(payload, currentWorkerIndex, _progress)
96
100
  }));
97
101
  }
98
102
  executorResults.push(...yield Promise.all(workerThreads));
@@ -6,11 +6,12 @@ class ExecutorProgress {
6
6
  this._FPS = 2;
7
7
  this._lastRenderTime = 0;
8
8
  this._lastRenderedLines = -1;
9
- this.register = (name) => {
10
- this.workers[name] = 0;
9
+ this.register = (name, producerName, fileIndex, totalFiles) => {
10
+ this.workers[name] = { progress: 0, producerName, fileIndex, totalFiles };
11
11
  };
12
12
  this.update = (name, value) => {
13
- this.workers[name] = value;
13
+ if (this.workers[name])
14
+ this.workers[name].progress = value;
14
15
  const now = Date.now();
15
16
  const interval = 1000 / this._FPS;
16
17
  if (now - this._lastRenderTime >= interval) {
@@ -20,7 +21,7 @@ class ExecutorProgress {
20
21
  };
21
22
  this.complete = () => {
22
23
  for (const key of Object.keys(this.workers)) {
23
- this.workers[key] = 1;
24
+ this.workers[key].progress = 1;
24
25
  }
25
26
  this.render();
26
27
  };
@@ -35,13 +36,14 @@ class ExecutorProgress {
35
36
  }
36
37
  this._lastRenderedLines = 0;
37
38
  for (const key of Object.keys(this.workers)) {
38
- const wrk = this.workers[key] * 100;
39
- const percentage = Math.min(100, Math.max(0, wrk));
39
+ const worker = this.workers[key];
40
+ const percentage = Math.min(100, Math.max(0, worker.progress * 100));
40
41
  const barWidth = 30;
41
42
  const filledWidth = Math.floor((percentage / 100) * barWidth);
42
43
  const emptyWidth = barWidth - filledWidth;
43
44
  const bar = '#'.repeat(filledWidth) + '-'.repeat(emptyWidth);
44
- console.log(`Worker ${key.padStart(2, '0')}: [${bar}] ${percentage.toFixed(2)}%`);
45
+ const fileInfo = worker.totalFiles > 1 ? ` [${worker.fileIndex + 1}/${worker.totalFiles}]` : '';
46
+ console.log(`Worker ${key.padStart(2, '0')}: [${bar}] ${percentage.toFixed(2)}% (${worker.producerName}${fileInfo})`);
45
47
  this._lastRenderedLines++;
46
48
  }
47
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forzalabs/remora",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "A powerful CLI tool for seamless data translation.",
5
5
  "main": "index.js",
6
6
  "private": false,