import * as vscode from 'vscode'; export class ToolBridgeMaster { constructor(public readonly name: string) { } public async Exec(message: ExecMessage) { const rawMessage : any = message.Serialize() await vscode.commands.executeCommand(this.name+'.Exec', rawMessage); } public async CompareTests(message: CompareTestsMessage) { const rawMessage : any = message.Serialize() await vscode.commands.executeCommand(this.name+'.CompareTests', rawMessage); } } export class ToolBridgeSlave { constructor(public readonly name: string) { } public async NotifyReports(message: ReportsMessage) { const rawMessage : any = message.Serialize() await vscode.commands.executeCommand(this.name+'.NotifyReports', rawMessage); } public async NotifyOutputs(message: OutputsMessage) { const rawMessage : any = message.Serialize() await vscode.commands.executeCommand(this.name+'.NotifyOutputs', rawMessage); } } export class ExecMessage { constructor( public readonly userFolder : vscode.Uri, public readonly testFolder : vscode.Uri, public readonly modelFile: vscode.Uri, public readonly projectName: string, public readonly projectId: string, public readonly modelName: string, public readonly modelId: string, public readonly experimentName: string, public readonly experimentId: string, public readonly testName: string, public readonly testId: string, public readonly defaultParameters: any, public readonly customizableParameters: any ) {} public Serialize() : any { return { user_folder: this.userFolder.fsPath, test_folder: this.testFolder.fsPath, model_file: this.modelFile.fsPath, project_name: this.projectName, project_id: this.projectId, model_name: this.modelName, model_id: this.modelId, experiment_name: this.experimentName, experiment_id: this.experimentId, test_name: this.testName, test_id: this.testId, default_parameters: this.defaultParameters, customizable_parameters: this.customizableParameters, }; } public static Deserialize(message: any) : ExecMessage { return new ExecMessage( vscode.Uri.parse(message.user_folder), vscode.Uri.parse(message.test_folder), vscode.Uri.parse(message.model_file), message.project_name, message.project_id, message.model_name, message.model_id, message.experiment_name, message.experiment_id, message.test_name, message.test_id, message.default_parameters, message.customizable_parameters ); } } export class CompareTestsMessage { constructor( public readonly projectName: string, public readonly projectId: string, public readonly modelName: string, public readonly modelId: string, public readonly tests : Array, ) {} public Serialize() : any { const tests : [string, string, string, string, string][] = this.tests.map( t => t.Serialize() ); return { project_name: this.projectName, project_id: this.projectId, model_name: this.modelName, model_id: this.modelId, tests: tests }; } public static Deserialize(message: any) : CompareTestsMessage { const tests : [string, string, string, string, string][] = message.tests; return new CompareTestsMessage( message.project_name, message.project_id, message.model_name, message.model_id, tests.map( t => new TestDescriptor(t[0],t[1], t[2], t[3], vscode.Uri.parse(t[4]))) ); } } export class TestDescriptor { constructor( public readonly experimentId: string, public readonly experimentName: string, public readonly testId: string, public readonly testName: string, public readonly testFolder: vscode.Uri ) {} public Serialize() : [string, string, string, string, string] { return [ this.experimentId, this.experimentName, this.testId, this.testName, this.testFolder.fsPath ]; } public static Deserialize(message: [string, string, string, string, string] ) : TestDescriptor { return new TestDescriptor(message[0], message[1], message[2], message[3], vscode.Uri.parse(message[4])); } } export class ReportsMessage { constructor( public readonly projectId: string, public readonly modelId: string, public readonly experimentId: string, public readonly testId: string, public readonly parameters: string[], public readonly resports: string[] ) {} public Serialize() : any { return { project_id: this.projectId, model_id: this.modelId, experiment_id: this.experimentId, test_id: this.testId, parameters: this.parameters, reports: this.resports }; } public static Deserialize(message: any ) : ReportsMessage { return new ReportsMessage( message.project_id, message.model_id, message.experiment_id, message.test_id, message.parameters, message.reports ); } } export class OutputsMessage { constructor( public readonly projectId: string, public readonly modelId: string, public readonly experimentId: string, public readonly testId: string, public readonly parameters: string[], public readonly outputs: string[] ) {} public Serialize() : any { return { project_id: this.projectId, model_id: this.modelId, experiment_id: this.experimentId, test_id: this.testId, parameters: this.parameters, outputs: this.outputs }; } public static Deserialize(message: any ) : OutputsMessage { return new OutputsMessage( message.project_id, message.model_id, message.experiment_id, message.test_id, message.parameters, message.outputs ); } }