@lage-run/reporters 0.2.43 → 0.2.44

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,22 @@
2
2
  "name": "@lage-run/reporters",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 08 Dec 2022 00:49:16 GMT",
5
+ "date": "Thu, 05 Jan 2023 00:40:39 GMT",
6
+ "tag": "@lage-run/reporters_v0.2.44",
7
+ "version": "0.2.44",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "author": "kchau@microsoft.com",
12
+ "package": "@lage-run/reporters",
13
+ "commit": "961843bef658c51312e02498554ad338e467e1a7",
14
+ "comment": "fixing progress bar to not be a bottleneck"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Thu, 08 Dec 2022 00:49:28 GMT",
6
21
  "tag": "@lage-run/reporters_v0.2.43",
7
22
  "version": "0.2.43",
8
23
  "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 Thu, 08 Dec 2022 00:49:16 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 05 Jan 2023 00:40:39 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.2.44
8
+
9
+ Thu, 05 Jan 2023 00:40:39 GMT
10
+
11
+ ### Patches
12
+
13
+ - fixing progress bar to not be a bottleneck (kchau@microsoft.com)
14
+
7
15
  ## 0.2.43
8
16
 
9
- Thu, 08 Dec 2022 00:49:16 GMT
17
+ Thu, 08 Dec 2022 00:49:28 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -1,17 +1,14 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import EventEmitter from "events";
4
3
  import type { LogEntry, Reporter } from "@lage-run/logger";
5
4
  import type { SchedulerRunSummary } from "@lage-run/scheduler-types";
6
5
  export declare class ProgressReporter implements Reporter {
7
- timer: NodeJS.Timeout;
8
6
  startTime: [number, number];
9
7
  logEvent: EventEmitter;
10
8
  logEntries: Map<string, LogEntry<import("@lage-run/logger").LogStructuredData>[]>;
11
9
  constructor(options?: {
12
10
  concurrency: number;
13
11
  });
14
- heartBeat: () => void;
15
12
  log(entry: LogEntry<any>): void;
16
13
  summarize(schedulerRunSummary: SchedulerRunSummary): void;
17
14
  }
@@ -70,7 +70,7 @@ class ProgressReporter {
70
70
  if (entry.data && entry.data.schedulerRun) {
71
71
  this.startTime = entry.data.schedulerRun.startTime;
72
72
  }
73
- if (entry.data && entry.data.target && typeof entry.data.threadId !== "undefined") {
73
+ if (entry.data && entry.data.status) {
74
74
  this.logEvent.emit("status", entry);
75
75
  }
76
76
  if (entry.data && entry.data.progress) {
@@ -82,7 +82,6 @@ class ProgressReporter {
82
82
  schedulerRunSummary,
83
83
  logEntries: this.logEntries
84
84
  });
85
- clearTimeout(this.timer);
86
85
  }
87
86
  constructor(options = {
88
87
  concurrency: 0
@@ -93,16 +92,9 @@ class ProgressReporter {
93
92
  ];
94
93
  this.logEvent = new _events.default();
95
94
  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
- };
102
95
  (0, _ink.render)(/*#__PURE__*/ _react.createElement(_progressReporterApp.ProgressReporterApp, {
103
96
  logEvent: this.logEvent,
104
97
  concurrency: options.concurrency
105
98
  }));
106
- this.timer = setTimeout(this.heartBeat, 1000);
107
99
  }
108
100
  }
@@ -50,14 +50,8 @@ 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
- }
56
53
  function ProgressReporterApp(props) {
57
- const initialThreadInfo = range(props.concurrency).reduce((acc, threadId)=>{
58
- acc[threadId] = "";
59
- return acc;
60
- }, {});
54
+ const initialThreadInfo = new Set();
61
55
  const [threadInfo, setThreadInfo] = _react.useState(initialThreadInfo);
62
56
  const [progress, setProgress] = _react.useState({
63
57
  waiting: 0,
@@ -65,26 +59,17 @@ function ProgressReporterApp(props) {
65
59
  total: 0
66
60
  });
67
61
  const [summary, setSummary] = _react.useState();
68
- const [currentTime, setCurrentTime] = _react.useState([
69
- 0,
70
- 0
71
- ]);
72
62
  const { logEvent } = props;
73
63
  _react.useEffect(()=>{
74
64
  logEvent.on("status", (entry)=>{
75
65
  const { target , threadId , status } = entry.data;
76
- if (status && status === "running") {
77
- setThreadInfo((threadInfo)=>({
78
- ...threadInfo,
79
- [threadId]: target.id
80
- }));
66
+ if (status === "running") {
67
+ setThreadInfo((threadInfo)=>new Set(threadInfo).add(target.id));
81
68
  } else if (status === "success" || status === "aborted" || status === "failed" || status === "skipped") {
82
69
  setThreadInfo((threadInfo)=>{
83
- const newThreadInfo = {
84
- ...threadInfo
85
- };
86
- newThreadInfo[threadId] = "";
87
- return newThreadInfo;
70
+ const newSet = new Set(threadInfo);
71
+ newSet.delete(target.id);
72
+ return newSet;
88
73
  });
89
74
  }
90
75
  });
@@ -94,39 +79,27 @@ function ProgressReporterApp(props) {
94
79
  logEvent.on("summary", (summary)=>{
95
80
  setSummary(summary);
96
81
  });
97
- logEvent.on("heartbeat", (heartbeat)=>{
98
- setCurrentTime(heartbeat.currentTime);
99
- });
100
82
  }, [
101
83
  logEvent
102
84
  ]);
103
- const arrayGapLength = props.concurrency - Object.keys(threadInfo).length;
104
- const idleWorkerDummyThreadInfo = arrayGapLength > 0 ? new Array(arrayGapLength).fill(0) : [];
85
+ const limit = 16;
86
+ const hasMore = threadInfo.size > limit;
105
87
  return /*#__PURE__*/ _react.createElement(_ink.Box, {
106
88
  flexDirection: "column"
107
89
  }, /*#__PURE__*/ _react.createElement(_ink.Text, null, "Lage running tasks with ", props.concurrency, " workers"), summary ? /*#__PURE__*/ _react.createElement(_summaryInfo.SummaryInfo, {
108
90
  summary: summary
109
91
  }) : /*#__PURE__*/ _react.createElement(_ink.Box, {
110
92
  flexDirection: "column"
111
- }, /*#__PURE__*/ _react.createElement(_ink.Box, {
93
+ }, /*#__PURE__*/ _react.createElement(_progressStatus.ProgressStatus, {
94
+ progress: progress
95
+ }), /*#__PURE__*/ _react.createElement(_ink.Box, {
112
96
  flexDirection: "column",
113
97
  marginLeft: 2,
114
98
  marginY: 1
115
- }, Object.entries(threadInfo).map(([threadId, targetId])=>{
116
- return /*#__PURE__*/ _react.createElement(_threadItem.ThreadItem, {
117
- key: threadId,
118
- threadId: threadId,
99
+ }, [
100
+ ...threadInfo
101
+ ].slice(Math.max(0, threadInfo.size - limit)).map((targetId)=>/*#__PURE__*/ _react.createElement(_threadItem.ThreadItem, {
102
+ key: targetId,
119
103
  targetId: targetId
120
- });
121
- }), idleWorkerDummyThreadInfo.map((_, index)=>{
122
- return /*#__PURE__*/ _react.createElement(_react.Fragment, {
123
- key: `idle-${index}`
124
- }, /*#__PURE__*/ _react.createElement(_threadItem.ThreadItem, {
125
- threadId: "?",
126
- targetId: ""
127
- }));
128
- })), /*#__PURE__*/ _react.createElement(_progressStatus.ProgressStatus, {
129
- progress: progress,
130
- currentTime: currentTime
131
- })));
104
+ })), hasMore && /*#__PURE__*/ _react.createElement(_ink.Text, null, "... (displaying most recent ", limit, ")"))));
132
105
  }
@@ -2,6 +2,5 @@
2
2
  import { Progress } from "../types/progressBarTypes";
3
3
  export interface ProgressStatusProps {
4
4
  progress: Progress;
5
- currentTime: [number, number];
6
5
  }
7
6
  export declare function ProgressStatus(props: ProgressStatusProps): JSX.Element;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "ProgressStatus", {
6
6
  enumerable: true,
7
7
  get: ()=>ProgressStatus
8
8
  });
9
- const _formatHrtime = require("@lage-run/format-hrtime");
10
9
  const _ink = require("ink");
11
10
  const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
12
11
  function _getRequireWildcardCache(nodeInterop) {
@@ -51,6 +50,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
51
50
  function ProgressStatus(props) {
52
51
  const { waiting , completed , total } = props.progress;
53
52
  const percentage = total > 0 ? `${(completed / total * 100).toFixed(2)}%` : "0%";
54
- const status = `Waiting: ${waiting} | Completed: ${completed} | Total: ${total} | ${percentage} | ${(0, _formatHrtime.formatDuration)((0, _formatHrtime.hrToSeconds)(props.currentTime))}`;
53
+ const status = `Waiting: ${waiting} | Completed: ${completed} | Total: ${total} | ${percentage}`;
55
54
  return /*#__PURE__*/ _react.createElement(_ink.Box, null, /*#__PURE__*/ _react.createElement(_ink.Text, null, status));
56
55
  }
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  export declare function ThreadItem(props: {
3
- threadId: string | number;
4
3
  targetId: string;
5
4
  }): JSX.Element;
@@ -48,12 +48,10 @@ function _interopRequireWildcard(obj, nodeInterop) {
48
48
  return newObj;
49
49
  }
50
50
  function ThreadItem(props) {
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, {
51
+ const { targetId } = props;
52
+ return targetId ? /*#__PURE__*/ _react.createElement(_ink.Text, {
55
53
  color: "whiteBright"
56
54
  }, targetId, " ") : /*#__PURE__*/ _react.createElement(_ink.Text, {
57
55
  color: "gray"
58
- }, "IDLE"));
56
+ }, "IDLE");
59
57
  }
@@ -23,6 +23,11 @@ function createReporter({ reporter ="npmLog" , progress =false , grouped =false
23
23
  grouped,
24
24
  logLevel: verbose ? _logger.LogLevel.verbose : logLevel
25
25
  });
26
+ case "old":
27
+ return new _logReporterJs.LogReporter({
28
+ grouped,
29
+ logLevel: verbose ? _logger.LogLevel.verbose : logLevel
30
+ });
26
31
  default:
27
32
  return progress ? new _progressReporterJs.ProgressReporter({
28
33
  concurrency
@@ -5,9 +5,7 @@ export interface Progress {
5
5
  completed: number;
6
6
  total: number;
7
7
  }
8
- export interface ThreadInfo {
9
- [threadId: string]: string;
10
- }
8
+ export type ThreadInfo = Set<string>;
11
9
  export interface SummaryWithLogs {
12
10
  schedulerRunSummary: SchedulerRunSummary;
13
11
  logEntries: Map<string, LogEntry[]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lage-run/reporters",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "Log reporters for Lage",
5
5
  "repository": {
6
6
  "url": "https://github.com/microsoft/lage"