-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Operations): preempted jobs [YTFRONT-4641]
- Loading branch information
1 parent
b05e92f
commit b8c5dc7
Showing
8 changed files
with
159 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...es/ui/src/ui/pages/operations/OperationDetail/tabs/Jobs/OperationJobsTable/JobDetails.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, {FC} from 'react'; | ||
import {Tooltip} from '../../../../../../components/Tooltip/Tooltip'; | ||
import ypath from '../../../../../../common/thor/ypath'; | ||
import hammer from '../../../../../../common/hammer'; | ||
import {Flex, Icon} from '@gravity-ui/uikit'; | ||
import CircleQuestionIcon from '@gravity-ui/icons/svgs/circle-question.svg'; | ||
import map_ from 'lodash/map'; | ||
import MetaTable from '../../../../../../components/MetaTable/MetaTable'; | ||
import {RawJob} from '../../../../../../types/operations/job'; | ||
|
||
type Props = { | ||
statistics: RawJob['statistics']; | ||
type: string; | ||
}; | ||
|
||
const prepareStatistics = (statistics: RawJob['statistics']) => { | ||
return map_(ypath.getValue(statistics), (value, key: string) => { | ||
let result = hammer.format.Number(value); | ||
|
||
if (key.endsWith('_data_size') || key.endsWith('_data_weight')) { | ||
result = hammer.format.Bytes(value); | ||
} else if (key.endsWith('_time')) { | ||
result = hammer.format.TimeDuration(value, {format: 'milliseconds'}); | ||
} | ||
|
||
return { | ||
key: hammer.format.Readable(key), | ||
value: <div style={{textAlign: 'right'}}>{result}</div>, | ||
}; | ||
}); | ||
}; | ||
|
||
export const JobDetails: FC<Props> = ({statistics, type}) => { | ||
if (!statistics || type === 'vanilla') return null; | ||
|
||
const [rowCount, dataSize] = ypath.getValues(statistics, [ | ||
'/processed_input_row_count', | ||
'/processed_input_uncompressed_data_size', | ||
]); | ||
|
||
if (!rowCount && !dataSize) return null; | ||
|
||
return ( | ||
<Tooltip content={<MetaTable items={prepareStatistics(statistics)} />}> | ||
<Flex gap={2} alignItems="center"> | ||
<span> | ||
{hammer.format['Number'](rowCount)} ({hammer.format['Bytes'](dataSize)}) | ||
</span> | ||
<Icon data={CircleQuestionIcon} size={16} /> | ||
</Flex> | ||
</Tooltip> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...s/ui/src/ui/pages/operations/OperationDetail/tabs/Jobs/OperationJobsTable/StatusInfo.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.yt-job-status-info { | ||
&__popup { | ||
padding: 10px; | ||
max-width: 400px; | ||
display: flex; | ||
gap: 5px; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...es/ui/src/ui/pages/operations/OperationDetail/tabs/Jobs/OperationJobsTable/StatusInfo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, {FC, useRef} from 'react'; | ||
import {RawJob} from '../../../../../../types/operations/job'; | ||
import hammer from '../../../../../../common/hammer'; | ||
import {ClipboardButton, Flex, Label, Popup} from '@gravity-ui/uikit'; | ||
import {useToggle} from 'react-use'; | ||
import './StatusInfo.scss'; | ||
import cn from 'bem-cn-lite'; | ||
|
||
const block = cn('yt-job-status-info'); | ||
|
||
type Props = { | ||
state: RawJob['state']; | ||
info: RawJob['interruption_info']; | ||
}; | ||
|
||
export const StatusInfo: FC<Props> = ({state, info}) => { | ||
const [open, toggleOpen] = useToggle(false); | ||
const anchorRef = useRef<HTMLDivElement>(null); | ||
const reason = hammer.format['ReadableField']( | ||
info?.preemption_reason || info?.interruption_reason, | ||
); | ||
|
||
return ( | ||
<Flex alignItems="center" gap={1} className={block()}> | ||
{hammer.format['ReadableField'](state)} | ||
{Boolean(reason) && ( | ||
<> | ||
<div onMouseEnter={toggleOpen}> | ||
<Label theme="warning" ref={anchorRef}> | ||
Interrupted | ||
</Label> | ||
</div> | ||
|
||
<Popup open={open} hasArrow anchorRef={anchorRef} onMouseLeave={toggleOpen}> | ||
<div className={block('popup')}> | ||
<div>{reason}</div> | ||
<ClipboardButton | ||
title="Copy reason" | ||
view="flat-secondary" | ||
size="s" | ||
text={reason} | ||
/> | ||
</div> | ||
</Popup> | ||
</> | ||
)} | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4.91 KB
(110%)
...tions/operations.base.screen.ts-snapshots/Operation---Jobs-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.