Skip to content

Commit 0d67d10

Browse files
committed
fix: update codeflare attach to use logdir created by the guidebook
Also updates the related dashboard commands to improve handling of filepaths with spaces.
1 parent f4873fc commit 0d67d10

File tree

4 files changed

+29
-41
lines changed

4 files changed

+29
-41
lines changed

package-lock.json

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

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

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,28 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { dir } from "tmp"
1817
import { cli } from "madwizard/dist/fe/cli"
1918
import { MadWizardOptions } from "madwizard"
20-
import { Arguments, KResponse } from "@kui-shell/core"
19+
import { Arguments, encodeComponent } from "@kui-shell/core"
2120

2221
export default async function attach(args: Arguments) {
23-
return new Promise<KResponse>((resolve, reject) => {
24-
dir({ prefix: "logdir-stage" }, async (err, logdir) => {
25-
if (err) {
26-
reject(err)
27-
}
22+
const options: MadWizardOptions = { store: process.env.GUIDEBOOK_STORE, clean: false }
2823

29-
try {
30-
const options: MadWizardOptions = { store: process.env.GUIDEBOOK_STORE, clean: false }
24+
// TODO: update madwizard to accept env in the options
25+
process.env.NO_WAIT = "true" // don't wait for job termination
26+
process.env.QUIET_CONSOLE = "true" // don't tee logs to the console
3127

32-
// TODO: update madwizard to accept env in the options
33-
process.env.LOGDIR_STAGE = logdir // stage log files here
34-
process.env.NO_WAIT = "true" // don't wait for job termination
35-
process.env.QUIET_CONSOLE = "true" // don't tee logs to the console
28+
const resp = await cli(["codeflare", "guide", "ml/ray/aggregator"], undefined, options)
3629

37-
/* const cleanup = */ await cli(["codeflare", "guide", "ml/ray/aggregator"], undefined, options)
38-
/* if (typeof cleanup === 'function') {
39-
onQuit(cleanup)
40-
} */
30+
const logdir = resp && resp.env ? resp.env.LOGDIR_STAGE : undefined
4131

42-
await args.REPL.qexec(`codeflare dashboardui -f ${logdir}`)
32+
if (logdir) {
33+
process.env.LOGDIR = logdir
34+
await args.REPL.qexec(`codeflare dashboardui -f ${encodeComponent(logdir)}`)
35+
} else {
36+
throw new Error("Could not attach, due to missing logging directory")
37+
}
4338

44-
// TODO: when job completes, auto-exit
45-
46-
resolve(true)
47-
} catch (err) {
48-
console.error(err)
49-
reject(err)
50-
}
51-
})
52-
})
39+
// TODO: when job completes, auto-exit
40+
return true
5341
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { join } from "path"
18-
import { Arguments, Registrar } from "@kui-shell/core"
18+
import { Arguments, Registrar, encodeComponent } from "@kui-shell/core"
1919
import { expand } from "../lib/util"
2020

2121
type Item = { label: string; value: string }
@@ -45,7 +45,7 @@ export type SummaryResponse = {
4545

4646
/** Given the location of the staging directory, return the location of the ray job definition */
4747
function jobDefinition(filepath: string) {
48-
return expand(join(filepath.replace(/'/g, ""), "ray-job-definition.json"))
48+
return encodeComponent(expand(join(filepath.replace(/'/g, ""), "ray-job-definition.json")))
4949
}
5050

5151
async function app(args: Arguments) {

plugins/plugin-madwizard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"access": "public"
2424
},
2525
"dependencies": {
26-
"madwizard": "^0.15.0"
26+
"madwizard": "^0.15.3"
2727
}
2828
}

0 commit comments

Comments
 (0)