Skip to content

Commit

Permalink
feat: codeflare logs command
Browse files Browse the repository at this point in the history
update tests/kind/run to use plain log streamer
  • Loading branch information
starpit committed Feb 19, 2023
1 parent ea9d7e6 commit 3e65eb7
Show file tree
Hide file tree
Showing 19 changed files with 192 additions and 135 deletions.
2 changes: 1 addition & 1 deletion deploy/self-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL org.opencontainers.image.source https://github.com/project-codeflare/codef

ENV DEBIAN_FRONTEND=noninteractive

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

Expand Down
34 changes: 17 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions plugins/plugin-codeflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"@types/split2": "^3.2.1"
},
"dependencies": {
"@guidebooks/store": "^3.3.9",
"@guidebooks/store": "^3.3.12",
"@logdna/tail-file": "^3.0.1",
"@patternfly/react-charts": "^6.94.18",
"@patternfly/react-core": "^4.276.6",
"asciinema-player": "^3.0.1",
"chokidar": "^3.5.3",
"madwizard": "^6.1.2",
"madwizard": "^6.2.0",
"needle": "^3.2.0",
"open": "^8.4.0",
"pretty-bytes": "^6.0.0",
Expand Down
20 changes: 20 additions & 0 deletions plugins/plugin-codeflare/src/controller/appName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2022 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { productName } from "@kui-shell/client/config.d/name.json"

const appName = productName.toLowerCase()
export default appName
2 changes: 1 addition & 1 deletion plugins/plugin-codeflare/src/controller/attach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Debug from "debug"
import { MadWizardOptions } from "madwizard"
import { Arguments, Capabilities, ParsedOptions } from "@kui-shell/core"

import appName from "./appName"
import { DashboardOptions } from "./dashboard"

export type Options = ParsedOptions &
Expand Down Expand Up @@ -57,7 +58,6 @@ export async function attach(
process.env.JOB_ID = jobId
}

const appName = "codeflare"
const options: MadWizardOptions = Object.assign(
{
appName,
Expand Down
7 changes: 7 additions & 0 deletions plugins/plugin-codeflare/src/controller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import events from "./events"
import dashboard from "./dashboard"
import description from "./description"
import { Options as AttachOptions } from "./attach"
import { ProfileOptions, profileFlags } from "./options"

function help() {
return `Usage:
Expand All @@ -42,6 +43,12 @@ export default function registerCodeflareCommands(registrar: Registrar) {
description(registrar)
registrar.listen("/help", help)

registrar.listen<KResponse, ProfileOptions>(
"/codeflare/logs",
(args) => import("./logs").then((_) => _.default(args)),
{ flags: profileFlags }
)

registrar.listen<KResponse, AttachOptions>(
"/codeflare/attach",
(args) => import("./attach").then((_) => _.default(args)),
Expand Down
53 changes: 53 additions & 0 deletions plugins/plugin-codeflare/src/controller/logs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2023 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Arguments } from "@kui-shell/core"
import { MadWizardOptions } from "madwizard"

import appName from "./appName"
import { ProfileOptions } from "./options"

export default async function logs(args: Arguments<ProfileOptions>) {
// Display logs for this jobID; if not provided, the user will be
// prompted (via the guidebook) to choose one
const jobId = args.argvNoOptions[args.argvNoOptions.indexOf("logs") + 1]
if (jobId) {
process.env.JOB_ID = jobId
}

// play this guidebook
const guidebook = jobId === undefined ? "ml/ray/aggregator" : "ml/ray/aggregator/with-jobid"

// but only interactive starting here
const ifor =
jobId === undefined
? ["ml/ray/cluster/choose", "ml/ray/cluster/choose/kubernetes", "ml/ray/run/choose/list-jobs"]
: undefined

const options: MadWizardOptions = Object.assign({
appName,
store: args.parsedOptions.s || process.env.GUIDEBOOK_STORE,
verbose: args.parsedOptions.V,
profile: args.parsedOptions.profile || (await import("madwizard").then((_) => _.Profiles.lastUsed())),
interactive: false,
ifor,
})

const { guide } = await import("madwizard/dist/fe/cli")

await guide([appName, "guide", guidebook], undefined, options)
return true
}
35 changes: 35 additions & 0 deletions plugins/plugin-codeflare/src/controller/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2023 The Kubernetes Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { CommandOptions, ParsedOptions } from "@kui-shell/core"

export type ProfileOptions = ParsedOptions & {
p: string
profile: string
s: string
store: string
V: string
verbose: string
}

export const profileFlags: CommandOptions["flags"] = {
boolean: ["V", "verbose"],
alias: {
verbose: ["V"],
profile: ["p"],
store: ["s"],
},
}
1 change: 1 addition & 0 deletions tests/kind/profiles/gpu1/keep-it-simple
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
5 changes: 3 additions & 2 deletions tests/kind/profiles/non-gpu1/keep-it-simple
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "keep-it-simple",
"creationTime": 1664149787016,
"lastModifiedTime": 1664149821230,
"lastUsedTime": 1675364320141,
"lastModifiedTime": 1676828268772,
"lastUsedTime": 1676836671254,
"choices": {
"madwizard/apriori/use-gpu": "don't use gpus",
"madwizard/apriori/arch": "x64",
Expand All @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu1/mcad-coscheduler
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
"kubernetes/mcad/choose/scheduler": "MCAD with the Advanced Coscheduler"
}
Expand Down
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu1/mcad-default
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
"kubernetes/mcad/choose/scheduler": "MCAD with the Default Kubernetes Scheduler"
}
Expand Down
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu1/mcad-preinstalled
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Multi-user Enhanced Kubernetes Scheduler",
"kubernetes/mcad/choose/scheduler": "My administrator has already installed and configured MCAD"
}
Expand Down
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu1/ray-autoscaler
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Use the Ray Autoscaler"
}
}
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu2/keep-it-simple
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu3/keep-it-simple
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
1 change: 1 addition & 0 deletions tests/kind/profiles/non-gpu4/keep-it-simple
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
1 change: 1 addition & 0 deletions tests/kind/profiles/roberta-1gpu/keep-it-simple
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"kubernetes/choose/ns": "default",
"ml/ray/storage/s3/maybe": "My code does not use Ray Workflows",
"ml/ray/cluster/choose": "codeflare-test-ray-cluster",
"ml/ray/cluster/choose/kubernetes": "codeflare-test-ray-cluster",
"ml/ray/cluster/kubernetes/choose-pod-scheduler": "Keep It Simple"
}
}
Loading

0 comments on commit 3e65eb7

Please sign in to comment.