Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
default to generate jsonc job config file
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaladin committed Mar 1, 2019
1 parent 9526117 commit 9e7f41c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contrib/pai_vscode/schemas/pai_job_config.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "object",
"description": "PAI job config",
"description": "PAI job config\nThis file can be submitted directly on PAI web portal.",
"properties": {
"jobName": {
"type": "string",
Expand Down
15 changes: 11 additions & 4 deletions contrib/pai_vscode/src/pai/paiJobManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class PAIJobManager extends Singleton {
parent = fileFolders[0].uri.fsPath;
}
}
defaultSaveDir = path.join(parent, `${name}.pai.json`);
defaultSaveDir = path.join(parent, `${name}.pai.jsonc`);
config = {
jobName: '<job name>',
image: 'aiplatform/pai.build.base',
Expand Down Expand Up @@ -161,7 +161,7 @@ export class PAIJobManager extends Singleton {
}
script = path.relative(parent, script);
const jobName: string = path.basename(script, path.extname(script));
defaultSaveDir = path.join(parent, `${jobName}.pai.json`);
defaultSaveDir = path.join(parent, `${jobName}.pai.jsonc`);
config = {
jobName,
image: 'aiplatform/pai.build.base',
Expand All @@ -182,10 +182,17 @@ export class PAIJobManager extends Singleton {
}

const saveDir: vscode.Uri | undefined = await vscode.window.showSaveDialog({
defaultUri: vscode.Uri.file(defaultSaveDir)
defaultUri: vscode.Uri.file(defaultSaveDir),
filters: {
JSON: ['json', 'jsonc']
}
});
if (saveDir) {
await fs.writeJSON(saveDir.fsPath, config, { spaces: 4 });
if (saveDir.fsPath.endsWith('.jsonc')) {
await fs.writeFile(saveDir.fsPath, await Util.generateCommentedJSON(config, 'pai_job_config.schema.json'));
} else {
await fs.writeJSON(saveDir.fsPath, config, { spaces: 4 });
}
await vscode.window.showTextDocument(saveDir);
}
}
Expand Down

0 comments on commit 9e7f41c

Please sign in to comment.