1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
18 } from '@material-ui/core';
19 import { ArvadosTheme } from 'common/custom-theme';
25 } from 'components/icon/icon';
26 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
27 import { connect } from 'react-redux';
28 import { Process } from 'store/processes/process';
29 import { NodeInstanceType } from 'store/process-panel/process-panel';
30 import { DefaultView } from 'components/default-view/default-view';
31 import { DetailsAttribute } from "components/details-attribute/details-attribute";
32 import { formatFileSize } from "common/formatters";
33 import { InputCollectionMount } from 'store/processes/processes-actions';
34 import { MountKind, TemporaryDirectoryMount } from 'models/mount-types';
36 interface ProcessResourceCardDataProps {
38 nodeInfo: NodeInstanceType | null;
41 type CssRules = "card" | "header" | "title" | "avatar" | "iconHeader" | "content" | "sectionH3";
43 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
51 paddingTop: theme.spacing.unit * 0.5
54 paddingTop: theme.spacing.unit * 0.5
58 color: theme.customs.colors.green700,
62 maxHeight: `calc(100% - ${theme.spacing.unit * 4.5}px)`,
67 color: theme.customs.colors.purple,
68 fontSize: "0.8125rem",
69 textTransform: "uppercase",
73 type ProcessResourceCardProps = ProcessResourceCardDataProps & WithStyles<CssRules> & MPVPanelProps;
75 export const ProcessResourceCard = withStyles(styles)(connect()(
76 ({ classes, nodeInfo, doHidePanel, doMaximizePanel, doUnMaximizePanel, panelMaximized, panelName, process, }: ProcessResourceCardProps) => {
78 const loading = false;
81 if (process.container?.mounts) {
82 for (const mnt in process.container.mounts) {
83 const mp = process.container.mounts[mnt];
84 if (mp.kind === MountKind.TEMPORARY_DIRECTORY) {
85 diskRequest += mp.capacity;
90 return <Card className={classes.card} data-cy="process-resources-card">
92 className={classes.header}
94 content: classes.title,
95 avatar: classes.avatar,
97 avatar={<ProcessIcon className={classes.iconHeader} />}
99 <Typography noWrap variant='h6' color='inherit'>
105 {doUnMaximizePanel && panelMaximized &&
106 <Tooltip title={`Unmaximize ${panelName || 'panel'}`} disableFocusListener>
107 <IconButton onClick={doUnMaximizePanel}><UnMaximizeIcon /></IconButton>
109 {doMaximizePanel && !panelMaximized &&
110 <Tooltip title={`Maximize ${panelName || 'panel'}`} disableFocusListener>
111 <IconButton onClick={doMaximizePanel}><MaximizeIcon /></IconButton>
114 <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
115 <IconButton disabled={panelMaximized} onClick={doHidePanel}><CloseIcon /></IconButton>
119 <CardContent className={classes.content}>
122 <h3 className={classes.sectionH3}>Requested Resources</h3>
125 <DetailsAttribute label="Cores" value={process.container?.runtimeConstraints.vcpus} />
128 <DetailsAttribute label="RAM" value={formatFileSize(process.container?.runtimeConstraints.ram)} />
131 <DetailsAttribute label="Disk" value={formatFileSize(diskRequest)} />
134 {process.container?.runtimeConstraints.keep_cache_ram &&
135 process.container?.runtimeConstraints.keep_cache_ram > 0 ?
137 <DetailsAttribute label="Keep cache (RAM)" value={formatFileSize(process.container?.runtimeConstraints.keep_cache_ram)} />
140 {process.container?.runtimeConstraints.keep_cache_disk &&
141 process.container?.runtimeConstraints.keep_cache_disk > 0 ?
143 <DetailsAttribute label="Keep cache (disk)" value={formatFileSize(process.container?.runtimeConstraints.keep_cache_disk)} />
146 {process.container?.runtimeConstraints.API ? <Grid item xs={12}>
147 <DetailsAttribute label="API access" value={process.container?.runtimeConstraints.API.toString()} />
150 {process.container?.runtimeConstraints.cuda &&
151 process.container?.runtimeConstraints.cuda.device_count > 0 ?
154 <DetailsAttribute label="CUDA devices" value={process.container?.runtimeConstraints.cuda.device_count} />
157 <DetailsAttribute label="CUDA driver version" value={process.container?.runtimeConstraints.cuda.driver_version} />
160 <DetailsAttribute label="CUDA hardware capability" value={process.container?.runtimeConstraints.cuda.hardware_capability} />
168 <h3 className={classes.sectionH3}>Assigned Instance Type</h3>
169 {nodeInfo === null ? <Grid item xs={8}>
170 No instance type recorded
175 <DetailsAttribute label="Cores" value={nodeInfo.VCPUs} />
179 <DetailsAttribute label="Provider type" value={nodeInfo.ProviderType} />
183 <DetailsAttribute label="RAM" value={formatFileSize(nodeInfo.RAM)} />
187 <DetailsAttribute label="Price" value={"$" + nodeInfo.Price.toString()} />
191 <DetailsAttribute label="Included scratch disk" value={formatFileSize(nodeInfo.IncludedScratch)} />
195 <DetailsAttribute label="Preemptible" value={nodeInfo.Preemptible.toString()} />
199 <DetailsAttribute label="Added scratch disk" value={formatFileSize(nodeInfo.AddedScratch)} />
202 {nodeInfo.CUDA.DeviceCount > 0 &&
205 <DetailsAttribute label="CUDA devices" value={formatFileSize(nodeInfo.CUDA.DeviceCount)} />
212 <DetailsAttribute label="CUDA driver version" value={formatFileSize(nodeInfo.CUDA.DriverVersion)} />
219 <DetailsAttribute label="CUDA hardware capability" value={formatFileSize(nodeInfo.CUDA.HardwareCapability)} />