Skip to content

Commit

Permalink
[Toolchain] Implement getModelInfo in ToolchainEnv (#1578)
Browse files Browse the repository at this point in the history
This commit implements getModelInfo() in ToolchainEnv.

ONE-vscode-DCO-1.0-Signed-off-by: Jiyoung Yun <[email protected]>
  • Loading branch information
jyoungyun authored Jun 6, 2023
1 parent 9c69e81 commit 87522a1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Tests/Toolchain/ToolchainEnv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,17 @@ suite("Toolchain", function () {
});
});
});

suite("#getModelInfo()", function () {
test("NEG: requests unimplemented getModelInfo", async function () {
let env = new ToolchainEnv(compiler);
const invalidToolchain = env.listInstalled();
assert.isAbove(invalidToolchain.length, 0);
const model = "model.bin";
await env.getModelInfo(invalidToolchain[0], model, "test").catch(() => {
assert.isTrue(true);
});
});
});
});
});
16 changes: 16 additions & 0 deletions src/Toolchain/ToolchainEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,22 @@ class ToolchainEnv extends Env {
this.executeEnv(jobs);
});
}

public getModelInfo(
toolchain: Toolchain,
model: string,
type: string
): Promise<string> {
return new Promise<string>((resolve, reject) => {
const jobs: Array<Job> = [];
const job = new JobConfig(toolchain.runShow(model, type));
job.workDir = path.dirname(model);
job.successCallback = () => resolve(job.result ? job.result : "");
job.failureCallback = () => reject();
jobs.push(job);
this.executeEnv(jobs);
});
}
}

/**
Expand Down

0 comments on commit 87522a1

Please sign in to comment.