@lage-run/scheduler 0.7.0 → 0.7.2

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/CHANGELOG.json CHANGED
@@ -2,7 +2,43 @@
2
2
  "name": "@lage-run/scheduler",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 05 Dec 2022 18:02:26 GMT",
5
+ "date": "Thu, 08 Dec 2022 00:49:16 GMT",
6
+ "tag": "@lage-run/scheduler_v0.7.2",
7
+ "version": "0.7.2",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/scheduler",
13
+ "commit": "ad281dfe8b222d949130821828a680d1c3625154",
14
+ "comment": "sets the default to progress"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Tue, 06 Dec 2022 00:48:02 GMT",
21
+ "tag": "@lage-run/scheduler_v0.7.1",
22
+ "version": "0.7.1",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "author": "kchau@microsoft.com",
27
+ "package": "@lage-run/scheduler",
28
+ "commit": "3fa4b9c8aa67cbc2198385e32fa38de123541f09",
29
+ "comment": "creating the beginnings of a progress reporter - it's in beta"
30
+ },
31
+ {
32
+ "author": "beachball",
33
+ "package": "@lage-run/scheduler",
34
+ "comment": "Bump @lage-run/scheduler-types to v0.2.10",
35
+ "commit": "3fa4b9c8aa67cbc2198385e32fa38de123541f09"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Mon, 05 Dec 2022 18:02:35 GMT",
6
42
  "tag": "@lage-run/scheduler_v0.7.0",
7
43
  "version": "0.7.0",
8
44
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # Change Log - @lage-run/scheduler
2
2
 
3
- This log was last generated on Mon, 05 Dec 2022 18:02:26 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 08 Dec 2022 00:49:16 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.7.2
8
+
9
+ Thu, 08 Dec 2022 00:49:16 GMT
10
+
11
+ ### Patches
12
+
13
+ - sets the default to progress (kchau@microsoft.com)
14
+
15
+ ## 0.7.1
16
+
17
+ Tue, 06 Dec 2022 00:48:02 GMT
18
+
19
+ ### Patches
20
+
21
+ - creating the beginnings of a progress reporter - it's in beta (kchau@microsoft.com)
22
+ - Bump @lage-run/scheduler-types to v0.2.10
23
+
7
24
  ## 0.7.0
8
25
 
9
- Mon, 05 Dec 2022 18:02:26 GMT
26
+ Mon, 05 Dec 2022 18:02:35 GMT
10
27
 
11
28
  ### Minor changes
12
29
 
@@ -40,6 +40,7 @@ export declare class SimpleScheduler implements TargetScheduler {
40
40
  abortController: AbortController;
41
41
  abortSignal: AbortSignal;
42
42
  pool: Pool;
43
+ workerIds: number[];
43
44
  runPromise: Promise<any>;
44
45
  constructor(options: SimpleSchedulerOptions);
45
46
  getTargetsByPriority(): import("@lage-run/target-graph").Target[];
@@ -62,6 +63,7 @@ export declare class SimpleScheduler implements TargetScheduler {
62
63
  getReadyTargets(): WrappedTarget[];
63
64
  isAllDone(): boolean;
64
65
  scheduleReadyTargets(): Promise<void>;
66
+ logProgress(): void;
65
67
  cleanup(): Promise<void>;
66
68
  /**
67
69
  * Abort the scheduler using the abort controller.
@@ -45,6 +45,11 @@ class SimpleScheduler {
45
45
  */ async run(root, targetGraph, shouldRerun = false) {
46
46
  const startTime = process.hrtime();
47
47
  const { continueOnError , logger , cacheProvider , shouldCache , shouldResetCache , hasher } = this.options;
48
+ logger.verbose("", {
49
+ schedulerRun: {
50
+ startTime
51
+ }
52
+ });
48
53
  const { pool , abortController } = this;
49
54
  const { targets } = targetGraph;
50
55
  for (const target of targets.values()){
@@ -93,9 +98,7 @@ class SimpleScheduler {
93
98
  error = e instanceof Error ? e.message : String(e);
94
99
  } finally{
95
100
  duration = process.hrtime(startTime);
96
- targetRunByStatus = (0, _categorizeTargetRunsJs.categorizeTargetRuns)([
97
- ...this.targetRuns.values()
98
- ]);
101
+ targetRunByStatus = (0, _categorizeTargetRunsJs.categorizeTargetRuns)(this.targetRuns.values());
99
102
  if (targetRunByStatus.failed.length + targetRunByStatus.aborted.length + targetRunByStatus.pending.length + targetRunByStatus.running.length === 0) {
100
103
  results = "success";
101
104
  }
@@ -171,6 +174,20 @@ class SimpleScheduler {
171
174
  }
172
175
  await Promise.all(promises);
173
176
  }
177
+ logProgress() {
178
+ const targetRunByStatus = (0, _categorizeTargetRunsJs.categorizeTargetRuns)(this.targetRuns.values());
179
+ const total = [
180
+ ...this.targetRuns.values()
181
+ ].filter((t)=>!t.target.hidden).length;
182
+ this.options.logger.verbose("", {
183
+ poolStats: this.pool.stats(),
184
+ progress: {
185
+ waiting: targetRunByStatus.pending.length + targetRunByStatus.queued.length,
186
+ completed: targetRunByStatus.aborted.length + targetRunByStatus.failed.length + targetRunByStatus.skipped.length + targetRunByStatus.success.length,
187
+ total
188
+ }
189
+ });
190
+ }
174
191
  async cleanup() {
175
192
  this.options.logger.silly(`Max Worker Memory Usage: ${(0, _formatBytesJs.formatBytes)(this.pool.stats().maxWorkerMemoryUsage)}`);
176
193
  await this.pool.close();
@@ -203,10 +220,13 @@ class SimpleScheduler {
203
220
  },
204
221
  workerIdleMemoryLimit: options.workerIdleMemoryLimit
205
222
  });
223
+ this.workerIds = Array(options.concurrency).fill(0).map((_, idx)=>idx + 1);
206
224
  }
207
225
  }
208
226
  async function generateTargetRunPromise(target) {
209
227
  let runError;
228
+ const threadId = this.workerIds.shift();
229
+ target.threadId = threadId;
210
230
  if (target.result && target.successful && !this.rerunTargets.has(target.target.id)) {
211
231
  await target.result;
212
232
  } else {
@@ -228,6 +248,9 @@ async function generateTargetRunPromise(target) {
228
248
  }
229
249
  }
230
250
  }
251
+ this.workerIds.unshift(threadId);
252
+ this.workerIds.sort();
253
+ this.logProgress();
231
254
  // finally do another round of scheduling to run next round of targets
232
255
  await this.scheduleReadyTargets();
233
256
  }
@@ -31,6 +31,7 @@ export declare class WrappedTarget implements TargetRun {
31
31
  duration: [number, number];
32
32
  target: Target;
33
33
  status: TargetStatus;
34
+ threadId: number;
34
35
  result: Promise<{
35
36
  stdoutBuffer: string;
36
37
  stderrBuffer: string;
@@ -39,7 +39,8 @@ class WrappedTarget {
39
39
  this.duration = process.hrtime(this.startTime);
40
40
  this.options.logger.info("aborted", {
41
41
  target: this.target,
42
- status: "aborted"
42
+ status: "aborted",
43
+ threadId: this.threadId
43
44
  });
44
45
  }
45
46
  onStart() {
@@ -48,7 +49,8 @@ class WrappedTarget {
48
49
  this.startTime = process.hrtime();
49
50
  this.options.logger.info("running", {
50
51
  target: this.target,
51
- status: "running"
52
+ status: "running",
53
+ threadId: this.threadId
52
54
  });
53
55
  }
54
56
  }
@@ -58,7 +60,8 @@ class WrappedTarget {
58
60
  this.options.logger.info("success", {
59
61
  target: this.target,
60
62
  status: "success",
61
- duration: this.duration
63
+ duration: this.duration,
64
+ threadId: this.threadId
62
65
  });
63
66
  }
64
67
  onFail() {
@@ -67,7 +70,8 @@ class WrappedTarget {
67
70
  this.options.logger.info("failed", {
68
71
  target: this.target,
69
72
  status: "failed",
70
- duration: this.duration
73
+ duration: this.duration,
74
+ threadId: this.threadId
71
75
  });
72
76
  if (!this.options.continueOnError && this.options.abortController) {
73
77
  this.options.abortController.abort();
@@ -80,7 +84,8 @@ class WrappedTarget {
80
84
  target: this.target,
81
85
  status: "skipped",
82
86
  duration: this.duration,
83
- hash
87
+ hash,
88
+ threadId: this.threadId
84
89
  });
85
90
  }
86
91
  async getCache() {
@@ -192,14 +197,16 @@ class WrappedTarget {
192
197
  stdout.pipe(bufferStdout.transform);
193
198
  stderr.pipe(bufferStderr.transform);
194
199
  const releaseStdoutStream = logger.stream(_logger.LogLevel.verbose, stdout, {
195
- target
200
+ target,
201
+ threadId: this.threadId
196
202
  });
197
203
  releaseStdout = ()=>{
198
204
  releaseStdoutStream();
199
205
  stdout.unpipe(bufferStdout.transform);
200
206
  };
201
207
  const releaseStderrStream = logger.stream(_logger.LogLevel.verbose, stderr, {
202
- target
208
+ target,
209
+ threadId: this.threadId
203
210
  });
204
211
  releaseStderr = ()=>{
205
212
  releaseStderrStream();
@@ -241,6 +248,7 @@ class WrappedTarget {
241
248
  0,
242
249
  0
243
250
  ];
251
+ this.threadId = 0;
244
252
  this.status = "pending";
245
253
  this.target = options.target;
246
254
  }
@@ -1,2 +1,2 @@
1
1
  import type { TargetRunSummary, TargetRun } from "@lage-run/scheduler-types";
2
- export declare function categorizeTargetRuns(targetRuns: TargetRun[]): TargetRunSummary;
2
+ export declare function categorizeTargetRuns<T extends TargetRun>(targetRuns: IterableIterator<T>): TargetRunSummary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/scheduler",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Scheduler for Lage",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"
@@ -21,7 +21,7 @@
21
21
  "@lage-run/worker-threads-pool": "^0.5.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@lage-run/scheduler-types": "^0.2.9",
24
+ "@lage-run/scheduler-types": "^0.2.10",
25
25
  "monorepo-scripts": "*"
26
26
  },
27
27
  "publishConfig": {