Skip to content

Commit 3e65eb7

Browse files
committed
feat: codeflare logs command
update tests/kind/run to use plain log streamer
1 parent ea9d7e6 commit 3e65eb7

File tree

19 files changed

+192
-135
lines changed

19 files changed

+192
-135
lines changed

Diff for: deploy/self-test/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LABEL org.opencontainers.image.source https://github.com/project-codeflare/codef
44

55
ENV DEBIAN_FRONTEND=noninteractive
66

7-
RUN apt update && apt -y install sudo curl python3 python3-pip python3-venv git \
7+
RUN apt update && apt -y install sudo curl python3 python3-pip python3-venv git uuid-runtime \
88
&& pip3 install --no-cache-dir -U pip && pip3 install --no-cache-dir -U setuptools \
99
&& apt -y clean && rm -rf /var/lib/apt/lists/*
1010

Diff for: package-lock.json

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: plugins/plugin-codeflare/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
"@types/split2": "^3.2.1"
3131
},
3232
"dependencies": {
33-
"@guidebooks/store": "^3.3.9",
33+
"@guidebooks/store": "^3.3.12",
3434
"@logdna/tail-file": "^3.0.1",
3535
"@patternfly/react-charts": "^6.94.18",
3636
"@patternfly/react-core": "^4.276.6",
3737
"asciinema-player": "^3.0.1",
3838
"chokidar": "^3.5.3",
39-
"madwizard": "^6.1.2",
39+
"madwizard": "^6.2.0",
4040
"needle": "^3.2.0",
4141
"open": "^8.4.0",
4242
"pretty-bytes": "^6.0.0",

Diff for: plugins/plugin-codeflare/src/controller/appName.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 { productName } from "@kui-shell/client/config.d/name.json"
18+
19+
const appName = productName.toLowerCase()
20+
export default appName

Diff for: plugins/plugin-codeflare/src/controller/attach.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import Debug from "debug"
1919
import { MadWizardOptions } from "madwizard"
2020
import { Arguments, Capabilities, ParsedOptions } from "@kui-shell/core"
2121

22+
import appName from "./appName"
2223
import { DashboardOptions } from "./dashboard"
2324

2425
export type Options = ParsedOptions &
@@ -57,7 +58,6 @@ export async function attach(
5758
process.env.JOB_ID = jobId
5859
}
5960

60-
const appName = "codeflare"
6161
const options: MadWizardOptions = Object.assign(
6262
{
6363
appName,

Diff for: plugins/plugin-codeflare/src/controller/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import events from "./events"
2525
import dashboard from "./dashboard"
2626
import description from "./description"
2727
import { Options as AttachOptions } from "./attach"
28+
import { ProfileOptions, profileFlags } from "./options"
2829

2930
function help() {
3031
return `Usage:
@@ -42,6 +43,12 @@ export default function registerCodeflareCommands(registrar: Registrar) {
4243
description(registrar)
4344
registrar.listen("/help", help)
4445

46+
registrar.listen<KResponse, ProfileOptions>(
47+
"/codeflare/logs",
48+
(args) => import("./logs").then((_) => _.default(args)),
49+
{ flags: profileFlags }
50+
)
51+
4552
registrar.listen<KResponse, AttachOptions>(
4653
"/codeflare/attach",
4754
(args) => import("./attach").then((_) => _.default(args)),

Diff for: plugins/plugin-codeflare/src/controller/logs.ts

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2023 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 } from "@kui-shell/core"
18+
import { MadWizardOptions } from "madwizard"
19+
20+
import appName from "./appName"
21+
import { ProfileOptions } from "./options"
22+
23+
export default async function logs(args: Arguments<ProfileOptions>) {
24+
// Display logs for this jobID; if not provided, the user will be
25+
// prompted (via the guidebook) to choose one
26+
const jobId = args.argvNoOptions[args.argvNoOptions.indexOf("logs") + 1]
27+
if (jobId) {
28+
process.env.JOB_ID = jobId
29+
}
30+
31+
// play this guidebook
32+
const guidebook = jobId === undefined ? "ml/ray/aggregator" : "ml/ray/aggregator/with-jobid"
33+
34+
// but only interactive starting here
35+
const ifor =
36+
jobId === undefined
37+
? ["ml/ray/cluster/choose", "ml/ray/cluster/choose/kubernetes", "ml/ray/run/choose/list-jobs"]
38+
: undefined
39+
40+
const options: MadWizardOptions = Object.assign({
41+
appName,
42+
store: args.parsedOptions.s || process.env.GUIDEBOOK_STORE,
43+
verbose: args.parsedOptions.V,
44+
profile: args.parsedOptions.profile || (await import("madwizard").then((_) => _.Profiles.lastUsed())),
45+
interactive: false,
46+
ifor,
47+
})
48+
49+
const { guide } = await import("madwizard/dist/fe/cli")
50+
51+
await guide([appName, "guide", guidebook], undefined, options)
52+
return true
53+
}

Diff for: plugins/plugin-codeflare/src/controller/options.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2023 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 { CommandOptions, ParsedOptions } from "@kui-shell/core"
18+
19+
export type ProfileOptions = ParsedOptions & {
20+
p: string
21+
profile: string
22+
s: string
23+
store: string
24+
V: string
25+
verbose: string
26+
}
27+
28+
export const profileFlags: CommandOptions["flags"] = {
29+
boolean: ["V", "verbose"],
30+
alias: {
31+
verbose: ["V"],
32+
profile: ["p"],
33+
store: ["s"],
34+
},
35+
}

Diff for: tests/kind/profiles/gpu1/keep-it-simple

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

Diff for: tests/kind/profiles/non-gpu1/keep-it-simple

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "keep-it-simple",
33
"creationTime": 1664149787016,
4-
"lastModifiedTime": 1664149821230,
5-
"lastUsedTime": 1675364320141,
4+
"lastModifiedTime": 1676828268772,
5+
"lastUsedTime": 1676836671254,
66
"choices": {
77
"madwizard/apriori/use-gpu": "don't use gpus",
88
"madwizard/apriori/arch": "x64",
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

Diff for: tests/kind/profiles/non-gpu1/mcad-coscheduler

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
2324
"kubernetes/mcad/choose/scheduler": "MCAD with the Advanced Coscheduler"
2425
}

Diff for: tests/kind/profiles/non-gpu1/mcad-default

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
2324
"kubernetes/mcad/choose/scheduler": "MCAD with the Default Kubernetes Scheduler"
2425
}

Diff for: tests/kind/profiles/non-gpu1/mcad-preinstalled

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
2324
"kubernetes/mcad/choose/scheduler": "My administrator has already installed and configured MCAD"
2425
}

Diff for: tests/kind/profiles/non-gpu1/ray-autoscaler

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Ray Autoscaler"
2324
}
2425
}

Diff for: tests/kind/profiles/non-gpu2/keep-it-simple

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

Diff for: tests/kind/profiles/non-gpu3/keep-it-simple

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

Diff for: tests/kind/profiles/non-gpu4/keep-it-simple

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

Diff for: tests/kind/profiles/roberta-1gpu/keep-it-simple

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"kubernetes/choose/ns": "default",
2020
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
2121
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
22+
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
2223
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
2324
}
2425
}

0 commit comments

Comments
 (0)