Skip to content

Commit d5ae977

Browse files
committed
feat: codeflare attach command
This command executes the `ml/ray/aggregator` guidebook, and then launches the dashboard against the aggregator's staging directory. TODO: the underlying aggregator guidebooks are still teeing to the console. We need to inhibit this somehow.
1 parent d143382 commit d5ae977

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

bin/codeflare

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ if [ $use_docker = 1 ]; then
126126
exec docker run -it --entrypoint ${ENTRYPOINT-codeflare} --rm -v /tmp:/tmp -v ~/.aws:/home/codeflare/.aws -v ~/.bluemix:/home/codeflare/.bluemix -v ~/.kube:/home/codeflare/.kube -e KUBECONFIG=$(echo $KUBECONFIG | sed "s/$USER/codeflare/g" | sed 's/Users/home/g') ghcr.io/project-codeflare/codeflare-cli -- $*
127127
fi
128128

129-
if ([ $do_cli = 1 ] && [ $# = 0 ]) || ([ $# = 1 ] && [ "$1" != "version" ]); then
129+
if ([ $do_cli = 1 ] && [ $# = 0 ]) || ([ $# = 1 ] && [ "$1" != "version" ] && [ "$1" != "attach" ]); then
130+
# TODO make this a kui command catchall
130131
# use the "guide" command if none was given
131132
EXTRAPREFIX="$EXTRAPREFIX guide"
132133
fi

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
"@types/react": "17.0.39",
9797
"@types/react-dom": "17.0.11",
9898
"@types/split2": "^3.2.1",
99+
"@types/tmp": "^0.2.3",
99100
"@types/uuid": "^8.3.4",
100101
"@typescript-eslint/eslint-plugin": "^5.30.5",
101102
"@typescript-eslint/parser": "^5.30.5",

plugins/plugin-codeflare/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"pretty-bytes": "^6.0.0",
3030
"split2": "^4.1.0",
3131
"strip-ansi": "6.0.0",
32+
"tmp": "^0.2.1",
3233
"xterm-addon-search": "^0.9.0"
3334
}
3435
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 { dir } from "tmp"
18+
import { cli } from "madwizard/dist/fe/cli"
19+
import { Arguments, KResponse } from "@kui-shell/core"
20+
21+
export default async function attach(args: Arguments) {
22+
return new Promise<KResponse>((resolve, reject) => {
23+
dir(async (err, logdir) => {
24+
if (err) {
25+
reject(err)
26+
}
27+
28+
process.env.LOGDIR_STAGE = logdir
29+
await cli(["codeflare", "guide", "ml/ray/aggregator"], undefined, { store: process.env.GUIDEBOOK_STORE })
30+
resolve(args.REPL.qexec(`codeflare dashboard ${logdir}`))
31+
})
32+
})
33+
}

plugins/plugin-codeflare/src/controller/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ import description from "./description"
2626
function help() {
2727
return `Usage:
2828
codeflare [run] [<task>] [-s /path/to/store] [-u]
29+
codeflare attach
2930
codeflare dashboard /path/to/logdir
3031
codeflare chart gpu /path/to/logdir`
3132
}
3233

3334
/** Register Kui Commands */
3435
export default function registerCodeflareCommands(registrar: Registrar) {
3536
tailf(registrar)
37+
registrar.listen("/attach", (args) => import("./attach").then((_) => _.default(args)))
3638
browse(registrar)
3739
charts(registrar)
3840
events(registrar)

0 commit comments

Comments
 (0)