@lage-run/reporters 0.2.42 → 0.2.43

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,37 @@
2
2
  "name": "@lage-run/reporters",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 06 Dec 2022 23:28:03 GMT",
5
+ "date": "Thu, 08 Dec 2022 00:49:16 GMT",
6
+ "tag": "@lage-run/reporters_v0.2.43",
7
+ "version": "0.2.43",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/reporters",
13
+ "commit": "ad281dfe8b222d949130821828a680d1c3625154",
14
+ "comment": "adding some more niceties to progress reporter"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Tue, 06 Dec 2022 23:33:47 GMT",
21
+ "tag": "@lage-run/reporters_v0.2.42",
22
+ "version": "0.2.42",
23
+ "comments": {
24
+ "none": [
25
+ {
26
+ "author": "renovate@whitesourcesoftware.com",
27
+ "package": "@lage-run/reporters",
28
+ "commit": "07c1993552c81082c2717146ce0ff57a7a2eba1b",
29
+ "comment": "Update devDependency @types/react to v18.0.26"
30
+ }
31
+ ]
32
+ }
33
+ },
34
+ {
35
+ "date": "Tue, 06 Dec 2022 23:28:12 GMT",
6
36
  "tag": "@lage-run/reporters_v0.2.42",
7
37
  "version": "0.2.42",
8
38
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @lage-run/reporters
2
2
 
3
- This log was last generated on Tue, 06 Dec 2022 23:28:03 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.2.43
8
+
9
+ Thu, 08 Dec 2022 00:49:16 GMT
10
+
11
+ ### Patches
12
+
13
+ - adding some more niceties to progress reporter (kchau@microsoft.com)
14
+
7
15
  ## 0.2.42
8
16
 
9
- Tue, 06 Dec 2022 23:28:03 GMT
17
+ Tue, 06 Dec 2022 23:28:12 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -11,8 +11,6 @@ export declare class ChromeTraceEventsReporter implements Reporter {
11
11
  private options;
12
12
  logStream: Writable;
13
13
  consoleLogStream: Writable;
14
- private threads;
15
- private targetIdThreadMap;
16
14
  private events;
17
15
  private outputFile;
18
16
  constructor(options: ChromeTraceEventsReporterOptions);
@@ -14,9 +14,6 @@ function _interopRequireDefault(obj) {
14
14
  default: obj
15
15
  };
16
16
  }
17
- function range(len) {
18
- return Array(len).fill(0).map((_, idx)=>idx + 1);
19
- }
20
17
  function hrTimeToMicroseconds(hr) {
21
18
  return hr[0] * 1e6 + hr[1] * 1e-3;
22
19
  }
@@ -48,7 +45,7 @@ class ChromeTraceEventsReporter {
48
45
  1000
49
46
  ]),
50
47
  pid: 1,
51
- tid: targetRun.threadId ?? 0
48
+ tid: targetRun.threadId
52
49
  };
53
50
  if (categorize) {
54
51
  event.cat += `,${categorize(targetRun)}`;
@@ -62,13 +59,11 @@ class ChromeTraceEventsReporter {
62
59
  constructor(options){
63
60
  this.options = options;
64
61
  this.consoleLogStream = process.stdout;
65
- this.targetIdThreadMap = new Map();
66
62
  this.events = {
67
63
  traceEvents: [],
68
64
  displayTimeUnit: "ms"
69
65
  };
70
66
  this.outputFile = options.outputFile ?? getTimeBasedFilename("profile");
71
- this.threads = range(options.concurrency);
72
67
  if (!_fs.default.existsSync(_path.default.dirname(this.outputFile))) {
73
68
  _fs.default.mkdirSync(_path.default.dirname(this.outputFile), {
74
69
  recursive: true
@@ -1,13 +1,17 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import EventEmitter from "events";
3
4
  import type { LogEntry, Reporter } from "@lage-run/logger";
4
5
  import type { SchedulerRunSummary } from "@lage-run/scheduler-types";
5
6
  export declare class ProgressReporter implements Reporter {
7
+ timer: NodeJS.Timeout;
8
+ startTime: [number, number];
6
9
  logEvent: EventEmitter;
7
10
  logEntries: Map<string, LogEntry<import("@lage-run/logger").LogStructuredData>[]>;
8
11
  constructor(options?: {
9
12
  concurrency: number;
10
13
  });
14
+ heartBeat: () => void;
11
15
  log(entry: LogEntry<any>): void;
12
16
  summarize(schedulerRunSummary: SchedulerRunSummary): void;
13
17
  }
@@ -67,6 +67,9 @@ class ProgressReporter {
67
67
  if (entry?.data?.target?.hidden) {
68
68
  return;
69
69
  }
70
+ if (entry.data && entry.data.schedulerRun) {
71
+ this.startTime = entry.data.schedulerRun.startTime;
72
+ }
70
73
  if (entry.data && entry.data.target && typeof entry.data.threadId !== "undefined") {
71
74
  this.logEvent.emit("status", entry);
72
75
  }
@@ -79,15 +82,27 @@ class ProgressReporter {
79
82
  schedulerRunSummary,
80
83
  logEntries: this.logEntries
81
84
  });
85
+ clearTimeout(this.timer);
82
86
  }
83
87
  constructor(options = {
84
88
  concurrency: 0
85
89
  }){
90
+ this.startTime = [
91
+ 0,
92
+ 0
93
+ ];
86
94
  this.logEvent = new _events.default();
87
95
  this.logEntries = new Map();
96
+ this.heartBeat = ()=>{
97
+ this.logEvent.emit("heartbeat", {
98
+ currentTime: process.hrtime(this.startTime)
99
+ });
100
+ this.timer = setTimeout(this.heartBeat, 1000);
101
+ };
88
102
  (0, _ink.render)(/*#__PURE__*/ _react.createElement(_progressReporterApp.ProgressReporterApp, {
89
103
  logEvent: this.logEvent,
90
104
  concurrency: options.concurrency
91
105
  }));
106
+ this.timer = setTimeout(this.heartBeat, 1000);
92
107
  }
93
108
  }
@@ -50,14 +50,25 @@ function _interopRequireWildcard(obj, nodeInterop) {
50
50
  }
51
51
  return newObj;
52
52
  }
53
+ function range(len) {
54
+ return Array(len).fill(0).map((_, idx)=>idx + 1);
55
+ }
53
56
  function ProgressReporterApp(props) {
54
- const [threadInfo, setThreadInfo] = _react.useState({});
57
+ const initialThreadInfo = range(props.concurrency).reduce((acc, threadId)=>{
58
+ acc[threadId] = "";
59
+ return acc;
60
+ }, {});
61
+ const [threadInfo, setThreadInfo] = _react.useState(initialThreadInfo);
55
62
  const [progress, setProgress] = _react.useState({
56
63
  waiting: 0,
57
64
  completed: 0,
58
65
  total: 0
59
66
  });
60
67
  const [summary, setSummary] = _react.useState();
68
+ const [currentTime, setCurrentTime] = _react.useState([
69
+ 0,
70
+ 0
71
+ ]);
61
72
  const { logEvent } = props;
62
73
  _react.useEffect(()=>{
63
74
  logEvent.on("status", (entry)=>{
@@ -67,7 +78,7 @@ function ProgressReporterApp(props) {
67
78
  ...threadInfo,
68
79
  [threadId]: target.id
69
80
  }));
70
- } else if (status === "success" || status === "aborted" || status === "failed") {
81
+ } else if (status === "success" || status === "aborted" || status === "failed" || status === "skipped") {
71
82
  setThreadInfo((threadInfo)=>{
72
83
  const newThreadInfo = {
73
84
  ...threadInfo
@@ -83,6 +94,9 @@ function ProgressReporterApp(props) {
83
94
  logEvent.on("summary", (summary)=>{
84
95
  setSummary(summary);
85
96
  });
97
+ logEvent.on("heartbeat", (heartbeat)=>{
98
+ setCurrentTime(heartbeat.currentTime);
99
+ });
86
100
  }, [
87
101
  logEvent
88
102
  ]);
@@ -90,9 +104,7 @@ function ProgressReporterApp(props) {
90
104
  const idleWorkerDummyThreadInfo = arrayGapLength > 0 ? new Array(arrayGapLength).fill(0) : [];
91
105
  return /*#__PURE__*/ _react.createElement(_ink.Box, {
92
106
  flexDirection: "column"
93
- }, /*#__PURE__*/ _react.createElement(_ink.Text, null, "Lage running tasks"), /*#__PURE__*/ _react.createElement(_ink.Text, {
94
- color: "yellow"
95
- }, "[warning: this progress reporter is currently in beta and unstable]"), summary ? /*#__PURE__*/ _react.createElement(_summaryInfo.SummaryInfo, {
107
+ }, /*#__PURE__*/ _react.createElement(_ink.Text, null, "Lage running tasks with ", props.concurrency, " workers"), summary ? /*#__PURE__*/ _react.createElement(_summaryInfo.SummaryInfo, {
96
108
  summary: summary
97
109
  }) : /*#__PURE__*/ _react.createElement(_ink.Box, {
98
110
  flexDirection: "column"
@@ -103,15 +115,18 @@ function ProgressReporterApp(props) {
103
115
  }, Object.entries(threadInfo).map(([threadId, targetId])=>{
104
116
  return /*#__PURE__*/ _react.createElement(_threadItem.ThreadItem, {
105
117
  key: threadId,
118
+ threadId: threadId,
106
119
  targetId: targetId
107
120
  });
108
121
  }), idleWorkerDummyThreadInfo.map((_, index)=>{
109
122
  return /*#__PURE__*/ _react.createElement(_react.Fragment, {
110
123
  key: `idle-${index}`
111
124
  }, /*#__PURE__*/ _react.createElement(_threadItem.ThreadItem, {
125
+ threadId: "?",
112
126
  targetId: ""
113
127
  }));
114
128
  })), /*#__PURE__*/ _react.createElement(_progressStatus.ProgressStatus, {
115
- progress: progress
129
+ progress: progress,
130
+ currentTime: currentTime
116
131
  })));
117
132
  }
@@ -2,7 +2,6 @@
2
2
  import { Progress } from "../types/progressBarTypes";
3
3
  export interface ProgressStatusProps {
4
4
  progress: Progress;
5
+ currentTime: [number, number];
5
6
  }
6
- export declare function ProgressStatus(props: {
7
- progress: Progress;
8
- }): JSX.Element;
7
+ export declare function ProgressStatus(props: ProgressStatusProps): JSX.Element;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "ProgressStatus", {
6
6
  enumerable: true,
7
7
  get: ()=>ProgressStatus
8
8
  });
9
+ const _formatHrtime = require("@lage-run/format-hrtime");
9
10
  const _ink = require("ink");
10
11
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
12
  function _getRequireWildcardCache(nodeInterop) {
@@ -50,6 +51,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
50
51
  function ProgressStatus(props) {
51
52
  const { waiting , completed , total } = props.progress;
52
53
  const percentage = total > 0 ? `${(completed / total * 100).toFixed(2)}%` : "0%";
53
- const status = `Waiting: ${waiting} | Completed: ${completed} | Total: ${total} | ${percentage}`;
54
+ const status = `Waiting: ${waiting} | Completed: ${completed} | Total: ${total} | ${percentage} | ${(0, _formatHrtime.formatDuration)((0, _formatHrtime.hrToSeconds)(props.currentTime))}`;
54
55
  return /*#__PURE__*/ _react.createElement(_ink.Box, null, /*#__PURE__*/ _react.createElement(_ink.Text, null, status));
55
56
  }
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  export declare function ThreadItem(props: {
3
+ threadId: string | number;
3
4
  targetId: string;
4
5
  }): JSX.Element;
@@ -48,10 +48,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
48
48
  return newObj;
49
49
  }
50
50
  function ThreadItem(props) {
51
- const { targetId } = props;
52
- return /*#__PURE__*/ _react.createElement(_ink.Box, null, targetId ? /*#__PURE__*/ _react.createElement(_ink.Text, {
51
+ const { targetId , threadId } = props;
52
+ return /*#__PURE__*/ _react.createElement(_ink.Box, null, /*#__PURE__*/ _react.createElement(_ink.Box, {
53
+ width: "2"
54
+ }, /*#__PURE__*/ _react.createElement(_ink.Text, null, threadId)), targetId ? /*#__PURE__*/ _react.createElement(_ink.Text, {
53
55
  color: "whiteBright"
54
- }, "[ ", targetId, " ]") : /*#__PURE__*/ _react.createElement(_ink.Text, {
56
+ }, targetId, " ") : /*#__PURE__*/ _react.createElement(_ink.Text, {
55
57
  color: "gray"
56
- }, "[ IDLE ]"));
58
+ }, "IDLE"));
57
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/reporters",
3
- "version": "0.2.42",
3
+ "version": "0.2.43",
4
4
  "description": "Log reporters for Lage",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"
@@ -26,7 +26,7 @@
26
26
  "react": "^18.2.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/react": "18.0.25",
29
+ "@types/react": "18.0.26",
30
30
  "memory-streams": "0.1.3"
31
31
  },
32
32
  "publishConfig": {