| Versión |
Creada |
- Entrenamiento / prueba |
+ Datos |
Informes |
Validación clínica |
|
@@ -59,32 +88,37 @@
}
{{ v.created | date: 'yyyy-MM-dd HH:mm' }} |
-
- {{ v.metrics['n_train'] | number }} / {{ v.metrics['n_test'] | number }}
- |
+ {{ sizes(v) }} |
- @for (r of v.reports; track r) {
- {{
- reportNames[r] ?? r
- }}
- }
- @if (v.reports.includes('interpretability')) {
-
- }
+
|
@if (!v.reports.includes('clinical_validation')) {
+
} @else {
Agregada
}
@@ -105,7 +139,7 @@
@if (chosen(); as c) {
- Interpretabilidad · {{ c.name }} v{{ c.version }}
+ Interpretabilidad · {{ titleOf(c.name) }} v{{ c.version }}
@for (f of figures(); track f.title) {
{{ f.title }}
diff --git a/src/app/gobernanza/gobernanza.scss b/src/app/gobernanza/gobernanza.scss
index e974ad7..16c0d92 100644
--- a/src/app/gobernanza/gobernanza.scss
+++ b/src/app/gobernanza/gobernanza.scss
@@ -1,18 +1,8 @@
:host {
display: block;
}
-h1 {
- text-align: center;
-}
-.domains {
- display: flex;
- justify-content: center;
- gap: var(--space-4);
- margin-bottom: var(--space-4);
-}
-.domains a.active {
- font-weight: 600;
- text-decoration: underline;
+.subtitle {
+ margin: 4px 0 var(--space-4);
}
.actions {
display: flex;
@@ -30,6 +20,7 @@ h1 {
white-space: nowrap;
}
.badge {
+ white-space: nowrap;
margin-left: var(--space-2);
padding: 2px 8px;
border-radius: 999px;
@@ -45,3 +36,32 @@ td a {
padding: 48px 0;
text-align: center;
}
+
+.reports {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ column-gap: var(--space-3);
+ row-gap: 2px;
+}
+.reports a {
+ margin-right: 0;
+}
+h2 .code {
+ font-size: 12px;
+ font-weight: 400;
+ margin-left: var(--space-2);
+}
+.confirm {
+ display: inline-flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--space-2);
+ padding: 4px 4px 4px 12px;
+ border-radius: 8px;
+ background: var(--color-surface-warning, #fdf3dc);
+}
+
+td button {
+ white-space: nowrap;
+}
diff --git a/src/app/gobernanza/gobernanza.ts b/src/app/gobernanza/gobernanza.ts
index 12d6bc1..d6d831c 100644
--- a/src/app/gobernanza/gobernanza.ts
+++ b/src/app/gobernanza/gobernanza.ts
@@ -6,7 +6,6 @@ import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
-import { RouterLink } from '@angular/router';
import { Api } from '../api/api';
import { ApiConfiguration } from '../api/api-configuration';
import { addClinicalValidation } from '../api/fn/models/add-clinical-validation';
@@ -17,9 +16,9 @@ import { readReport$Json } from '../api/fn/models/read-report-json';
import { score } from '../api/fn/models/score';
import { train } from '../api/fn/models/train';
import { versions } from '../api/fn/models/versions';
-import { domains } from '../api/fn/operations/domains';
import { studies } from '../api/fn/eeg/studies';
import { study } from '../api/fn/eeg/study';
+import { terminateRun } from '../api/fn/runs/terminate-run';
import { runStatus } from '../api/fn/runs/run-status';
import type { Domain } from '../api/models/domain';
import type { Version } from '../api/models/version';
@@ -47,7 +46,6 @@ const REPORTS: Record = {
MatButtonModule,
MatFormFieldModule,
MatInputModule,
- RouterLink,
Plot,
],
templateUrl: './gobernanza.html',
@@ -60,15 +58,15 @@ export class Gobernanza {
protected readonly labels = DOMAINS as Record;
protected readonly reportNames = REPORTS;
- protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
private readonly refreshed = signal(0);
protected readonly models = resource({
params: () => ({ domain: this.domain() as Domain, at: this.refreshed() }),
loader: async ({ params: { domain } }) => {
- const names = await this.api.invoke(models, { domain });
+ const found = await this.api.invoke(models, { domain });
return Promise.all(
- names.map(async (name) => ({
+ found.map(async ({ name, title }) => ({
name,
+ title,
versions: await this.api.invoke(versions, { domain, name }),
})),
);
@@ -96,7 +94,41 @@ export class Gobernanza {
});
protected readonly metricNames = METRIC_NAMES;
protected readonly asOf = signal('');
- protected readonly run = signal<{ kind: string; status: string } | undefined>(undefined);
+ protected readonly run = signal<{ id: string; kind: string; status: string } | undefined>(
+ undefined,
+ );
+ /** The run "Entrenar" or "Calcular riesgos" will start once confirmed. */
+ protected readonly confirming = signal<'train' | 'score' | undefined>(undefined);
+ protected readonly running = computed(() => {
+ const r = this.run();
+ return !!r && !['SUCCESS', 'FAILURE', 'CANCELED'].includes(r.status);
+ });
+ protected readonly STATUS: Record = {
+ QUEUED: 'en cola',
+ NOT_STARTED: 'por iniciar',
+ STARTING: 'iniciando',
+ STARTED: 'en curso',
+ SUCCESS: 'terminado',
+ FAILURE: 'con error',
+ CANCELING: 'deteniéndose',
+ CANCELED: 'detenido',
+ };
+ /** A model's title by its name, for messages. */
+ protected titleOf(name: string): string {
+ return this.models.value()?.find((m) => m.name === name)?.title ?? name;
+ }
+ /** What a version learned from, as its metrics say it (each kind of model its own). */
+ protected sizes(v: Version): string {
+ const m = v.metrics;
+ const n = (x: number) => x.toLocaleString('es-MX');
+ if (m['n_train'] !== undefined)
+ return `${n(m['n_train'])} entrenamiento / ${n(m['n_test'] ?? 0)} prueba`;
+ if (m['n_reference'] !== undefined) return `${n(m['n_reference'])} EEG de referencia`;
+ if (m['children'] !== undefined) return `${n(m['children'])} niños`;
+ const c = Object.entries(m).find(([k]) => k.endsWith('c_index_cox'));
+ if (c) return `C-index ${c[1].toFixed(3)}`;
+ return '—';
+ }
protected readonly message = signal('');
protected champion(v: Version): boolean {
@@ -117,14 +149,14 @@ export class Gobernanza {
// OpenAPI's binary is typed as a string; the request builder sends the File as is.
body: { file: file as unknown as string },
});
- this.message.set(`Validación clínica agregada a ${name} v${version}.`);
+ this.message.set(`Validación clínica agregada a ${this.titleOf(name)} v${version}.`);
this.refreshed.update((n) => n + 1);
}
protected async promote(name: string, version: number): Promise {
try {
await this.api.invoke(promote, { domain: this.domain() as Domain, name, version });
- this.message.set(`${name} v${version} es ahora la versión en producción.`);
+ this.message.set(`${this.titleOf(name)} v${version} es ahora la versión en producción.`);
this.refreshed.update((n) => n + 1);
} catch (e) {
const detail = e instanceof HttpErrorResponse ? e.error?.detail : undefined;
@@ -140,14 +172,22 @@ export class Gobernanza {
private async follow(run_id: string, label: string): Promise {
for (;;) {
const status = (await this.api.invoke(runStatus, { run_id }))['status'] as string;
- this.run.set({ kind: label, status });
+ this.run.set({ id: run_id, kind: label, status });
if (['SUCCESS', 'FAILURE', 'CANCELED'].includes(status)) break;
await new Promise((r) => setTimeout(r, 2000));
}
this.refreshed.update((n) => n + 1);
}
+ protected async stop(): Promise {
+ const r = this.run();
+ if (!r) return;
+ const found = await this.api.invoke(terminateRun, { run_id: r.id });
+ this.run.set({ ...r, status: found['status'] });
+ }
+
protected async start(kind: 'train' | 'score'): Promise {
+ this.confirming.set(undefined);
const domain = this.domain() as Domain;
const { run_id } =
kind === 'train'
|