File tree Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { InformationSourceType } from "./enums" ;
2
+
3
+ export function informationSourceTypeToString ( source : InformationSourceType , short : boolean , forDisplay : boolean = true ) {
4
+ if ( forDisplay ) {
5
+ switch ( source ) {
6
+ case InformationSourceType . LABELING_FUNCTION : return short ? "LF" : "Labeling Function module" ;
7
+ case InformationSourceType . ACTIVE_LEARNING : return short ? "AL" : "Active Learning module" ;
8
+ case InformationSourceType . PRE_COMPUTED : return short ? "PC" : "Pre Computed module" ;
9
+ case InformationSourceType . ZERO_SHOT : return short ? "ZS" : "Zero Shot module" ;
10
+ case InformationSourceType . CROWD_LABELER : return short ? "CL" : "Crowd labeler" ;
11
+ default : return source ;
12
+ }
13
+ }
14
+ return source ;
15
+ }
Original file line number Diff line number Diff line change
1
+ export enum InformationSourceType {
2
+ LABELING_FUNCTION = "LABELING_FUNCTION" ,
3
+ ACTIVE_LEARNING = "ACTIVE_LEARNING" ,
4
+ PRE_COMPUTED = "PRE_COMPUTED" ,
5
+ ZERO_SHOT = "ZERO_SHOT" ,
6
+ CROWD_LABELER = "CROWD_LABELER"
7
+ }
Original file line number Diff line number Diff line change @@ -192,4 +192,17 @@ export function getUserAvatarUri(user) {
192
192
avatarId = ( user . firstName [ 0 ] . charCodeAt ( 0 ) + user . lastName [ 0 ] . charCodeAt ( 0 ) ) % 5 ;
193
193
}
194
194
return avatarId + ".png" ;
195
+ }
196
+
197
+ export function percentRoundString ( value : number | string , decimals : number = 0 , isZeroToOne : boolean = true ) {
198
+ if ( typeof value == 'number' ) {
199
+ if ( isNaN ( value ) ) return "n/a" ;
200
+ if ( ! isFinite ( value ) ) return "0 %" ;
201
+ if ( isZeroToOne ) value *= 100 ;
202
+ if ( ! decimals ) return Math . round ( value ) + '%' ;
203
+ const dec = 10 ** decimals ;
204
+ return Math . round ( value * dec ) / dec + ' %' ;
205
+ }
206
+ else if ( typeof value == 'undefined' || value == null ) return "n/a" ;
207
+ return value ;
195
208
}
Original file line number Diff line number Diff line change
1
+ import { informationSourceTypeToString } from "./enums/enum-functions" ;
2
+ import { InformationSourceType } from "./enums/enums" ;
3
+
4
+ export function parseContainerLogsData ( logs : string [ ] , isType : InformationSourceType = null ) {
5
+ if ( ! logs ) {
6
+ if ( isType ) return [ `Running ${ informationSourceTypeToString ( isType , false ) } ...` ] ;
7
+ else return null ;
8
+ }
9
+ if ( ! Array . isArray ( logs ) ) return null ;
10
+ if ( logs . length == 0 ) return [ ] ;
11
+
12
+ const neededIDLength = String ( logs . length ) ?. length ;
13
+ return logs . map ( ( wrapper , index ) => {
14
+ const d : Date = new Date ( wrapper . substr ( 0 , wrapper . indexOf ( ' ' ) ) ) ;
15
+ if ( isNaN ( d . getTime ( ) ) ) return wrapper ;
16
+ return (
17
+ String ( index + 1 ) . padStart ( neededIDLength , '0' ) +
18
+ ': ' +
19
+ d . toLocaleString ( ) +
20
+ ' - ' +
21
+ wrapper . substr ( wrapper . indexOf ( ' ' ) + 1 )
22
+ ) ;
23
+ } ) ;
24
+ }
You can’t perform that action at this time.
0 commit comments