Skip to content

Commit

Permalink
get queuesize and check up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Aug 6, 2024
1 parent 6550b5b commit 817d4d6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ <h3>Analysis Job from {{ analyzerJob.time }}</h3>
<span>{{ resParam.key }} = {{ resParam.value }}</span>
</div>
<p></p>
<div *ngIf="!qpuCheckFinished" class="spinner-wrapper">
<span><i>Check if QPU data is up-to-date</i></span>
<mat-spinner class="mat-spinner-left" [diameter]="20"></mat-spinner>
</div>
</div>
<div
*ngIf="jobReady && analyzerResults && analyzerResults.length === 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
EntityModelMcdaWeightLearningJob,
CriterionValue,
EntityModelMcdaJob,
QpuSelectionJobDto,
} from 'api-nisq/models';
import { AnalysisResultService } from 'api-nisq/services/analysis-result.service';
import { ImplementationService } from 'api-nisq/services/implementation.service';
Expand Down Expand Up @@ -353,6 +354,7 @@ export class NisqAnalyzerComponent implements OnInit {
this.jobReady = jobResult.ready;
this.analyzerJob = jobResult;
this.analyzerResults = jobResult.analysisResultList;
this.allQpuSelectionResults = [];
this.analyzerResults.forEach((analysisResult) => {
this.qpuSelectionService
.getQpuSelectionJob({ resId: analysisResult.qpuSelectionJobId })
Expand All @@ -363,19 +365,25 @@ export class NisqAnalyzerComponent implements OnInit {
this.dataSource = new MatTableDataSource(
this.allQpuSelectionResults
);
for (const analysisQpuSelectionResult of qpuSelectionJob.qpuSelectionResultList) {
this.queueLengths[analysisQpuSelectionResult.qpu] =
analysisQpuSelectionResult.queueSize;
this.hasExecutionResult(analysisQpuSelectionResult);
this.checkIfQpuDataIsOutdated(
analysisQpuSelectionResult,
qpuSelectionJob
);
}
});
});
for (const analysisResult of this.allQpuSelectionResults) {
this.showBackendQueueSize(analysisResult);
setInterval(() => this.showBackendQueueSize(analysisResult), 300000);
this.hasExecutionResult(analysisResult);
this.checkIfQpuDataIsOutdated(analysisResult);
}
});
return true;
}

checkIfQpuDataIsOutdated(analysisResult: QpuSelectionResultDto): void {
checkIfQpuDataIsOutdated(
analysisResult: QpuSelectionResultDto,
qpuSelectionJob: QpuSelectionJobDto

Check warning on line 385 in src/app/components/algorithms/nisq-analyzer/nisq-analyzer.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

'qpuSelectionJob' is defined but never used
): void {
let provider = null;
this.qprovService.getProviders().subscribe((providers) => {
for (const providerDto of providers._embedded.providerDtoes) {
Expand All @@ -391,29 +399,26 @@ export class NisqAnalyzerComponent implements OnInit {
this.qprovService
.getQpUs({ providerId: provider.id })
.subscribe((qpuResult) => {
for (const qpuDto of qpuResult._embedded.qpuDtoes) {
if (
qpuDto.name.toLowerCase() === analysisResult.qpu.toLowerCase()
) {
if (analysisResult.qpu.toLowerCase() === 'aer_simulator') {
this.qpuDataIsUpToDate.set(analysisResult, true);
} else {
for (const qpuDto of qpuResult._embedded.qpuDtoes) {
if (
qpuDto.lastCalibrated === null ||
Date.parse(analysisResult.time) >=
Date.parse(qpuDto.lastCalibrated)
qpuDto.name.toLowerCase() === analysisResult.qpu.toLowerCase()
) {
this.qpuDataIsUpToDate.set(analysisResult, true);
} else {
this.qpuDataIsUpToDate.set(analysisResult, false);
if (
qpuDto.lastCalibrated === null ||
Date.parse(analysisResult.time) >=
Date.parse(qpuDto.lastCalibrated)
) {
this.qpuDataIsUpToDate.set(analysisResult, true);
} else {
this.qpuDataIsUpToDate.set(analysisResult, false);
}
break;
}
break;
}
}
this.qpuCounter++;
if (this.qpuCounter === this.analyzerJob.analysisResultList.length) {
this.qpuCheckFinished = true;
this.qpuCounter = 0;
} else {
this.qpuCheckFinished = false;
}
});
});
}
Expand Down Expand Up @@ -582,11 +587,15 @@ export class NisqAnalyzerComponent implements OnInit {
}

showBackendQueueSize(analysisResult: QpuSelectionResultDto): void {
this.nisqAnalyzerService
.getIBMQBackendState(analysisResult.qpu)
.subscribe((data) => {
this.queueLengths[analysisResult.qpu] = data.lengthQueue;
});
if (analysisResult.qpu !== 'aer_simluator') {
this.nisqAnalyzerService
.getIBMQBackendState(analysisResult.qpu)
.subscribe((data) => {
this.queueLengths[analysisResult.qpu] = data.lengthQueue;
});
} else {
this.queueLengths[analysisResult.qpu] = analysisResult.queueSize;
}
}

setVendorTokens(
Expand Down

0 comments on commit 817d4d6

Please sign in to comment.