wording fixes
This commit is contained in:
@@ -100,8 +100,8 @@
|
||||
type="button"
|
||||
class="saved-connection__forget"
|
||||
(click)="forgetSaved(saved, $event)"
|
||||
aria-label="Olvidar esta conexión guardada"
|
||||
matTooltip="Olvidar"
|
||||
aria-label="Eliminar esta conexión guardada"
|
||||
matTooltip="Eliminar"
|
||||
>
|
||||
<mat-icon aria-hidden="true">close</mat-icon>
|
||||
</button>
|
||||
@@ -134,7 +134,7 @@
|
||||
</mat-form-field>
|
||||
</form>
|
||||
<mat-checkbox [checked]="remember()" (change)="remember.set($event.checked)">
|
||||
Recordar servidor, usuario y base de datos (nunca la contraseña)
|
||||
Guardar servidor, usuario y base de datos para conexiones futuras (la contraseña no se guarda)
|
||||
</mat-checkbox>
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,13 @@ export class GovernanceApi {
|
||||
return this.http.post<ModelVersion>(`/governance/model-versions/${domain}/${scenario}/${version}/promote`, {});
|
||||
}
|
||||
|
||||
/** Exports the scenario's latest dbt cohort build, trains a PROD version and tries to promote it, the same
|
||||
* one-shot pipeline the `entrenar` compose profile runs. 409 when it trained but needs its reports attached
|
||||
* before it can be promoted; 503 with no dbt manifest configured or an operational failure. */
|
||||
trainModelVersion(domain: string, scenario: string): Observable<{ output: string }> {
|
||||
return this.http.post<{ output: string }>(`/governance/model-versions/${domain}/${scenario}/train`, {});
|
||||
}
|
||||
|
||||
retireModelVersion(domain: string, scenario: string, version: string): Observable<ModelVersion> {
|
||||
return this.http.post<ModelVersion>(`/governance/model-versions/${domain}/${scenario}/${version}/retire`, {});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PendingRiskBatch } from './risk-batches.types';
|
||||
|
||||
/** `/<domain>/riesgos/lotes`: risk batches a model produced and nobody has reviewed yet (ADR-MD-008). Only `cacu`
|
||||
* is served today. */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class RiskBatchesApi {
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
listPending(domain: string): Observable<PendingRiskBatch[]> {
|
||||
return this.http.get<PendingRiskBatch[]>(`/${domain}/riesgos/lotes`);
|
||||
}
|
||||
|
||||
/** Moves every current evaluation of the batch to `final`: it becomes the one patient records read. */
|
||||
confirm(domain: string, loteId: number, reason: string): Observable<{ lote_id: number; evaluaciones_cambiadas: number }> {
|
||||
return this.http.post<{ lote_id: number; evaluaciones_cambiadas: number }>(
|
||||
`/${domain}/riesgos/lotes/${loteId}/confirmar`, { reason },
|
||||
);
|
||||
}
|
||||
|
||||
/** Moves every current evaluation of the batch to `entered-in-error` instead. */
|
||||
void(domain: string, loteId: number, reason: string): Observable<{ lote_id: number; evaluaciones_cambiadas: number }> {
|
||||
return this.http.post<{ lote_id: number; evaluaciones_cambiadas: number }>(
|
||||
`/${domain}/riesgos/lotes/${loteId}/anular`, { reason },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/** A risk batch waiting for someone to confirm or void it (ADR-MD-008); invisible to patient records until
|
||||
* confirmed. */
|
||||
export interface PendingRiskBatch {
|
||||
lote_id: number;
|
||||
modelo_nombre: string;
|
||||
modelo_version: string;
|
||||
evaluado_en: string;
|
||||
n_evaluaciones: number;
|
||||
}
|
||||
@@ -22,5 +22,10 @@
|
||||
<app-ocr-review-panel></app-ocr-review-panel>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab label="Lotes de riesgo">
|
||||
<div class="governance__panel">
|
||||
<app-risk-batches-panel></app-risk-batches-panel>
|
||||
</div>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
|
||||
@@ -4,15 +4,16 @@ import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { ExperimentsPanel } from '../experiments-panel/experiments-panel';
|
||||
import { ModelVersionsPanel } from '../model-versions-panel/model-versions-panel';
|
||||
import { OcrReviewPanel } from '../ocr-review-panel/ocr-review-panel';
|
||||
import { RiskBatchesPanel } from '../risk-batches-panel/risk-batches-panel';
|
||||
|
||||
/**
|
||||
* The "Gobernanza de modelos" page (route `/gobernanza`): model versions,
|
||||
* notebooks run on cohort builds and the OCR review queue, one tab each. Every tab is a
|
||||
* notebooks run on cohort builds, the OCR review queue and pending risk batches, one tab each. Every tab is a
|
||||
* self-contained panel that loads its own data.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-governance-page',
|
||||
imports: [ExperimentsPanel, MatTabsModule, MatToolbarModule, ModelVersionsPanel, OcrReviewPanel],
|
||||
imports: [ExperimentsPanel, MatTabsModule, MatToolbarModule, ModelVersionsPanel, OcrReviewPanel, RiskBatchesPanel],
|
||||
templateUrl: './governance-page.html',
|
||||
styleUrl: './governance-page.scss',
|
||||
})
|
||||
|
||||
@@ -6,12 +6,16 @@
|
||||
}
|
||||
</mat-button-toggle-group>
|
||||
<span class="models__spacer"></span>
|
||||
<button mat-stroked-button type="button" [disabled]="training()" (click)="train()"
|
||||
matTooltip="Entrena el modelo cacu/cin2_logistic con la cohorte de vigilancia vigente y lo pone en producción">
|
||||
<mat-icon aria-hidden="true">model_training</mat-icon>Entrenar cacu/cin2_logistic
|
||||
</button>
|
||||
<button mat-icon-button type="button" (click)="reload()" aria-label="Recargar" matTooltip="Recargar">
|
||||
<mat-icon aria-hidden="true">refresh</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (loading()) {
|
||||
@if (loading() || training()) {
|
||||
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
@if (loadError(); as error) {
|
||||
|
||||
@@ -17,10 +17,14 @@ import { ModelVersion } from '../../api/governance.types';
|
||||
import { ModelStatusChip } from '../model-status-chip/model-status-chip';
|
||||
import { ModelVersionDialog } from '../model-version-dialog/model-version-dialog';
|
||||
|
||||
/** The only scenario with a trainer today (ML-cin2_logistic, CaCu): `entrenar`'s own domain and scenario. */
|
||||
const TRAINABLE = { domain: 'cacu', scenario: 'cin2_logistic' };
|
||||
|
||||
/**
|
||||
* Every registered model version with its status (desarrollo, candidata,
|
||||
* en producción, retirada). The detail dialog holds the promotion
|
||||
* checklist, lineage, artifacts and reports.
|
||||
* checklist, lineage, artifacts and reports. The toolbar also offers
|
||||
* training the one scenario with a trainer, over HTTP instead of a shell.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-model-versions-panel',
|
||||
@@ -50,6 +54,7 @@ export class ModelVersionsPanel implements OnInit {
|
||||
readonly versions = signal<ModelVersion[]>([]);
|
||||
readonly loading = signal(false);
|
||||
readonly loadError = signal<string | null>(null);
|
||||
readonly training = signal(false);
|
||||
|
||||
readonly displayedColumns = ['version', 'scenario', 'environment', 'armado', 'status', 'created_at', 'acciones'];
|
||||
|
||||
@@ -94,4 +99,23 @@ export class ModelVersionsPanel implements OnInit {
|
||||
metrics(version: ModelVersion): { key: string; value: unknown }[] {
|
||||
return Object.entries(version.metrics ?? {}).map(([key, value]) => ({ key, value }));
|
||||
}
|
||||
|
||||
train(): void {
|
||||
this.training.set(true);
|
||||
this.api
|
||||
.trainModelVersion(TRAINABLE.domain, TRAINABLE.scenario)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: () => {
|
||||
this.training.set(false);
|
||||
this.snackBar.open(`El modelo ${TRAINABLE.domain}/${TRAINABLE.scenario} se entrenó correctamente.`, 'OK', { duration: 3000 });
|
||||
this.reload();
|
||||
},
|
||||
error: (error) => {
|
||||
this.training.set(false);
|
||||
this.snackBar.open(apiErrorMessage(error, 'No se pudo entrenar el modelo.'), 'OK', { duration: 5000 });
|
||||
if (error?.status === 409) this.reload();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<div class="batches">
|
||||
<div class="batches__toolbar">
|
||||
<span class="batches__spacer"></span>
|
||||
<button mat-icon-button type="button" (click)="reload()" aria-label="Recargar" matTooltip="Recargar">
|
||||
<mat-icon aria-hidden="true">refresh</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (loading()) {
|
||||
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
||||
}
|
||||
@if (loadError(); as error) {
|
||||
<p class="batches__alert" role="alert"><mat-icon aria-hidden="true">error</mat-icon>{{ error }}</p>
|
||||
}
|
||||
|
||||
<table mat-table [dataSource]="batches()" class="batches__table">
|
||||
<ng-container matColumnDef="modelo">
|
||||
<th mat-header-cell *matHeaderCellDef>Modelo</th>
|
||||
<td mat-cell *matCellDef="let b">{{ b.modelo_nombre }}:{{ b.modelo_version }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="evaluado_en">
|
||||
<th mat-header-cell *matHeaderCellDef>Calculado</th>
|
||||
<td mat-cell *matCellDef="let b">{{ b.evaluado_en | date: 'short' }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="n_evaluaciones">
|
||||
<th mat-header-cell *matHeaderCellDef>Pacientes</th>
|
||||
<td mat-cell *matCellDef="let b">{{ b.n_evaluaciones }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="motivo">
|
||||
<th mat-header-cell *matHeaderCellDef>Motivo</th>
|
||||
<td mat-cell *matCellDef="let b">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="batches__reason">
|
||||
<input matInput [formControl]="reasonFor(b)" placeholder="Motivo de la confirmación o anulación" />
|
||||
</mat-form-field>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="acciones">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let b">
|
||||
<button mat-button type="button" color="primary" [disabled]="!reasonFor(b).value.trim() || deciding() === b.lote_id"
|
||||
(click)="confirm(b)">
|
||||
<mat-icon aria-hidden="true">check_circle</mat-icon>Confirmar
|
||||
</button>
|
||||
<button mat-button type="button" color="warn" [disabled]="!reasonFor(b).value.trim() || deciding() === b.lote_id"
|
||||
(click)="void(b)">
|
||||
<mat-icon aria-hidden="true">block</mat-icon>Anular
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
|
||||
</table>
|
||||
|
||||
@if (!loading() && batches().length === 0) {
|
||||
<p class="batches__empty"><mat-icon aria-hidden="true">task_alt</mat-icon>No hay lotes de riesgo pendientes de revisión.</p>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
.batches {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.batches__toolbar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.batches__spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.batches__alert {
|
||||
align-items: center;
|
||||
background: var(--mat-sys-error-container);
|
||||
color: var(--mat-sys-on-error-container);
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
margin: 0;
|
||||
padding: var(--space-2) var(--space-3);
|
||||
}
|
||||
|
||||
.batches__table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.batches__reason {
|
||||
min-width: 220px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.batches__empty {
|
||||
align-items: center;
|
||||
color: var(--mat-sys-on-surface-variant);
|
||||
display: flex;
|
||||
font: var(--mat-sys-body-small);
|
||||
gap: var(--space-2);
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Component, DestroyRef, OnInit, inject, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
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 { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { apiErrorMessage } from '../../../connect/api/api.types';
|
||||
import { RiskBatchesApi } from '../../api/risk-batches.api';
|
||||
import { PendingRiskBatch } from '../../api/risk-batches.types';
|
||||
|
||||
const DOMAIN = 'cacu';
|
||||
|
||||
/**
|
||||
* Risk batches a model produced that nobody has confirmed or voided yet (ADR-MD-008): invisible to patient
|
||||
* records until someone decides, with a reason. Only CaCu has a model estimating risks today.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'app-risk-batches-panel',
|
||||
imports: [
|
||||
DatePipe,
|
||||
MatButtonModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatProgressBarModule,
|
||||
MatSnackBarModule,
|
||||
MatTableModule,
|
||||
MatTooltipModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './risk-batches-panel.html',
|
||||
styleUrl: './risk-batches-panel.scss',
|
||||
})
|
||||
export class RiskBatchesPanel implements OnInit {
|
||||
private readonly api = inject(RiskBatchesApi);
|
||||
private readonly snackBar = inject(MatSnackBar);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
|
||||
readonly batches = signal<PendingRiskBatch[]>([]);
|
||||
readonly loading = signal(false);
|
||||
readonly loadError = signal<string | null>(null);
|
||||
readonly deciding = signal<number | null>(null);
|
||||
|
||||
readonly displayedColumns = ['modelo', 'evaluado_en', 'n_evaluaciones', 'motivo', 'acciones'];
|
||||
private readonly reasons = new Map<number, FormControl<string>>();
|
||||
|
||||
ngOnInit(): void {
|
||||
this.reload();
|
||||
}
|
||||
|
||||
reload(): void {
|
||||
this.loading.set(true);
|
||||
this.loadError.set(null);
|
||||
this.api
|
||||
.listPending(DOMAIN)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (batches) => {
|
||||
this.loading.set(false);
|
||||
this.batches.set(batches);
|
||||
},
|
||||
error: (error) => {
|
||||
this.loading.set(false);
|
||||
this.loadError.set(apiErrorMessage(error, 'No se pudieron cargar los lotes de riesgo.'));
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
reasonFor(batch: PendingRiskBatch): FormControl<string> {
|
||||
let control = this.reasons.get(batch.lote_id);
|
||||
if (!control) {
|
||||
control = new FormControl('', { nonNullable: true });
|
||||
this.reasons.set(batch.lote_id, control);
|
||||
}
|
||||
return control;
|
||||
}
|
||||
|
||||
confirm(batch: PendingRiskBatch): void {
|
||||
this.decide(batch, (reason) => this.api.confirm(DOMAIN, batch.lote_id, reason), 'confirmado');
|
||||
}
|
||||
|
||||
void(batch: PendingRiskBatch): void {
|
||||
this.decide(batch, (reason) => this.api.void(DOMAIN, batch.lote_id, reason), 'anulado');
|
||||
}
|
||||
|
||||
private decide(
|
||||
batch: PendingRiskBatch,
|
||||
request: (reason: string) => ReturnType<RiskBatchesApi['confirm']>,
|
||||
verb: string,
|
||||
): void {
|
||||
const reason = this.reasonFor(batch).value.trim();
|
||||
if (!reason) return;
|
||||
this.deciding.set(batch.lote_id);
|
||||
request(reason).subscribe({
|
||||
next: () => {
|
||||
this.deciding.set(null);
|
||||
this.reasons.delete(batch.lote_id);
|
||||
this.snackBar.open(`El lote ${batch.lote_id} quedó ${verb}.`, 'OK', { duration: 3000 });
|
||||
this.reload();
|
||||
},
|
||||
error: (error) => {
|
||||
this.deciding.set(null);
|
||||
this.snackBar.open(apiErrorMessage(error, 'La operación no se pudo completar.'), 'OK', { duration: 5000 });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user