CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/compute/cloud/google-cloud/specs.tsx
Views: 687
1
import { displayAcceleratorType } from "./accelerator";
2
import { plural } from "@cocalc/util/misc";
3
import { getMinDiskSizeGb } from "@cocalc/util/db-schema/compute-servers";
4
5
export default function Specs({ configuration, priceData, IMAGES }) {
6
const gpu = configuration.acceleratorType
7
? `${configuration.acceleratorCount ?? 1} ${displayAcceleratorType(
8
configuration.acceleratorType,
9
)} ${plural(configuration.acceleratorCount ?? 1, "GPU")}, `
10
: "";
11
12
return (
13
<div>
14
{configuration.spot ? "Spot " : "Standard "} {configuration.machineType}{" "}
15
with {gpu}
16
{priceData ? (
17
<span>
18
<RamAndCpu
19
machineType={configuration.machineType}
20
priceData={priceData}
21
inline
22
/>
23
</span>
24
) : (
25
""
26
)}
27
, and a{" "}
28
{configuration.diskSizeGb ??
29
`at least ${getMinDiskSizeGb({ configuration, IMAGES })}`}{" "}
30
GB{" "}
31
{configuration.diskType?.includes("hyper") ? (
32
"hyperdisk"
33
) : (
34
<>
35
{(configuration.diskType ?? "pd-standard") != "pd-standard"
36
? " SSD "
37
: " HDD "}{" "}
38
disk
39
</>
40
)}{" "}
41
in {configuration.zone}.
42
</div>
43
);
44
}
45
46
export function RamAndCpu({
47
machineType,
48
priceData,
49
style,
50
inline,
51
}: {
52
machineType: string;
53
priceData;
54
style?;
55
inline?: boolean;
56
}) {
57
const data = priceData.machineTypes[machineType];
58
if (data == null) return null;
59
const { memory } = data;
60
let { vcpu } = data;
61
if (!vcpu || !memory) return null;
62
if (machineType == "e2-micro") {
63
vcpu = "0.25-2";
64
} else if (machineType == "e2-small") {
65
vcpu = "0.5-2";
66
} else if (machineType == "e2-medium") {
67
vcpu = "1-2";
68
}
69
if (inline) {
70
return (
71
<span style={style}>
72
{vcpu} {plural(vcpu, "vCPU")}, {memory} GB RAM
73
</span>
74
);
75
}
76
return (
77
<div style={{ color: "#666", ...style }}>
78
<b>{plural(vcpu, "vCPU")}: </b>
79
<div
80
style={{ width: "65px", textAlign: "left", display: "inline-block" }}
81
>
82
{vcpu}
83
</div>
84
<b>Memory:</b> {memory} GB
85
</div>
86
);
87
}
88
89