Skip to content

Commit

Permalink
set multiple tokens for qpu selection
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Nov 27, 2023
1 parent b725861 commit b7aef61
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable */
export type ExecuteAnalysisResultRequestDto = {
refreshToken?: string;
tokens?: Map<string, Map<string, string>>;
tokens?: {};
};
2 changes: 1 addition & 1 deletion generated/api-nisq/models/qpu-selection-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type QpuSelectionDto = {
circuitLanguage?: string;
circuitUrl?: string;
qasmCode?: string;
tokens?: Map<string, Map<string, string>>;
tokens?: {};
refreshToken?: string;
circuitName?: string;
preciseResultsPreference?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
selectedCompilers: string[] = [];

ibmqEnabled = true;
ionqEnabled = true;
ionqEnabled = false;
shortWaitingTimeEnabled = false;
stableExecutionResultsEnabled = false;
predictionAlgorithmInDialog = 'extra_trees_regressor';
Expand Down Expand Up @@ -136,11 +136,11 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
),
});

this.selectedVendors = ['ibmq', 'ionq'];
this.selectedVendors = ['ibmq'];
for (const vendor of this.selectedVendors) {
this.vendors.push(new FormControl(vendor));
}
this.setCompilerOptions(this.vendors.value);
this.setCompilerOptions(this.selectedVendors);
this.predictionAlgorithm.setValue('extra_trees_regressor');
this.metaOptimizer.setValue('ada_boost_regressor');
this.maxNumberOfCompiledCircuits.setValue(5);
Expand All @@ -167,7 +167,7 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
}

updateCompilerSelection(compilerName: string, allowed: boolean): void {
if (allowed) {
if (allowed && !this.selectedCompilers.includes(compilerName)) {
this.selectedCompilers.push(compilerName);
} else {
this.selectedCompilers = this.selectedCompilers.filter(
Expand All @@ -192,7 +192,6 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
}

setCompilerOptions(vendors: string[]): void {
debugger;
const setOfAllAvailableCompilers = new Set<string>();
for (const vendor of vendors) {
this.nisqAnalyzerService
Expand All @@ -201,22 +200,23 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
for (const availableCompiler of availableCompilers) {
setOfAllAvailableCompilers.add(availableCompiler);
}
setOfAllAvailableCompilers.forEach((compiler) => {
if (!this.selectedCompilers.includes(compiler)) {
this.selectedCompilers.push(compiler);
}
});
this.compilers.clear();
for (const compiler of setOfAllAvailableCompilers) {
this.compilers.push(new FormControl(compiler));
}
});
setOfAllAvailableCompilers.forEach((compiler) =>
this.selectedCompilers.push(compiler)
);
this.compilers.clear();
for (const compiler of this.selectedCompilers) {
this.compilers.push(new FormControl(compiler));
}
}
}

setIbmqEnabled(enabled: boolean): void {
this.ibmqEnabled = enabled;
if (enabled) {
this.selectedVendors.push('ibmq');
this.setCompilerOptions(['ibmq']);
} else {
this.selectedVendors = this.selectedVendors.filter(
(item) => item !== 'ibmq'
Expand All @@ -228,7 +228,6 @@ export class ImplementationNisqAnalyzerQpuSelectionDialogComponent
this.ionqEnabled = enabled;
if (enabled) {
this.selectedVendors.push('ionq');
this.setCompilerOptions(['ionq']);
} else {
this.selectedVendors = this.selectedVendors.filter(
(item) => item !== 'ionq'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,20 @@ export class ImplementationNisqAnalyzerQpuSelectionComponent
this.analyzerJob = undefined;
this.jobReady = false;
refreshToken = this.planqkService.getRefreshToken();
const tokensToDeliver = this.setVendorTokens(
dialogResult.vendors,
dialogResult.ibmqToken,
dialogResult.awsToken,
dialogResult.awsSecretToken
);

debugger;

Check failure on line 225 in src/app/components/algorithms/implementation-view/implementation-nisq-analyzer-qpu-selection/implementation-nisq-analyzer-qpu-selection.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Unexpected 'debugger' statement

const qpuSelectionDto: QpuSelectionDto = {
allowedProviders: dialogResult.vendors,
circuitLanguage: this.nisqImpl.language,
circuitUrl: this.nisqImpl.fileLocation,
tokens: this.setVendorTokens(
dialogResult.vendors,
dialogResult.ibmqToken,
dialogResult.awsToken,
dialogResult.awsSecretToken
),
tokens: tokensToDeliver,
refreshToken,
compilers: dialogResult.selectedCompilers,
circuitName: this.nisqImpl.name,
Expand Down Expand Up @@ -368,21 +371,32 @@ export class ImplementationNisqAnalyzerQpuSelectionComponent
ibmqToken: string,
awsToken: string,
awsSecretToken: string
): Map<string, Map<string, string>> {
const providerTokens: Map<string, Map<string, string>> = new Map();
const rawTokens: Map<string, string> = new Map();
if (vendors.filter((vendor) => vendor === 'ibmq') != null) {
rawTokens.clear();
rawTokens.set('ibmq', ibmqToken);
providerTokens.set('ibmq', rawTokens);
): {} {
const providerTokens = new Map<string, Map<string, string>>();
const rawTokensIbmq = new Map<string, string>();
const rawTokensIonq = new Map<string, string>();
debugger;

Check failure on line 378 in src/app/components/algorithms/implementation-view/implementation-nisq-analyzer-qpu-selection/implementation-nisq-analyzer-qpu-selection.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Unexpected 'debugger' statement
if (vendors.includes('ibmq')) {
rawTokensIbmq.set('ibmq', ibmqToken);
providerTokens.set('ibmq', rawTokensIbmq);
}
if (vendors.filter((vendor) => vendor === 'ionq') != null) {
rawTokens.clear();
rawTokens.set('awsAccessKey', awsToken);
rawTokens.set('awsSecretKey', awsSecretToken);
providerTokens.set('ionq', rawTokens);
if (vendors.includes('ionq')) {
rawTokensIonq.set('awsAccessKey', awsToken);
rawTokensIonq.set('awsSecretKey', awsSecretToken);
providerTokens.set('ionq', rawTokensIonq);
}
return providerTokens;

debugger;

Check failure on line 389 in src/app/components/algorithms/implementation-view/implementation-nisq-analyzer-qpu-selection/implementation-nisq-analyzer-qpu-selection.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Unexpected 'debugger' statement
// converting such that it can be delivered via HTTP
const convMap: { [props: string]: { [props: string]: string } } = {};
providerTokens.forEach((val: Map<string, string>, key: string) => {
const innerConvMap: { [props: string]: string } = {};
val.forEach((subVal: string, subkey: string) => {
innerConvMap[subkey] = subVal;
});
convMap[key] = innerConvMap;
});
return convMap;
}

hasExecutionResult(analysisResult: QpuSelectionResultDto): void {
Expand Down

0 comments on commit b7aef61

Please sign in to comment.