Skip to content

Commit 1807a3d

Browse files
Pablo Carmonastarpit
authored andcommitted
feat: format summary as a patterfly DescriptionList
1 parent 8dddedc commit 1807a3d

File tree

8 files changed

+191
-13
lines changed

8 files changed

+191
-13
lines changed

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
=== "Summary"
22

3-
```json
3+
```shell
44
---
5-
language: yaml
6-
exclude:
7-
- .source
8-
- .language
9-
- .runtimeEnv
5+
execute: now
6+
outputOnly: true
107
---
11-
--8<-- "$LOGDIR/job.json"
8+
description $LOGDIR/job.json
129
```

plugins/plugin-codeflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26+
"@patternfly/react-core": "^4.221.3",
2627
"@patternfly/react-charts": "^6.74.3",
2728
"strip-ansi": "6.0.0"
2829
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import React from "react"
18+
19+
import {
20+
DescriptionList,
21+
DescriptionListTerm,
22+
DescriptionListGroup,
23+
DescriptionListDescription,
24+
} from "@patternfly/react-core"
25+
26+
import { Summary } from "../controller/description"
27+
28+
import "../../web/scss/components/Dashboard/Description.scss"
29+
30+
type Props = {
31+
summaryData: Summary
32+
}
33+
34+
const Description = (props: Props) => {
35+
const { summaryData } = props
36+
37+
return (
38+
<DescriptionList>
39+
{Object.values(summaryData).map(({ label, value }, index) => (
40+
<DescriptionListGroup key={index}>
41+
<DescriptionListTerm>{label}</DescriptionListTerm>
42+
<DescriptionListDescription>{value}</DescriptionListDescription>
43+
</DescriptionListGroup>
44+
))}
45+
</DescriptionList>
46+
)
47+
}
48+
49+
export default Description
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Arguments, Registrar } from "@kui-shell/core"
18+
import { expand } from "../lib/util"
19+
20+
export type Summary = {
21+
appClass: { label: string; value: string }
22+
appName: { label: string; value: string }
23+
language: { label: string; value: string }
24+
pythonVersion: { label: string; value: string }
25+
rayVersion: { label: string; value: string }
26+
gpuClass: { label: string; value: string }
27+
workerGPUs: { label: string; value: string }
28+
workerMemory: { label: string; value: string }
29+
workerCount: { label: string; value: string }
30+
status: { label: string; value: string }
31+
parameters: { label: string; value: string }
32+
dataSources: { label: string; value: string }
33+
}
34+
35+
export type SummaryResponse = {
36+
jobid: string
37+
cmdline: {
38+
appPart: string
39+
systemPart: string
40+
}
41+
runtimeEnv: {
42+
env_vars: {
43+
KUBE_NS: string
44+
WORKER_MEMORY: string
45+
NUM_GPUS: string
46+
MIN_WORKERS: string
47+
MAX_WORKERS: string
48+
RAY_IMAGE: string
49+
}
50+
}
51+
language: string
52+
source: string
53+
}
54+
55+
async function description(args: Arguments) {
56+
const filepath = args.argvNoOptions[1]
57+
if (!filepath) {
58+
throw new Error("Usage: codeflare description <filepath>")
59+
}
60+
61+
const summaryCmd = JSON.parse(await args.REPL.qexec<string>(`vfs fslice ${expand(filepath)} 0`))
62+
const { KUBE_NS, WORKER_MEMORY, NUM_GPUS, MIN_WORKERS, MAX_WORKERS, RAY_IMAGE } = summaryCmd.runtimeEnv.env_vars
63+
64+
const summaryData = {
65+
appClass: { label: "Application Class", value: "Unknown" },
66+
appName: { label: "Application Name", value: "Unknown" },
67+
language: { label: "Source Language", value: summaryCmd.language },
68+
pythonVersion: { label: "Python Version", value: "Unknown" },
69+
rayVersion: { label: "Ray Version", value: RAY_IMAGE },
70+
gpuClass: { label: "GPU Class", value: KUBE_NS },
71+
workerGPUs: { label: "GPUs per Worker", value: NUM_GPUS },
72+
workerMemory: { label: "Memory per Worker", value: WORKER_MEMORY },
73+
workerCount: { label: "Worker Count", value: `${MIN_WORKERS}-${MAX_WORKERS}` },
74+
status: { label: "Status", value: "Unknown" },
75+
parameters: { label: "Parameters", value: "Unknown" },
76+
dataSources: { label: "Data Sources", value: "Unknown" },
77+
}
78+
79+
const React = await import("react")
80+
const Description = await import("../components/Description")
81+
82+
return {
83+
react: React.createElement(Description.default, { summaryData }),
84+
}
85+
}
86+
87+
export default function registerDescriptionCommands(registrar: Registrar) {
88+
registrar.listen("/description", description, { needsUI: true, outputOnly: true })
89+
}

plugins/plugin-codeflare/src/plugin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { Registrar } from "@kui-shell/core"
1818
import dashboard from "./controller/dashboard"
1919
import charts from "./controller/charts"
20+
import description from "./controller/description"
2021

2122
function help() {
2223
return `Usage:
@@ -29,5 +30,6 @@ codeflare chart gpu /path/to/logdir`
2930
export default function registerCodeflareCommands(registrar: Registrar) {
3031
dashboard(registrar)
3132
charts(registrar)
33+
description(registrar)
3234
registrar.listen("/help", help)
3335
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2022 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@import "@kui-shell/plugin-client-common/web/scss/components/Terminal/mixins";
18+
19+
@include Scrollback {
20+
dd {
21+
margin: 0;
22+
}
23+
.pf-c-description-list {
24+
grid-template-columns: 1fr;
25+
padding: 0 1em;
26+
}
27+
.pf-c-description-list__group {
28+
grid-template-columns: 1fr;
29+
}
30+
.pf-c-description-list__term,
31+
.pf-c-description-list__description {
32+
grid-column-start: unset;
33+
}
34+
.pf-c-description-list__description {
35+
font-weight: 300;
36+
color: var(--color-text-02);
37+
}
38+
}

plugins/plugin-codeflare/web/scss/components/Dashboard/_index.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
@include TopLevelTab {
3232
@include Split(3) {
3333
@include Rows(5);
34-
@include Columns(7);
34+
@include Columns(12);
3535
grid-template-areas:
36-
"T1 T1 T3 T3 T3 T3 T3"
37-
"T1 T1 T3 T3 T3 T3 T3"
38-
"T1 T1 T3 T3 T3 T3 T3"
39-
"T2 T2 T2 T2 T2 T2 T2"
40-
"T2 T2 T2 T2 T2 T2 T2";
36+
"T1 T1 T1 T3 T3 T3 T3 T3 T3 T3 T3 T3"
37+
"T1 T1 T1 T3 T3 T3 T3 T3 T3 T3 T3 T3"
38+
"T1 T1 T1 T3 T3 T3 T3 T3 T3 T3 T3 T3"
39+
"T1 T1 T1 T2 T2 T2 T2 T2 T2 T2 T2 T2"
40+
"T1 T1 T1 T2 T2 T2 T2 T2 T2 T2 T2 T2";
4141
}
4242
}
4343

0 commit comments

Comments
 (0)