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

SUBMARINE-556. [WEB] Connect workbench with database for metric #349

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
[workerIndex]="selectedPod"
[paramData]="paramData"
></submarine-hyper-params>
<submarine-metrics *ngSwitchCase="2"></submarine-metrics>
<submarine-metrics *ngSwitchCase="2" [workerIndex]="selectedPod" [metricData]="metricData"></submarine-metrics>
<submarine-outputs
*ngSwitchCase="3"
[podName]="selectedPod"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ExperimentInfoComponent implements OnInit {
podNameArr;
podLogArr;
paramData;
metricData;

constructor(
private router: Router,
Expand Down Expand Up @@ -76,7 +77,7 @@ export class ExperimentInfoComponent implements OnInit {

this.experimentService
.getExperimentParam({
jobName: null
jobName: this.experimentID
})
.subscribe(
(result) => {
Expand All @@ -87,12 +88,26 @@ export class ExperimentInfoComponent implements OnInit {
console.log(err);
}
);

this.experimentService
.getExperimentMetric({
jobName: this.experimentID
})
.subscribe(
(result) => {
this.metricData = result;
},
(err) => {
this.nzMessageService.error('Cannot load metric of ' + this.experimentID);
console.log(err);
}
);
}

onDeleteExperiment() {
this.experimentService.deleteExperiment(this.experimentID).subscribe(
() => {
this.nzMessageService.success('Delete user success!');
this.nzMessageService.success('Delete experiment success!');
this.router.navigate(['/workbench/experiment']);
},
(err) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ export class HyperParamsComponent implements OnInit {
@Input() paramData;
podParam = [];

constructor(private baseApi: BaseApiService, private httpClient: HttpClient) {}
constructor() {}

ngOnInit() {}

ngOnChanges(chg: SimpleChanges) {
this.podParam.length = 0;
this.paramData.forEach((data) => {
if (data.workerIndex == this.workerIndex) {
this.podParam.push(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,25 @@
~ under the License.
-->

<p>metrics works!</p>
<div id="metricTable">
<nz-table #metricTable nzSize="middle" [nzBordered]="true" [nzFrontPagination]="false" [nzData]="podMetric">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
<th>Time</th>
<th>Step</th>
<th>Is_NaN</th>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove this line
If Is_NaN is true, we set metric value string to "Nan"

</tr>
</thead>
<tbody>
<tr *ngFor="let metric of metricTable.data">
<td>{{ metric.key }}</td>
<td>{{ metric.value }}</td>
<td>{{ metric.timestamp }}</td>
<td>{{ metric.step }}</td>
<td>{{ metric.is_nan }}</td>
</tr>
</tbody>
</nz-table>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
* under the License.
*/


#metricTable {
background-color: white;
height: 500px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,28 @@
* under the License.
*/

import { Component, OnInit } from '@angular/core';
import { Component, OnInit, Input, SimpleChanges } from '@angular/core';

@Component({
selector: 'submarine-metrics',
templateUrl: './metrics.component.html',
styleUrls: ['./metrics.component.scss']
})
export class MetricsComponent implements OnInit {
@Input() workerIndex;
@Input() metricData;
podMetric = [];

constructor() {}

ngOnInit() {}

ngOnChanges(chg: SimpleChanges) {
this.podMetric.length = 0;
this.metricData.forEach((data) => {
if (data.workerIndex == this.workerIndex) {
this.podMetric.push(data);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,17 @@ export class ExperimentService {
})
);
}

getExperimentMetric(param: object): Observable<any> {
const apiUrl = this.baseApi.getRestApi('/metric/selective');
return this.httpClient.post<any>(apiUrl, param).pipe(
switchMap((res) => {
if (res.success) {
return of(res.result);
} else {
throw this.baseApi.createRequestError(res.message, res.code, apiUrl, 'post', param);
}
})
);
}
}