@ornncompute/cli 1.0.35 → 1.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  /** Live orchestrator software dictionary: `GET /v1/orchestrator/catalog/software`. */
2
2
  export const SOFTWARE_CATALOG_PATH = "/v1/orchestrator/catalog/software";
3
- export const SOFTWARE_KINDS = ["python", "package", "cuda", "nvidia_smi", "dcgmi"];
3
+ export const SOFTWARE_KINDS = ["python", "package", "cuda", "nvidia_driver", "dcgmi"];
4
+ /** Kinds a disk build installs per OS release; Python packages install anywhere. */
5
+ const RELEASE_KINDS = ["python", "cuda", "nvidia_driver", "dcgmi"];
4
6
  function stringMap(value) {
5
7
  if (!value || typeof value !== "object" || Array.isArray(value)) {
6
8
  return {};
@@ -13,22 +15,66 @@ function stringMap(value) {
13
15
  }
14
16
  return out;
15
17
  }
18
+ function stringList(value) {
19
+ return Array.isArray(value)
20
+ ? value.filter((entry) => typeof entry === "string")
21
+ : [];
22
+ }
23
+ function releaseSupport(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
25
+ return {};
26
+ }
27
+ const out = {};
28
+ for (const [release, kinds] of Object.entries(value)) {
29
+ if (!kinds || typeof kinds !== "object")
30
+ continue;
31
+ const row = kinds;
32
+ out[release] = Object.fromEntries(RELEASE_KINDS.map((kind) => [kind, stringList(row[kind])]));
33
+ }
34
+ return out;
35
+ }
16
36
  export function parseSoftwareCatalog(payload) {
17
37
  const row = payload && typeof payload === "object" ? payload : {};
18
- const python = Array.isArray(row.python)
19
- ? row.python.filter((value) => typeof value === "string")
20
- : [];
21
38
  return {
22
- python,
39
+ python: stringList(row.python),
23
40
  packages: stringMap(row.packages),
24
41
  cuda: stringMap(row.cuda),
25
- nvidia_smi: stringMap(row.nvidia_smi),
42
+ nvidia_driver: stringMap(row.nvidia_driver),
26
43
  dcgmi: stringMap(row.dcgmi),
44
+ os_releases: releaseSupport(row.os_releases),
27
45
  };
28
46
  }
29
47
  export async function loadSoftwareCatalog(fetchImpl) {
30
48
  return parseSoftwareCatalog(await fetchImpl(SOFTWARE_CATALOG_PATH, { method: "GET" }));
31
49
  }
50
+ /**
51
+ * The catalog a disk built on an image of `osRelease` can install: Python,
52
+ * CUDA, driver, and DCGM choices narrowed to that release (none when it is
53
+ * unset or unknown); packages unchanged.
54
+ */
55
+ export function softwareCatalogForOsRelease(catalog, osRelease) {
56
+ const supported = catalog.os_releases[osRelease ?? ""] ?? {};
57
+ const allows = (kind, slug) => supported[kind]?.includes(slug) ?? false;
58
+ const narrow = (kind) => Object.fromEntries(Object.entries(catalog[kind]).filter(([, slug]) => allows(kind, slug)));
59
+ return {
60
+ ...catalog,
61
+ python: catalog.python.filter((version) => allows("python", version)),
62
+ cuda: narrow("cuda"),
63
+ nvidia_driver: narrow("nvidia_driver"),
64
+ dcgmi: narrow("dcgmi"),
65
+ };
66
+ }
67
+ /** `stack` with every version `catalog` does not offer cleared. */
68
+ export function keepOfferedChoices(stack, catalog) {
69
+ const offered = (map, slug) => slug && Object.values(map).includes(slug) ? slug : "";
70
+ return {
71
+ ...stack,
72
+ python_version: catalog.python.includes(stack.python_version) ? stack.python_version : "",
73
+ cuda_version: offered(catalog.cuda, stack.cuda_version),
74
+ nvidia_driver_version: offered(catalog.nvidia_driver, stack.nvidia_driver_version),
75
+ dcgmi_version: offered(catalog.dcgmi, stack.dcgmi_version),
76
+ };
77
+ }
32
78
  export function displayForSoftwareSlug(catalog, kind, slug) {
33
79
  const map = catalog[kind];
34
80
  const hit = Object.entries(map).find(([, value]) => value === slug);