Skip to content

Commit 64e2659

Browse files
committed
fix: usesGpus needs to wait for env.json file to exist
also picks up some fixes from the store for torchx env file population
1 parent 5981b74 commit 64e2659

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Diff for: package-lock.json

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type Tail = {
2626
quit: TailFile["quit"]
2727
}
2828

29-
function waitTillExists(filepath: string) {
29+
export function waitTillExists(filepath: string) {
3030
const watcher = chokidar.watch(filepath)
3131
return new Promise<void>((resolve, reject) => {
3232
watcher.on("add", () => resolve())

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,14 @@ function toRecord(nva: NameValue[]): Record<string, unknown> {
3535
}, {} as Record<string, unknown>)
3636
}
3737

38+
async function getJobEnvFilepath(profile: string, jobId: string): Promise<string> {
39+
return join(await import("./path.js").then((_) => _.pathFor(profile, jobId)), "env.json")
40+
}
41+
3842
export async function getJobEnv(profile: string, jobId: string): Promise<Record<string, unknown>> {
39-
const filepath = await import("./path.js").then((_) => _.pathFor(profile, jobId))
43+
const filepath = await getJobEnvFilepath(profile, jobId)
4044
const nameValueArray = JSON.parse(
41-
await import("fs/promises").then((_) => _.readFile(join(filepath, "env.json"))).then((_) => _.toString())
45+
await import("fs/promises").then((_) => _.readFile(filepath)).then((_) => _.toString())
4246
)
4347
if (!isNameValueArray(nameValueArray)) {
4448
throw new Error("Malformatted env.json file")
@@ -48,6 +52,9 @@ export async function getJobEnv(profile: string, jobId: string): Promise<Record<
4852
}
4953

5054
export async function numGpus(profile: string, jobId: string): Promise<number> {
55+
const filepath = await getJobEnvFilepath(profile, jobId)
56+
await import("./dashboard/tailf.js").then((_) => _.waitTillExists(filepath))
57+
5158
try {
5259
const env = await getJobEnv(profile, jobId)
5360

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@types/split2": "^3.2.1"
3131
},
3232
"dependencies": {
33-
"@guidebooks/store": "^7.5.13",
33+
"@guidebooks/store": "^7.5.15",
3434
"@logdna/tail-file": "^3.0.1",
3535
"@patternfly/react-charts": "^6.94.18",
3636
"@patternfly/react-core": "^4.276.6",

0 commit comments

Comments
 (0)