fix governance reqs; allow for sandboxed jupyter notebooks for testing
This commit is contained in:
@@ -1,48 +1,47 @@
|
||||
import { DatePipe, DecimalPipe } from '@angular/common';
|
||||
import { DatePipe, DecimalPipe, JsonPipe } from '@angular/common';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MAT_DIALOG_DATA, MatDialog, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { Observable } from 'rxjs';
|
||||
import { apiErrorMessage } from '../../../connect/api/api.types';
|
||||
import { GovernanceApi } from '../../api/governance.api';
|
||||
import { ModelLineage, ModelVersion, PromotionCheck } from '../../api/governance.types';
|
||||
import { ArtifactFile, ModelLineage, ModelVersion, PromotionCheck, RoutineKind } from '../../api/governance.types';
|
||||
import { ModelStatusChip } from '../model-status-chip/model-status-chip';
|
||||
import { NotebookRunDefaults, NotebookRunDialog } from '../notebook-run-dialog/notebook-run-dialog';
|
||||
|
||||
export const ARTIFACT_KINDS: { id: string; label: string }[] = [
|
||||
{ id: 'ONNX_CHECKPOINT', label: 'Checkpoint ONNX' },
|
||||
{ id: 'MUESTREO', label: 'Muestreo' },
|
||||
{ id: 'DATOS_FALTANTES', label: 'Datos faltantes' },
|
||||
{ id: 'METODO_ANALITICO', label: 'Método analítico' },
|
||||
{ id: 'BALANCE_CLASES', label: 'Balance de clases' },
|
||||
{ id: 'CONFIANZA_SALIDA', label: 'Confianza de la salida' },
|
||||
{ id: 'OTRO', label: 'Otro' },
|
||||
/** The routines training records as it runs (ML-01a), in the order they happen. */
|
||||
export const ROUTINES: { kind: RoutineKind; label: string }[] = [
|
||||
{ kind: 'MUESTREO', label: 'Muestreo' },
|
||||
{ kind: 'DATOS_FALTANTES', label: 'Datos faltantes' },
|
||||
{ kind: 'METODO_ANALITICO', label: 'Método analítico' },
|
||||
{ kind: 'BALANCE_CLASES', label: 'Balance de clases' },
|
||||
{ kind: 'CONFIANZA_SALIDA', label: 'Confianza de la salida' },
|
||||
];
|
||||
|
||||
/**
|
||||
* One model version: what it was trained on (the kit's cohort build and its attrition),
|
||||
* its artifacts and their integrity, its validation reports, and the
|
||||
* checklist that must pass before it can serve predictions. Closes with
|
||||
* `true` when the version changed.
|
||||
* what each routine did as it trained, the files its run stored, its validation
|
||||
* reports, and the checklist that must pass before it can serve predictions.
|
||||
* Closes with `true` when the version changed.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-model-version-dialog',
|
||||
imports: [
|
||||
DatePipe,
|
||||
DecimalPipe,
|
||||
JsonPipe,
|
||||
MatButtonModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressBarModule,
|
||||
MatSelectModule,
|
||||
MatTooltipModule,
|
||||
ModelStatusChip,
|
||||
ReactiveFormsModule,
|
||||
@@ -54,8 +53,9 @@ export class ModelVersionDialog {
|
||||
private readonly api = inject(GovernanceApi);
|
||||
private readonly dialogRef = inject<MatDialogRef<ModelVersionDialog, boolean>>(MatDialogRef);
|
||||
private readonly version = inject<ModelVersion>(MAT_DIALOG_DATA);
|
||||
private readonly dialog = inject(MatDialog);
|
||||
|
||||
readonly artifactKinds = ARTIFACT_KINDS;
|
||||
readonly routineKinds = ROUTINES;
|
||||
readonly lineage = signal<ModelLineage | null>(null);
|
||||
readonly busy = signal(false);
|
||||
readonly error = signal<string | null>(null);
|
||||
@@ -66,7 +66,6 @@ export class ModelVersionDialog {
|
||||
clinical_validation_report_uri: [''],
|
||||
interpretability_report_uri: [''],
|
||||
});
|
||||
readonly artifactKind = signal('ONNX_CHECKPOINT');
|
||||
|
||||
constructor() {
|
||||
this.load();
|
||||
@@ -93,12 +92,25 @@ export class ModelVersionDialog {
|
||||
return Object.entries(version.metrics ?? {});
|
||||
}
|
||||
|
||||
artifactName(path: string): string {
|
||||
return path.split('/').pop() ?? path;
|
||||
/** The run's files, with the saved model as one folder (it downloads as a zip). */
|
||||
files(artifacts: ArtifactFile[]): { path: string; label: string; size: number | null }[] {
|
||||
const model = artifacts.filter((file) => file.path.startsWith('model/'));
|
||||
const rest = artifacts.filter((file) => !file.path.startsWith('model/'));
|
||||
const folder = model.length ? [{ path: 'model', label: 'model (modelo guardado, .zip)', size: null }] : [];
|
||||
return [...folder, ...rest.map((file) => ({ ...file, label: file.path }))];
|
||||
}
|
||||
|
||||
artifactKindOf(path: string): string {
|
||||
return path.split('/')[0] ?? path;
|
||||
artifactUrl(path: string): string {
|
||||
return this.api.artifactUrl(this.domain, this.scenario, this.version.version, path);
|
||||
}
|
||||
|
||||
tryInNotebook(): void {
|
||||
this.dialog.open<NotebookRunDialog, NotebookRunDefaults>(NotebookRunDialog, {
|
||||
data: { domain: this.domain as NotebookRunDefaults['domain'], scenario: this.scenario, version: this.version.version },
|
||||
width: '640px',
|
||||
maxWidth: '96vw',
|
||||
autoFocus: false,
|
||||
});
|
||||
}
|
||||
|
||||
saveReports(): void {
|
||||
@@ -110,13 +122,6 @@ export class ModelVersionDialog {
|
||||
}));
|
||||
}
|
||||
|
||||
uploadArtifact(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const file = input.files?.[0];
|
||||
input.value = '';
|
||||
if (file) this.run(this.api.uploadArtifact(this.domain, this.scenario, this.version.version, this.artifactKind(), file));
|
||||
}
|
||||
|
||||
promote(): void {
|
||||
this.run(this.api.promoteModelVersion(this.domain, this.scenario, this.version.version));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user