integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
<h2 mat-dialog-title class="title">
|
||||
{{ title }}
|
||||
@if (lineage(); as l) {
|
||||
<app-model-status [status]="l.model_version.status"></app-model-status>
|
||||
}
|
||||
</h2>
|
||||
|
||||
<mat-dialog-content class="content">
|
||||
@if (busy()) {
|
||||
<mat-progress-bar mode="indeterminate" aria-label="Cargando"></mat-progress-bar>
|
||||
}
|
||||
@if (error(); as message) {
|
||||
<p class="alert" role="alert"><mat-icon aria-hidden="true">error</mat-icon>{{ message }}</p>
|
||||
}
|
||||
|
||||
@if (lineage(); as l) {
|
||||
@let v = l.model_version;
|
||||
<section class="summary">
|
||||
<dl>
|
||||
<dt>Dominio · escenario</dt>
|
||||
<dd>{{ v.tags.domain }} · {{ v.tags.scenario }}</dd>
|
||||
<dt>Entorno</dt>
|
||||
<dd>{{ v.tags.environment }}</dd>
|
||||
<dt>Creada</dt>
|
||||
<dd>{{ v.created_at | date: 'medium' }}</dd>
|
||||
@if (v.tags.promovida_en) {
|
||||
<dt>Promovida</dt>
|
||||
<dd>{{ v.tags.promovida_en | date: 'medium' }}</dd>
|
||||
}
|
||||
<dt>Predicciones registradas</dt>
|
||||
<dd>{{ l.predictions | number }}</dd>
|
||||
</dl>
|
||||
@if (metrics(v).length) {
|
||||
<dl class="metrics">
|
||||
@for (metric of metrics(v); track metric[0]) {
|
||||
<dt>{{ metric[0] }}</dt>
|
||||
<dd>{{ metric[1] }}</dd>
|
||||
}
|
||||
</dl>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="checks-title">
|
||||
<h3 id="checks-title">Requisitos para producción</h3>
|
||||
<ul class="checks">
|
||||
@for (check of l.checks; track $index) {
|
||||
<li [class.checks__fail]="!check.passed">
|
||||
<mat-icon aria-hidden="true">{{ check.passed ? 'check_circle' : 'cancel' }}</mat-icon>
|
||||
<span class="checks__code">{{ check.code }}</span>
|
||||
<span>{{ check.requirement }}</span>
|
||||
@if (check.detail) {
|
||||
<span class="checks__detail">{{ check.detail }}</span>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="cohort-title">
|
||||
<h3 id="cohort-title">Cohorte de entrenamiento</h3>
|
||||
@if (l.cohort_version; as cohort) {
|
||||
<p>
|
||||
{{ cohort.domain }} · {{ cohort.scenario }} · criterio {{ cohort.criteria_version }} ·
|
||||
{{ cohort.n_included | number }} de {{ cohort.n_source | number }} episodios
|
||||
</p>
|
||||
<p class="hash" [matTooltip]="cohort.version_hash">hash {{ cohort.version_hash.slice(0, 16) }}…</p>
|
||||
@if (l.cohort_exclusions.length) {
|
||||
<ul class="exclusions">
|
||||
@for (count of l.cohort_exclusions; track count.cohort_exclusion_count_id) {
|
||||
<li>{{ count.criterion_code }} ({{ count.reason_code }}): {{ count.count | number }} excluidos</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
} @else {
|
||||
<p class="muted">Sin cohorte enlazada.</p>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="artifacts-title">
|
||||
<h3 id="artifacts-title">Artefactos</h3>
|
||||
<p class="muted">Guardados en la corrida de MLflow; ábrelos desde el servidor de MLflow.</p>
|
||||
<ul class="artifacts">
|
||||
@for (artifact of l.artifacts; track artifact) {
|
||||
<li>
|
||||
<mat-icon aria-hidden="true">description</mat-icon>
|
||||
<span class="artifacts__kind">{{ artifactKindOf(artifact) }}</span>
|
||||
<span class="artifacts__name">{{ artifactName(artifact) }}</span>
|
||||
</li>
|
||||
} @empty {
|
||||
<li class="muted">Sin artefactos.</li>
|
||||
}
|
||||
</ul>
|
||||
<div class="upload">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-label>Tipo</mat-label>
|
||||
<mat-select [value]="artifactKind()" (valueChange)="artifactKind.set($event)">
|
||||
@for (kind of artifactKinds; track kind.id) {
|
||||
<mat-option [value]="kind.id">{{ kind.label }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<button mat-stroked-button type="button" [disabled]="busy()" (click)="fileInput.click()">
|
||||
<mat-icon aria-hidden="true">upload_file</mat-icon>Subir artefacto
|
||||
</button>
|
||||
<input #fileInput type="file" hidden (change)="uploadArtifact($event)" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section aria-labelledby="reports-title">
|
||||
<h3 id="reports-title">Reportes de validación</h3>
|
||||
<form [formGroup]="reports" class="reports" (ngSubmit)="saveReports()">
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Pruebas técnicas (MLD-01)</mat-label>
|
||||
<input matInput formControlName="technical_validation_report_uri" placeholder="Ruta o URL del reporte" />
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Validación clínica (MLD-01b)</mat-label>
|
||||
<input matInput formControlName="clinical_validation_report_uri" placeholder="Ruta o URL del reporte" />
|
||||
</mat-form-field>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>Interpretabilidad (MLD-03)</mat-label>
|
||||
<input matInput formControlName="interpretability_report_uri" placeholder="Ruta o URL del reporte" />
|
||||
</mat-form-field>
|
||||
<button mat-stroked-button type="submit" [disabled]="busy() || reports.pristine">Guardar reportes</button>
|
||||
</form>
|
||||
</section>
|
||||
}
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button type="button" (click)="close()">Cerrar</button>
|
||||
@if (lineage(); as l) {
|
||||
@if (l.model_version.status === 'produccion') {
|
||||
<button mat-stroked-button type="button" [disabled]="busy()" (click)="retire()">
|
||||
<mat-icon aria-hidden="true">pause_circle</mat-icon>Retirar de producción
|
||||
</button>
|
||||
} @else {
|
||||
<button
|
||||
mat-flat-button
|
||||
type="button"
|
||||
[disabled]="busy() || !ready(l.checks)"
|
||||
[matTooltip]="ready(l.checks) ? '' : 'Faltan requisitos para producción'"
|
||||
(click)="promote()"
|
||||
>
|
||||
<mat-icon aria-hidden="true">rocket_launch</mat-icon>Promover a producción
|
||||
</button>
|
||||
}
|
||||
}
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,113 @@
|
||||
.title {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-4);
|
||||
|
||||
h3 {
|
||||
font: var(--mat-sys-title-small);
|
||||
margin: 0 0 var(--space-2);
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 var(--space-1);
|
||||
}
|
||||
}
|
||||
|
||||
.alert {
|
||||
align-items: center;
|
||||
color: var(--mat-sys-error);
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-6, 24px);
|
||||
|
||||
dl {
|
||||
display: grid;
|
||||
gap: var(--space-1) var(--space-3);
|
||||
grid-template-columns: auto auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font: var(--mat-sys-label-medium);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.checks,
|
||||
.artifacts,
|
||||
.exclusions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-1);
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
li {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
}
|
||||
|
||||
.checks mat-icon {
|
||||
color: var(--mat-sys-primary);
|
||||
}
|
||||
|
||||
.checks__fail mat-icon {
|
||||
color: var(--mat-sys-error);
|
||||
}
|
||||
|
||||
.checks__code,
|
||||
.artifacts__kind {
|
||||
font: var(--mat-sys-label-medium);
|
||||
min-width: 64px;
|
||||
}
|
||||
|
||||
.checks__detail,
|
||||
.hash,
|
||||
.muted {
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
font: var(--mat-sys-body-small);
|
||||
}
|
||||
|
||||
.hash {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.artifacts__name {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.upload {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--space-3);
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
|
||||
.reports {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
button {
|
||||
justify-self: start;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
import { DatePipe, DecimalPipe } 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 { 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 { ModelStatusChip } from '../model-status-chip/model-status-chip';
|
||||
|
||||
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' },
|
||||
];
|
||||
|
||||
/**
|
||||
* One model version: what it was trained on (cohort hash and exclusions),
|
||||
* 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.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-model-version-dialog',
|
||||
imports: [
|
||||
DatePipe,
|
||||
DecimalPipe,
|
||||
MatButtonModule,
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressBarModule,
|
||||
MatSelectModule,
|
||||
MatTooltipModule,
|
||||
ModelStatusChip,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './model-version-dialog.html',
|
||||
styleUrl: './model-version-dialog.scss',
|
||||
})
|
||||
export class ModelVersionDialog {
|
||||
private readonly api = inject(GovernanceApi);
|
||||
private readonly dialogRef = inject<MatDialogRef<ModelVersionDialog, boolean>>(MatDialogRef);
|
||||
private readonly version = inject<ModelVersion>(MAT_DIALOG_DATA);
|
||||
|
||||
readonly artifactKinds = ARTIFACT_KINDS;
|
||||
readonly lineage = signal<ModelLineage | null>(null);
|
||||
readonly busy = signal(false);
|
||||
readonly error = signal<string | null>(null);
|
||||
private changed = false;
|
||||
|
||||
readonly reports = inject(FormBuilder).nonNullable.group({
|
||||
technical_validation_report_uri: [''],
|
||||
clinical_validation_report_uri: [''],
|
||||
interpretability_report_uri: [''],
|
||||
});
|
||||
readonly artifactKind = signal('ONNX_CHECKPOINT');
|
||||
|
||||
constructor() {
|
||||
this.load();
|
||||
}
|
||||
|
||||
private get domain(): string {
|
||||
return this.version.tags.domain!;
|
||||
}
|
||||
|
||||
private get scenario(): string {
|
||||
return this.version.tags.scenario!;
|
||||
}
|
||||
|
||||
get title(): string {
|
||||
const v = this.lineage()?.model_version ?? this.version;
|
||||
return `${v.name}:${v.version}`;
|
||||
}
|
||||
|
||||
ready(checks: PromotionCheck[]): boolean {
|
||||
return checks.every((check) => check.passed);
|
||||
}
|
||||
|
||||
metrics(version: ModelVersion): [string, unknown][] {
|
||||
return Object.entries(version.metrics ?? {});
|
||||
}
|
||||
|
||||
artifactName(path: string): string {
|
||||
return path.split('/').pop() ?? path;
|
||||
}
|
||||
|
||||
artifactKindOf(path: string): string {
|
||||
return path.split('/')[0] ?? path;
|
||||
}
|
||||
|
||||
saveReports(): void {
|
||||
const values = this.reports.getRawValue();
|
||||
this.run(this.api.attachReports(this.domain, this.scenario, this.version.version, {
|
||||
technical_validation_report_uri: values.technical_validation_report_uri.trim() || null,
|
||||
clinical_validation_report_uri: values.clinical_validation_report_uri.trim() || null,
|
||||
interpretability_report_uri: values.interpretability_report_uri.trim() || null,
|
||||
}));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
retire(): void {
|
||||
this.run(this.api.retireModelVersion(this.domain, this.scenario, this.version.version));
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.dialogRef.close(this.changed);
|
||||
}
|
||||
|
||||
private run(request: Observable<unknown>): void {
|
||||
this.busy.set(true);
|
||||
this.error.set(null);
|
||||
request.subscribe({
|
||||
next: () => {
|
||||
this.changed = true;
|
||||
this.load();
|
||||
},
|
||||
error: (error) => {
|
||||
this.busy.set(false);
|
||||
this.error.set(apiErrorMessage(error, 'La operación no se pudo completar.'));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private load(): void {
|
||||
this.busy.set(true);
|
||||
this.api.lineage(this.domain, this.scenario, this.version.version).subscribe({
|
||||
next: (lineage) => {
|
||||
this.lineage.set(lineage);
|
||||
const tags = lineage.model_version.tags;
|
||||
this.reports.setValue({
|
||||
technical_validation_report_uri: tags.technical_validation_report_uri ?? '',
|
||||
clinical_validation_report_uri: tags.clinical_validation_report_uri ?? '',
|
||||
interpretability_report_uri: tags.interpretability_report_uri ?? '',
|
||||
});
|
||||
this.reports.markAsPristine();
|
||||
this.busy.set(false);
|
||||
},
|
||||
error: (error) => {
|
||||
this.busy.set(false);
|
||||
this.error.set(apiErrorMessage(error, 'No se pudo cargar la versión.'));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user