1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
17 } from '@material-ui/core';
18 import { ArvadosTheme } from 'common/custom-theme';
24 } from 'components/icon/icon';
25 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
26 import { connect } from 'react-redux';
27 import { Process } from 'store/processes/process';
28 import { NodeInstanceType } from 'store/process-panel/process-panel';
29 import { DetailsAttribute } from "components/details-attribute/details-attribute";
30 import { formatFileSize } from "common/formatters";
31 import { MountKind } from 'models/mount-types';
33 interface ProcessResourceCardDataProps {
35 nodeInfo: NodeInstanceType | null;
38 type CssRules = "card" | "header" | "title" | "avatar" | "iconHeader" | "content" | "sectionH3";
40 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
48 paddingTop: theme.spacing.unit * 0.5
51 paddingTop: theme.spacing.unit * 0.5
55 color: theme.customs.colors.greyL,
59 maxHeight: `calc(100% - ${theme.spacing.unit * 7.5}px)`,
64 color: theme.customs.colors.greyD,
65 fontSize: "0.8125rem",
66 textTransform: "uppercase",
70 type ProcessResourceCardProps = ProcessResourceCardDataProps & WithStyles<CssRules> & MPVPanelProps;
72 export const ProcessResourceCard = withStyles(styles)(connect()(
73 ({ classes, nodeInfo, doHidePanel, doMaximizePanel, doUnMaximizePanel, panelMaximized, panelName, process, }: ProcessResourceCardProps) => {
75 if (process.container?.mounts) {
76 for (const mnt in process.container.mounts) {
77 const mp = process.container.mounts[mnt];
78 if (mp.kind === MountKind.TEMPORARY_DIRECTORY) {
79 diskRequest += mp.capacity;
84 return <Card className={classes.card} data-cy="process-resources-card">
86 className={classes.header}
88 content: classes.title,
89 avatar: classes.avatar,
91 avatar={<MemoryIcon className={classes.iconHeader} />}
93 <Typography noWrap variant='h6' color='inherit'>
99 {doUnMaximizePanel && panelMaximized &&
100 <Tooltip title={`Unmaximize ${panelName || 'panel'}`} disableFocusListener>
101 <IconButton onClick={doUnMaximizePanel}><UnMaximizeIcon /></IconButton>
103 {doMaximizePanel && !panelMaximized &&
104 <Tooltip title={`Maximize ${panelName || 'panel'}`} disableFocusListener>
105 <IconButton onClick={doMaximizePanel}><MaximizeIcon /></IconButton>
108 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
109 <IconButton disabled={panelMaximized} onClick={doHidePanel}><CloseIcon /></IconButton>
113 <CardContent className={classes.content}>
116 <h3 className={classes.sectionH3}>Requested Resources</h3>
119 <DetailsAttribute label="Cores" value={process.container?.runtimeConstraints.vcpus} />
122 <DetailsAttribute label="RAM*" value={formatFileSize(process.container?.runtimeConstraints.ram)} />
125 <DetailsAttribute label="Disk" value={formatFileSize(diskRequest)} />
128 {process.container?.runtimeConstraints.cuda &&
129 process.container?.runtimeConstraints.cuda.device_count > 0 ?
132 <DetailsAttribute label="CUDA devices" value={process.container?.runtimeConstraints.cuda.device_count} />
135 <DetailsAttribute label="CUDA driver version" value={process.container?.runtimeConstraints.cuda.driver_version} />
138 <DetailsAttribute label="CUDA hardware capability" value={process.container?.runtimeConstraints.cuda.hardware_capability} />
142 {process.container?.runtimeConstraints.keep_cache_ram &&
143 process.container?.runtimeConstraints.keep_cache_ram > 0 ?
145 <DetailsAttribute label="Keep cache (RAM)" value={formatFileSize(process.container?.runtimeConstraints.keep_cache_ram)} />
148 {process.container?.runtimeConstraints.keep_cache_disk &&
149 process.container?.runtimeConstraints.keep_cache_disk > 0 ?
151 <DetailsAttribute label="Keep cache (disk)" value={formatFileSize(process.container?.runtimeConstraints.keep_cache_disk)} />
154 {process.container?.runtimeConstraints.API ? <Grid item xs={12}>
155 <DetailsAttribute label="API access" value={process.container?.runtimeConstraints.API.toString()} />
163 <h3 className={classes.sectionH3}>Assigned Instance Type</h3>
164 {nodeInfo === null ? <Grid item xs={8}>
165 No instance type recorded
170 <DetailsAttribute label="Cores" value={nodeInfo.VCPUs} />
174 <DetailsAttribute label="Provider type" value={nodeInfo.ProviderType} />
178 <DetailsAttribute label="RAM" value={formatFileSize(nodeInfo.RAM)} />
182 <DetailsAttribute label="Price" value={"$" + nodeInfo.Price.toString()} />
186 <DetailsAttribute label="Disk" value={formatFileSize(nodeInfo.IncludedScratch + nodeInfo.AddedScratch)} />
190 <DetailsAttribute label="Preemptible" value={nodeInfo.Preemptible.toString()} />
193 {nodeInfo.CUDA && nodeInfo.CUDA.DeviceCount > 0 &&
196 <DetailsAttribute label="CUDA devices" value={nodeInfo.CUDA.DeviceCount} />
203 <DetailsAttribute label="CUDA driver version" value={nodeInfo.CUDA.DriverVersion} />
210 <DetailsAttribute label="CUDA hardware capability" value={nodeInfo.CUDA.HardwareCapability} />
217 <Typography>* RAM available to the program is limited to Requested RAM, not Instance RAM</Typography>