-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Distinct page for each Trial in the UI
- Loading branch information
Showing
18 changed files
with
593 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
pkg/new-ui/v1beta1/frontend/src/app/models/trial.k8s.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { K8sObject } from 'kubeflow'; | ||
import { V1Container } from '@kubernetes/client-node'; | ||
|
||
/* | ||
* K8s object definitions | ||
*/ | ||
export const TRIAL_KIND = 'Trial'; | ||
export const TRIAL_APIVERSION = 'kubeflow.org/v1beta1'; | ||
|
||
export interface TrialK8s extends K8sObject { | ||
spec?: TrialSpec; | ||
status?: TrialStatus; | ||
} | ||
|
||
export interface TrialSpec { | ||
metricsCollector: MetricsCollector; | ||
objective: Objective; | ||
parameterAssignments: { name: string; value: number }[]; | ||
primaryContainerName: string; | ||
successCondition: string; | ||
failureCondition: string; | ||
runSpec: K8sObject; | ||
} | ||
|
||
export interface MetricsCollector { | ||
collector?: CollectorSpec; | ||
} | ||
|
||
export interface CollectorSpec { | ||
kind: CollectorKind; | ||
customCollector: V1Container; | ||
} | ||
|
||
export type CollectorKind = | ||
| 'StdOut' | ||
| 'File' | ||
| 'TensorFlowEvent' | ||
| 'PrometheusMetric' | ||
| 'Custom' | ||
| 'None'; | ||
|
||
export interface Objective { | ||
type: ObjectiveType; | ||
goal: number; | ||
objectiveMetricName: string; | ||
additionalMetricNames: string[]; | ||
metricStrategies: MetricStrategy[]; | ||
} | ||
|
||
export type ObjectiveType = 'maximize' | 'minimize'; | ||
|
||
export interface MetricStrategy { | ||
name: string; | ||
value: string; | ||
} | ||
|
||
export interface RunSpec { | ||
|
||
} | ||
|
||
/* | ||
* status | ||
*/ | ||
|
||
interface TrialStatus { | ||
startTime: string; | ||
completionTime: string; | ||
conditions: TrialStatusCondition[]; | ||
observation: { | ||
metrics: { | ||
name: string; | ||
latest: number; | ||
min: number; | ||
max: string; | ||
}[]; | ||
} | ||
} | ||
|
||
interface TrialStatusCondition { | ||
type: string; | ||
status: boolean; | ||
reason: string; | ||
message: string; | ||
lastUpdateTime: string; | ||
lastTransitionTime: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
.../experiment-details/trials-table/trial-modal/overview/trial-modal-overview.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<lib-details-list-item key="Trial Name"> | ||
{{ trialName }} | ||
</lib-details-list-item> | ||
|
||
<lib-details-list-item key="Experiment Name"> | ||
{{ experimentName }} | ||
</lib-details-list-item> | ||
|
||
<lib-details-list-item key="Status" [icon]="statusIcon"> | ||
{{ status }} | ||
</lib-details-list-item> | ||
|
||
<lib-details-list-item [chipsList]="performance" key="Performance"> | ||
</lib-details-list-item> | ||
|
||
<lib-conditions-table | ||
*ngIf="trial" | ||
[conditions]="trial.status.conditions" | ||
title="Trial Conditions" | ||
></lib-conditions-table> |
24 changes: 24 additions & 0 deletions
24
...periment-details/trials-table/trial-modal/overview/trial-modal-overview.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TrialModalOverviewComponent } from './trial-modal-overview.component'; | ||
|
||
describe('TrialModalOverviewComponent', () => { | ||
let component: TrialModalOverviewComponent; | ||
let fixture: ComponentFixture<TrialModalOverviewComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [TrialModalOverviewComponent], | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TrialModalOverviewComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
111 changes: 111 additions & 0 deletions
111
...es/experiment-details/trials-table/trial-modal/overview/trial-modal-overview.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
Input, | ||
OnChanges, | ||
} from '@angular/core'; | ||
import { | ||
ChipDescriptor, | ||
getCondition, | ||
} from 'kubeflow'; | ||
import { StatusEnum } from 'src/app/enumerations/status.enum'; | ||
import { TrialK8s } from 'src/app/models/trial.k8s.model'; | ||
import { numberToExponential } from 'src/app/shared/utils'; | ||
|
||
|
||
@Component({ | ||
selector: 'app-trial-modal-overview', | ||
templateUrl: './trial-modal-overview.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class TrialModalOverviewComponent implements OnChanges { | ||
status: string; | ||
statusIcon: string; | ||
performance: ChipDescriptor[]; | ||
|
||
@Input() | ||
trialName: string; | ||
|
||
@Input() | ||
trial: TrialK8s; | ||
|
||
@Input() | ||
experimentName: string; | ||
|
||
constructor() {} | ||
|
||
ngOnInit() { | ||
if (this.trial) { | ||
const { status, statusIcon } = this.generateTrialStatus(this.trial); | ||
this.status = status; | ||
this.statusIcon = statusIcon; | ||
} | ||
} | ||
|
||
ngOnChanges(): void { | ||
if (this.trial) { | ||
this.generateTrialPropsList(this.trial); | ||
} | ||
} | ||
|
||
private generateTrialPropsList(trial: TrialK8s): void { | ||
this.performance = this.generateTrialMetrics(this.trial); | ||
|
||
const { status, statusIcon } = this.generateTrialStatus(trial); | ||
this.status = status; | ||
this.statusIcon = statusIcon; | ||
} | ||
|
||
private generateTrialStatus( | ||
trial: TrialK8s, | ||
): { status: string; statusIcon: string } { | ||
const succeededCondition = getCondition(trial, StatusEnum.SUCCEEDED); | ||
|
||
if (succeededCondition && succeededCondition.status === 'True') { | ||
return { status: succeededCondition.message, statusIcon: 'check_circle' }; | ||
} | ||
|
||
const failedCondition = getCondition(trial, StatusEnum.FAILED); | ||
|
||
if (failedCondition && failedCondition.status === 'True') { | ||
return { status: failedCondition.message, statusIcon: 'warning' }; | ||
} | ||
|
||
const runningCondition = getCondition(trial, StatusEnum.RUNNING); | ||
|
||
if (runningCondition && runningCondition.status === 'True') { | ||
return { status: runningCondition.message, statusIcon: 'schedule' }; | ||
} | ||
|
||
const restartingCondition = getCondition(trial, StatusEnum.RESTARTING); | ||
|
||
if (restartingCondition && restartingCondition.status === 'True') { | ||
return { status: restartingCondition.message, statusIcon: 'loop' }; | ||
} | ||
|
||
const createdCondition = getCondition(trial, StatusEnum.CREATED); | ||
|
||
if (createdCondition && createdCondition.status === 'True') { | ||
return { | ||
status: createdCondition.message, | ||
statusIcon: 'add_circle_outline', | ||
}; | ||
} | ||
} | ||
|
||
private generateTrialMetrics(trial: TrialK8s): ChipDescriptor[] { | ||
const metrics = trial.status.observation.metrics.map( | ||
metric => | ||
`${metric.name}: ${ | ||
!isNaN(+metric.latest) | ||
? numberToExponential(+metric.latest, 6) | ||
: metric.latest | ||
}`, | ||
); | ||
|
||
return metrics.map(m => { | ||
return { value: m, color: 'primary', tooltip: 'Latest value' }; | ||
}); | ||
} | ||
} | ||
|
13 changes: 13 additions & 0 deletions
13
...pages/experiment-details/trials-table/trial-modal/overview/trial-modal-overview.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ConditionsTableModule, DetailsListModule } from 'kubeflow'; | ||
|
||
import { TrialModalOverviewComponent } from './trial-modal-overview.component'; | ||
|
||
@NgModule({ | ||
declarations: [TrialModalOverviewComponent], | ||
imports: [CommonModule, ConditionsTableModule, DetailsListModule], | ||
exports: [TrialModalOverviewComponent], | ||
}) | ||
export class TrialModalOverviewModule {} | ||
|
Oops, something went wrong.