Merge parity/F1a
This commit is contained in:
+30
-1
@@ -132,10 +132,16 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF',
|
|||||||
'Ejecución',
|
'Ejecución',
|
||||||
'Modelos',
|
'Modelos',
|
||||||
'Entrenamiento',
|
'Entrenamiento',
|
||||||
|
'Subir archivos',
|
||||||
'Bundles',
|
'Bundles',
|
||||||
'Estudios EEG',
|
'Estudios EEG',
|
||||||
'Vista previa',
|
|
||||||
]);
|
]);
|
||||||
|
await expect(page.locator('app-eeg-preview')).toHaveCount(0);
|
||||||
|
await expect(page.getByText('Archivos de entrenamiento', { exact: true })).toHaveCount(0);
|
||||||
|
const uploads = page.getByRole('region', { name: 'Subir archivos' });
|
||||||
|
await expect(uploads.getByLabel('Conjunto')).toBeVisible();
|
||||||
|
await expect(uploads.getByRole('button', { name: 'Archivos', exact: true })).toBeVisible();
|
||||||
|
await expect(uploads.getByRole('button', { name: 'Subir archivos' })).toBeDisabled();
|
||||||
await page.getByRole('combobox', { name: 'Modo' }).click();
|
await page.getByRole('combobox', { name: 'Modo' }).click();
|
||||||
await page.getByRole('option', { name: 'Sync' }).click();
|
await page.getByRole('option', { name: 'Sync' }).click();
|
||||||
await expect(page.getByRole('status').filter({ hasText: 'Disponible' })).toBeVisible();
|
await expect(page.getByRole('status').filter({ hasText: 'Disponible' })).toBeVisible();
|
||||||
@@ -146,6 +152,21 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF',
|
|||||||
await expect(training).toBeFocused();
|
await expect(training).toBeFocused();
|
||||||
await expect(page.locator('app-governance-training formly-form')).toBeVisible();
|
await expect(page.locator('app-governance-training formly-form')).toBeVisible();
|
||||||
|
|
||||||
|
const source = page.getByRole('combobox', { name: 'Origen' });
|
||||||
|
const folder = page.getByLabel('Carpeta', { exact: true });
|
||||||
|
const line = page.getByRole('combobox', { name: 'Frecuencia de la red eléctrica (Hz)' });
|
||||||
|
await expect(source).toHaveText('Niños del sitio sin el diagnóstico');
|
||||||
|
await expect(folder).toBeHidden();
|
||||||
|
await expect(line).toBeHidden();
|
||||||
|
await source.click();
|
||||||
|
await page.getByRole('option', { name: 'Carpeta de EDF con edades' }).click();
|
||||||
|
await expect(folder).toBeVisible();
|
||||||
|
await expect(line).toBeVisible();
|
||||||
|
await source.click();
|
||||||
|
await page.getByRole('option', { name: 'Niños del sitio sin el diagnóstico' }).click();
|
||||||
|
await expect(folder).toBeHidden();
|
||||||
|
await expect(line).toBeHidden();
|
||||||
|
|
||||||
const monitor = page.locator('app-governance-models app-run-monitor');
|
const monitor = page.locator('app-governance-models app-run-monitor');
|
||||||
await page.getByRole('button', { name: 'Analizar EEG' }).click();
|
await page.getByRole('button', { name: 'Analizar EEG' }).click();
|
||||||
await expect(page.getByRole('heading', { name: 'Análisis de EEG' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'Análisis de EEG' })).toBeVisible();
|
||||||
@@ -157,6 +178,7 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF',
|
|||||||
await expect(page.getByText('No hay candidatas que se puedan promover.')).toBeVisible();
|
await expect(page.getByText('No hay candidatas que se puedan promover.')).toBeVisible();
|
||||||
|
|
||||||
const studies = page.locator('app-eeg-studies');
|
const studies = page.locator('app-eeg-studies');
|
||||||
|
await expect(studies.locator('input[type=file]')).toHaveCount(0);
|
||||||
await expect(studies.locator('table.eegs tbody tr').first()).toContainText(/Válido|No válido/);
|
await expect(studies.locator('table.eegs tbody tr').first()).toContainText(/Válido|No válido/);
|
||||||
await studies.locator('table.eegs tbody button:enabled').first().click();
|
await studies.locator('table.eegs tbody button:enabled').first().click();
|
||||||
await expect(studies.getByRole('heading', { name: /^EEG .* meses$/ })).toBeVisible();
|
await expect(studies.getByRole('heading', { name: /^EEG .* meses$/ })).toBeVisible();
|
||||||
@@ -166,7 +188,14 @@ test('tea gobernanza: every section in sync mode, and the preview saved as PDF',
|
|||||||
{ timeout: 10 * 60_000 },
|
{ timeout: 10 * 60_000 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await page
|
||||||
|
.locator('app-governance-models')
|
||||||
|
.getByRole('button', {
|
||||||
|
name: 'Evaluar un solo estudio',
|
||||||
|
})
|
||||||
|
.click();
|
||||||
const preview = page.locator('app-eeg-preview');
|
const preview = page.locator('app-eeg-preview');
|
||||||
|
await expect(preview.getByRole('heading', { name: 'Vista previa' })).toBeVisible();
|
||||||
await preview.getByLabel('EDF').setInputFiles(process.env['TEA_EDF']!);
|
await preview.getByLabel('EDF').setInputFiles(process.env['TEA_EDF']!);
|
||||||
await preview.getByLabel('ADOS-2 (PDF)').setInputFiles(process.env['TEA_ADOS2']!);
|
await preview.getByLabel('ADOS-2 (PDF)').setInputFiles(process.env['TEA_ADOS2']!);
|
||||||
await preview.getByLabel('Fecha de nacimiento').fill(process.env['TEA_BIRTH']!);
|
await preview.getByLabel('Fecha de nacimiento').fill(process.env['TEA_BIRTH']!);
|
||||||
|
|||||||
+63
-34
@@ -1077,6 +1077,37 @@
|
|||||||
"title": "FieldSpec",
|
"title": "FieldSpec",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"FolderTrainingSource": {
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"folder": {
|
||||||
|
"description": "Carpeta dentro de TEA_REFERENCE_ROOT",
|
||||||
|
"pattern": "^[A-Za-z0-9._-]{1,64}$",
|
||||||
|
"title": "Carpeta",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"kind": {
|
||||||
|
"const": "folder",
|
||||||
|
"title": "Kind",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"line_hz": {
|
||||||
|
"default": 50,
|
||||||
|
"enum": [
|
||||||
|
50,
|
||||||
|
60
|
||||||
|
],
|
||||||
|
"title": "Frecuencia de la red el\u00e9ctrica (Hz)",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"kind",
|
||||||
|
"folder"
|
||||||
|
],
|
||||||
|
"title": "FolderTrainingSource",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"Group": {
|
"Group": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -2840,6 +2871,21 @@
|
|||||||
"title": "Site",
|
"title": "Site",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"SiteTrainingSource": {
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"kind": {
|
||||||
|
"const": "site",
|
||||||
|
"title": "Kind",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"kind"
|
||||||
|
],
|
||||||
|
"title": "SiteTrainingSource",
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"Source": {
|
"Source": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"description": "One table, file set or API resource, copied as it is (dlt). Merged on the source's\nown primary key or `primary_key`; replaced whole when it has none.",
|
"description": "One table, file set or API resource, copied as it is (dlt). Merged on the source's\nown primary key or `primary_key`; replaced whole when it has none.",
|
||||||
@@ -3448,43 +3494,21 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"TrainingSource": {
|
"TrainingSource": {
|
||||||
"additionalProperties": false,
|
"discriminator": {
|
||||||
"properties": {
|
"mapping": {
|
||||||
"folder": {
|
"folder": "#/components/schemas/FolderTrainingSource",
|
||||||
"anyOf": [
|
"site": "#/components/schemas/SiteTrainingSource"
|
||||||
|
},
|
||||||
|
"propertyName": "kind"
|
||||||
|
},
|
||||||
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"pattern": "^[A-Za-z0-9._-]{1,64}$",
|
"$ref": "#/components/schemas/SiteTrainingSource"
|
||||||
"type": "string"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null"
|
"$ref": "#/components/schemas/FolderTrainingSource"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"description": "Carpeta dentro de TEA_REFERENCE_ROOT",
|
|
||||||
"title": "Carpeta"
|
|
||||||
},
|
|
||||||
"kind": {
|
|
||||||
"default": "site",
|
|
||||||
"description": "site: los ni\u00f1os del sitio sin el diagn\u00f3stico a la fecha de corte; folder: una carpeta de EDF con edades.csv (path, age en meses)",
|
|
||||||
"enum": [
|
|
||||||
"site",
|
|
||||||
"folder"
|
|
||||||
],
|
|
||||||
"title": "Origen",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"line_hz": {
|
|
||||||
"default": 50,
|
|
||||||
"enum": [
|
|
||||||
50,
|
|
||||||
60
|
|
||||||
],
|
|
||||||
"title": "Frecuencia de la red el\u00e9ctrica (Hz)",
|
|
||||||
"type": "integer"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"title": "Datos de entrenamiento",
|
|
||||||
"type": "object"
|
|
||||||
},
|
},
|
||||||
"Uploaded": {
|
"Uploaded": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -5304,7 +5328,12 @@
|
|||||||
"content": {
|
"content": {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
"schema": {
|
"schema": {
|
||||||
"additionalProperties": true,
|
"additionalProperties": {
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
"title": "Response Training Inputs",
|
"title": "Response Training Inputs",
|
||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export interface TrainingInputs$Params {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function trainingInputs(http: HttpClient, rootUrl: string, params: TrainingInputs$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
export function trainingInputs(http: HttpClient, rootUrl: string, params: TrainingInputs$Params, context?: HttpContext): Observable<StrictHttpResponse<{
|
||||||
[key: string]: any;
|
[key: string]: Array<string>;
|
||||||
}>> {
|
}>> {
|
||||||
const rb = new RequestBuilder(rootUrl, trainingInputs.PATH, 'get');
|
const rb = new RequestBuilder(rootUrl, trainingInputs.PATH, 'get');
|
||||||
if (params) {
|
if (params) {
|
||||||
@@ -29,7 +29,7 @@ export function trainingInputs(http: HttpClient, rootUrl: string, params: Traini
|
|||||||
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
filter((r: any): r is HttpResponse<any> => r instanceof HttpResponse),
|
||||||
map((r: HttpResponse<any>) => {
|
map((r: HttpResponse<any>) => {
|
||||||
return r as StrictHttpResponse<{
|
return r as StrictHttpResponse<{
|
||||||
[key: string]: any;
|
[key: string]: Array<string>;
|
||||||
}>;
|
}>;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export type { Execution } from './models/execution';
|
|||||||
export type { Extract } from './models/extract';
|
export type { Extract } from './models/extract';
|
||||||
export type { Fhir } from './models/fhir';
|
export type { Fhir } from './models/fhir';
|
||||||
export type { FieldSpec } from './models/field-spec';
|
export type { FieldSpec } from './models/field-spec';
|
||||||
|
export type { FolderTrainingSource } from './models/folder-training-source';
|
||||||
export type { Group } from './models/group';
|
export type { Group } from './models/group';
|
||||||
export type { Guided } from './models/guided';
|
export type { Guided } from './models/guided';
|
||||||
export type { Health } from './models/health';
|
export type { Health } from './models/health';
|
||||||
@@ -57,6 +58,7 @@ export type { Scope } from './models/scope';
|
|||||||
export type { Score } from './models/score';
|
export type { Score } from './models/score';
|
||||||
export type { SignIn } from './models/sign-in';
|
export type { SignIn } from './models/sign-in';
|
||||||
export type { Site } from './models/site';
|
export type { Site } from './models/site';
|
||||||
|
export type { SiteTrainingSource } from './models/site-training-source';
|
||||||
export type { Source } from './models/source';
|
export type { Source } from './models/source';
|
||||||
export type { SourceRef } from './models/source-ref';
|
export type { SourceRef } from './models/source-ref';
|
||||||
export type { SourceType } from './models/source-type';
|
export type { SourceType } from './models/source-type';
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
|
export interface FolderTrainingSource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Carpeta dentro de TEA_REFERENCE_ROOT
|
||||||
|
*/
|
||||||
|
folder: string;
|
||||||
|
kind: 'folder';
|
||||||
|
line_hz?: 50 | 60;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
|
export interface SiteTrainingSource {
|
||||||
|
kind: 'site';
|
||||||
|
}
|
||||||
@@ -1,16 +1,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
/* Code generated by ng-openapi-gen DO NOT EDIT. */
|
||||||
|
|
||||||
export interface TrainingSource {
|
import { FolderTrainingSource } from '../models/folder-training-source';
|
||||||
|
import { SiteTrainingSource } from '../models/site-training-source';
|
||||||
|
export type TrainingSource = (SiteTrainingSource | FolderTrainingSource);
|
||||||
|
|
||||||
/**
|
|
||||||
* Carpeta dentro de TEA_REFERENCE_ROOT
|
|
||||||
*/
|
|
||||||
folder?: (string | null);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* site: los niños del sitio sin el diagnóstico a la fecha de corte; folder: una carpeta de EDF con edades.csv (path, age en meses)
|
|
||||||
*/
|
|
||||||
kind?: 'site' | 'folder';
|
|
||||||
line_hz?: 50 | 60;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
[domain]="domainKey()"
|
[domain]="domainKey()"
|
||||||
[execution]="execution.execution()"
|
[execution]="execution.execution()"
|
||||||
(trainingRequested)="training.focus()"
|
(trainingRequested)="training.focus()"
|
||||||
|
(previewRequested)="showPreview.set(true)"
|
||||||
/>
|
/>
|
||||||
<app-governance-training
|
<app-governance-training
|
||||||
#training
|
#training
|
||||||
@@ -38,7 +39,9 @@
|
|||||||
[refresh]="models.refreshed()"
|
[refresh]="models.refreshed()"
|
||||||
(changed)="models.refresh()"
|
(changed)="models.refresh()"
|
||||||
/>
|
/>
|
||||||
|
@if (showPreview()) {
|
||||||
<app-eeg-preview />
|
<app-eeg-preview />
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, computed, inject, input, resource } from '@angular/core';
|
import { Component, computed, inject, input, linkedSignal, resource } from '@angular/core';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
import { Api } from '../api/api';
|
import { Api } from '../api/api';
|
||||||
@@ -30,6 +30,7 @@ import { Training } from './training';
|
|||||||
export class Gobernanza {
|
export class Gobernanza {
|
||||||
private readonly api = inject(Api);
|
private readonly api = inject(Api);
|
||||||
readonly domain = input.required<string>();
|
readonly domain = input.required<string>();
|
||||||
|
protected readonly showPreview = linkedSignal({ source: this.domain, computation: () => false });
|
||||||
protected readonly domainKey = computed(() => this.domain() as Domain);
|
protected readonly domainKey = computed(() => this.domain() as Domain);
|
||||||
protected readonly labels = DOMAINS as Record<string, string>;
|
protected readonly labels = DOMAINS as Record<string, string>;
|
||||||
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
protected readonly domains = resource({ loader: () => this.api.invoke(domains) });
|
||||||
|
|||||||
@@ -19,6 +19,9 @@
|
|||||||
>
|
>
|
||||||
Analizar EEG
|
Analizar EEG
|
||||||
</button>
|
</button>
|
||||||
|
<button mat-stroked-button type="button" (click)="previewRequested.emit()">
|
||||||
|
Evaluar un solo estudio
|
||||||
|
</button>
|
||||||
}
|
}
|
||||||
<button
|
<button
|
||||||
mat-stroked-button
|
mat-stroked-button
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export class Models {
|
|||||||
readonly domain = input.required<Domain>();
|
readonly domain = input.required<Domain>();
|
||||||
readonly execution = input<Choice>();
|
readonly execution = input<Choice>();
|
||||||
readonly trainingRequested = output<void>();
|
readonly trainingRequested = output<void>();
|
||||||
|
readonly previewRequested = output<void>();
|
||||||
protected readonly reportNames = REPORTS;
|
protected readonly reportNames = REPORTS;
|
||||||
protected readonly errorText = errorText;
|
protected readonly errorText = errorText;
|
||||||
readonly refreshed = signal(0);
|
readonly refreshed = signal(0);
|
||||||
|
|||||||
@@ -23,25 +23,6 @@
|
|||||||
}
|
}
|
||||||
<button mat-flat-button type="submit" [disabled]="busy() || !execution()">Analizar</button>
|
<button mat-flat-button type="submit" [disabled]="busy() || !execution()">Analizar</button>
|
||||||
</form>
|
</form>
|
||||||
<form (ngSubmit)="upload(files)">
|
|
||||||
<input
|
|
||||||
#files
|
|
||||||
type="file"
|
|
||||||
accept=".edf"
|
|
||||||
multiple
|
|
||||||
required
|
|
||||||
hidden
|
|
||||||
aria-label="Archivos EDF"
|
|
||||||
(change)="selectedFiles.set(files.files)"
|
|
||||||
/>
|
|
||||||
<button mat-stroked-button type="button" (click)="files.click()">Archivos EDF</button>
|
|
||||||
@for (file of selectedFiles(); track $index) {
|
|
||||||
<span>{{ file.name }}</span>
|
|
||||||
}
|
|
||||||
<button mat-stroked-button type="submit" [disabled]="busy() || !selectedFiles()?.length">
|
|
||||||
Subir EDF
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
@if (error()) {
|
@if (error()) {
|
||||||
<p role="alert">{{ error() }}</p>
|
<p role="alert">{{ error() }}</p>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { DatePipe, DecimalPipe, KeyValuePipe } from '@angular/common';
|
import { DatePipe, DecimalPipe, KeyValuePipe } from '@angular/common';
|
||||||
import { HttpErrorResponse } from '@angular/common/http';
|
|
||||||
import { Component, inject, input, output, resource, signal } from '@angular/core';
|
import { Component, inject, input, output, resource, signal } from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
@@ -11,9 +10,6 @@ import { analyzeEegs } from '../../api/fn/eeg/analyze-eegs';
|
|||||||
import { eegStudiesSummary } from '../../api/fn/eeg/eeg-studies-summary';
|
import { eegStudiesSummary } from '../../api/fn/eeg/eeg-studies-summary';
|
||||||
import { studies } from '../../api/fn/eeg/studies';
|
import { studies } from '../../api/fn/eeg/studies';
|
||||||
import { study } from '../../api/fn/eeg/study';
|
import { study } from '../../api/fn/eeg/study';
|
||||||
import { pipeline } from '../../api/fn/ingest/pipeline';
|
|
||||||
import { startRun } from '../../api/fn/ingest/start-run';
|
|
||||||
import { upload } from '../../api/fn/ingest/upload';
|
|
||||||
import { runHistory } from '../../api/fn/runs/run-history';
|
import { runHistory } from '../../api/fn/runs/run-history';
|
||||||
import type { Execution } from '../../api/models/execution';
|
import type { Execution } from '../../api/models/execution';
|
||||||
import type { Scope } from '../../api/models/scope';
|
import type { Scope } from '../../api/models/scope';
|
||||||
@@ -98,7 +94,6 @@ export class EegStudies {
|
|||||||
protected readonly mode = signal<NonNullable<Scope['mode']>>('pending');
|
protected readonly mode = signal<NonNullable<Scope['mode']>>('pending');
|
||||||
protected readonly count = signal<number | null>(null);
|
protected readonly count = signal<number | null>(null);
|
||||||
protected readonly ids = signal('');
|
protected readonly ids = signal('');
|
||||||
protected readonly selectedFiles = signal<FileList | null>(null);
|
|
||||||
protected readonly busy = signal(false);
|
protected readonly busy = signal(false);
|
||||||
protected readonly error = signal('');
|
protected readonly error = signal('');
|
||||||
protected readonly runId = signal('');
|
protected readonly runId = signal('');
|
||||||
@@ -118,47 +113,19 @@ export class EegStudies {
|
|||||||
scope.ids = this.ids().split(/\s+/).filter(Boolean);
|
scope.ids = this.ids().split(/\s+/).filter(Boolean);
|
||||||
if (!scope.ids.length) return;
|
if (!scope.ids.length) return;
|
||||||
}
|
}
|
||||||
await this.start(() => this.api.invoke(analyzeEegs, { body: { scope, execution } }));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected async upload(input: HTMLInputElement): Promise<void> {
|
|
||||||
const files = Array.from(input.files ?? []);
|
|
||||||
if (!files.length) return;
|
|
||||||
if (files.some((file) => !file.name.toLowerCase().endsWith('.edf'))) {
|
|
||||||
this.error.set('Selecciona archivos EDF.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await this.start(async () => {
|
|
||||||
try {
|
|
||||||
await this.api.invoke(pipeline, { pipeline_id: 'tea' });
|
|
||||||
await this.api.invoke(upload, { body: { files: files as unknown as string[] } });
|
|
||||||
const run = await this.api.invoke(startRun, { pipeline_id: 'tea', body: {} });
|
|
||||||
input.value = '';
|
|
||||||
this.selectedFiles.set(null);
|
|
||||||
return run;
|
|
||||||
} catch (error) {
|
|
||||||
if (error instanceof HttpErrorResponse && error.status === 404) {
|
|
||||||
throw new Error('No hay un pipeline TEA configurado');
|
|
||||||
}
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected finish(): void {
|
|
||||||
this.busy.set(false);
|
|
||||||
this.changed.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async start(submit: () => Promise<{ [key: string]: string }>): Promise<void> {
|
|
||||||
this.busy.set(true);
|
this.busy.set(true);
|
||||||
this.error.set('');
|
this.error.set('');
|
||||||
try {
|
try {
|
||||||
const { run_id } = await submit();
|
const { run_id } = await this.api.invoke(analyzeEegs, { body: { scope, execution } });
|
||||||
this.runId.set(run_id);
|
this.runId.set(run_id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.error.set(errorText(error));
|
this.error.set(errorText(error));
|
||||||
this.busy.set(false);
|
this.busy.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected finish(): void {
|
||||||
|
this.busy.set(false);
|
||||||
|
this.changed.emit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { trainingForm } from './training';
|
import { trainingForm } from './training';
|
||||||
|
|
||||||
describe('training form', () => {
|
describe('training form', () => {
|
||||||
it('removes execution and resolves the TEA training source with its defaults', () => {
|
it('builds the source selector from the folder fields and keeps the site payload minimal', () => {
|
||||||
const { schema, model } = trainingForm({
|
const { schema, model } = trainingForm({
|
||||||
name: 'all',
|
name: 'all',
|
||||||
domain: 'tea',
|
domain: 'tea',
|
||||||
defaults: {
|
defaults: {
|
||||||
execution: { mode: 'local', scheduler: null },
|
execution: { mode: 'local', scheduler: null },
|
||||||
source: { kind: 'site', line_hz: 50 },
|
source: { kind: 'site' },
|
||||||
},
|
},
|
||||||
json_schema: {
|
json_schema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -18,10 +18,22 @@ describe('training form', () => {
|
|||||||
},
|
},
|
||||||
$defs: {
|
$defs: {
|
||||||
TrainingSource: {
|
TrainingSource: {
|
||||||
|
discriminator: { propertyName: 'kind' },
|
||||||
|
oneOf: [
|
||||||
|
{ $ref: '#/$defs/SiteTrainingSource' },
|
||||||
|
{ $ref: '#/$defs/FolderTrainingSource' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
SiteTrainingSource: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
properties: { kind: { type: 'string', const: 'site' } },
|
||||||
|
},
|
||||||
|
FolderTrainingSource: {
|
||||||
|
type: 'object',
|
||||||
|
required: ['kind', 'folder'],
|
||||||
properties: {
|
properties: {
|
||||||
kind: { type: 'string', enum: ['site', 'folder'], default: 'site' },
|
kind: { type: 'string', const: 'folder' },
|
||||||
folder: { anyOf: [{ type: 'string' }, { type: 'null' }] },
|
folder: { type: 'string' },
|
||||||
line_hz: { type: 'integer', enum: [50, 60], default: 50 },
|
line_hz: { type: 'integer', enum: [50, 60], default: 50 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -35,13 +47,14 @@ describe('training form', () => {
|
|||||||
format: 'date',
|
format: 'date',
|
||||||
});
|
});
|
||||||
expect(schema.properties?.['source']).toMatchObject({
|
expect(schema.properties?.['source']).toMatchObject({
|
||||||
type: ['object', 'null'],
|
type: 'object',
|
||||||
|
required: ['kind', 'folder'],
|
||||||
properties: {
|
properties: {
|
||||||
kind: { enum: ['site', 'folder'] },
|
kind: { enum: ['site', 'folder'] },
|
||||||
folder: { type: ['string', 'null'] },
|
folder: { type: 'string' },
|
||||||
line_hz: { enum: [50, 60] },
|
line_hz: { enum: [50, 60] },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(model).toEqual({ source: { kind: 'site', line_hz: 50 } });
|
expect(model).toEqual({ source: { kind: 'site' } });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,23 +28,30 @@ import { uploadTrainingInputs } from '../api/fn/models/upload-training-inputs';
|
|||||||
import type { Domain } from '../api/models/domain';
|
import type { Domain } from '../api/models/domain';
|
||||||
import type { Execution } from '../api/models/execution';
|
import type { Execution } from '../api/models/execution';
|
||||||
import type { TrainingConfig } from '../api/models/training-config';
|
import type { TrainingConfig } from '../api/models/training-config';
|
||||||
|
import type { TrainingSource } from '../api/models/training-source';
|
||||||
import { FORMLY_TYPES } from '../conectar/schema-form';
|
import { FORMLY_TYPES } from '../conectar/schema-form';
|
||||||
import { errorText } from './run-monitor';
|
import { errorText } from './run-monitor';
|
||||||
|
|
||||||
type Schema = JSONSchema7 & { $defs?: Record<string, Schema> };
|
type Schema = JSONSchema7 & { $defs?: Record<string, Schema> };
|
||||||
|
|
||||||
interface InputSets {
|
|
||||||
allowed: string[];
|
|
||||||
description: string;
|
|
||||||
sets: { name: string; edf_files: number; has_ages: boolean }[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function trainingForm(config: TrainingConfig) {
|
export function trainingForm(config: TrainingConfig) {
|
||||||
const raw = structuredClone(config.json_schema) as Schema;
|
const raw = structuredClone(config.json_schema) as Schema;
|
||||||
const model = structuredClone(config.defaults);
|
const model = structuredClone(config.defaults);
|
||||||
delete model['execution'];
|
delete model['execution'];
|
||||||
delete raw.properties?.['execution'];
|
delete raw.properties?.['execution'];
|
||||||
raw.required = raw.required?.filter((key) => key !== 'execution');
|
raw.required = raw.required?.filter((key) => key !== 'execution');
|
||||||
|
if (raw.properties?.['source']) {
|
||||||
|
const folder = raw.$defs!['FolderTrainingSource'];
|
||||||
|
raw.properties['source'] = {
|
||||||
|
...folder,
|
||||||
|
title: 'Datos de entrenamiento',
|
||||||
|
properties: {
|
||||||
|
kind: { type: 'string', title: 'Origen', enum: ['site', 'folder'] },
|
||||||
|
folder: folder.properties!['folder'],
|
||||||
|
line_hz: folder.properties!['line_hz'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
const normalize = (schema: Schema): Schema => {
|
const normalize = (schema: Schema): Schema => {
|
||||||
if (schema.$ref) return normalize(raw.$defs![schema.$ref.split('/').pop()!]);
|
if (schema.$ref) return normalize(raw.$defs![schema.$ref.split('/').pop()!]);
|
||||||
if (schema.anyOf) {
|
if (schema.anyOf) {
|
||||||
@@ -89,6 +96,7 @@ function allowedFile(file: File, allowed: string[]): boolean {
|
|||||||
MatInputModule,
|
MatInputModule,
|
||||||
],
|
],
|
||||||
providers: [provideFormlyCore([...withFormlyMaterial(), FORMLY_TYPES])],
|
providers: [provideFormlyCore([...withFormlyMaterial(), FORMLY_TYPES])],
|
||||||
|
styles: ':host { display: grid; gap: var(--space-4); }',
|
||||||
template: `
|
template: `
|
||||||
<section class="card" aria-labelledby="training-heading">
|
<section class="card" aria-labelledby="training-heading">
|
||||||
<h2 #heading id="training-heading" tabindex="-1">Entrenamiento</h2>
|
<h2 #heading id="training-heading" tabindex="-1">Entrenamiento</h2>
|
||||||
@@ -115,33 +123,24 @@ function allowedFile(file: File, allowed: string[]): boolean {
|
|||||||
} @else if (config.error(); as error) {
|
} @else if (config.error(); as error) {
|
||||||
<p role="alert">{{ errorText(error) }}</p>
|
<p role="alert">{{ errorText(error) }}</p>
|
||||||
}
|
}
|
||||||
@if (inputs.hasValue() && inputs.value(); as sets) {
|
@if (message()) {
|
||||||
<h4>Archivos de entrenamiento</h4>
|
<p role="status">{{ message() }}</p>
|
||||||
<p>{{ sets.description }}</p>
|
|
||||||
<ul>
|
|
||||||
@for (set of sets.sets; track set.name) {
|
|
||||||
<li>
|
|
||||||
{{ set.name }} · {{ set.edf_files }} EDF ·
|
|
||||||
{{ set.has_ages ? 'Con edades' : 'Sin edades' }}
|
|
||||||
</li>
|
|
||||||
}
|
}
|
||||||
</ul>
|
</section>
|
||||||
|
@if (inputs.hasValue() && inputs.value(); as metadata) {
|
||||||
|
<section class="card" aria-labelledby="training-upload-heading">
|
||||||
|
<h2 id="training-upload-heading">Subir archivos</h2>
|
||||||
<form (ngSubmit)="upload(setName.value, files)">
|
<form (ngSubmit)="upload(setName.value, files)">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<mat-label>Conjunto</mat-label>
|
<mat-label>Conjunto</mat-label>
|
||||||
<input matInput #setName list="training-input-sets" required />
|
<input matInput #setName required />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<datalist id="training-input-sets">
|
|
||||||
@for (set of sets.sets; track set.name) {
|
|
||||||
<option [value]="set.name"></option>
|
|
||||||
}
|
|
||||||
</datalist>
|
|
||||||
<input
|
<input
|
||||||
#files
|
#files
|
||||||
type="file"
|
type="file"
|
||||||
multiple
|
multiple
|
||||||
required
|
required
|
||||||
[accept]="accept(sets.allowed)"
|
[accept]="accept(metadata.allowed)"
|
||||||
hidden
|
hidden
|
||||||
aria-label="Archivos"
|
aria-label="Archivos"
|
||||||
(change)="selectedFiles.set(files.files)"
|
(change)="selectedFiles.set(files.files)"
|
||||||
@@ -158,13 +157,13 @@ function allowedFile(file: File, allowed: string[]): boolean {
|
|||||||
Subir archivos
|
Subir archivos
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
@if (uploadMessage()) {
|
||||||
|
<p role="status">{{ uploadMessage() }}</p>
|
||||||
|
}
|
||||||
|
</section>
|
||||||
} @else if (inputs.error(); as error) {
|
} @else if (inputs.error(); as error) {
|
||||||
<p role="alert">{{ errorText(error) }}</p>
|
<p role="alert">{{ errorText(error) }}</p>
|
||||||
}
|
}
|
||||||
@if (message()) {
|
|
||||||
<p role="status">{{ message() }}</p>
|
|
||||||
}
|
|
||||||
</section>
|
|
||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
export class Training {
|
export class Training {
|
||||||
@@ -197,6 +196,10 @@ export class Training {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (field.key === 'folder' || field.key === 'line_hz') {
|
||||||
|
field.expressions = { hide: (field) => field.model?.kind !== 'folder' };
|
||||||
|
field.resetOnHide = false;
|
||||||
|
}
|
||||||
if (field.key === 'line_hz') {
|
if (field.key === 'line_hz') {
|
||||||
field.type = 'select';
|
field.type = 'select';
|
||||||
field.props = {
|
field.props = {
|
||||||
@@ -218,7 +221,7 @@ export class Training {
|
|||||||
params: () => ({ domain: this.domain(), name: this.name() }),
|
params: () => ({ domain: this.domain(), name: this.name() }),
|
||||||
loader: async ({ params }) => {
|
loader: async ({ params }) => {
|
||||||
try {
|
try {
|
||||||
return (await this.api.invoke(trainingInputs, params)) as InputSets;
|
return await this.api.invoke(trainingInputs, params);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof HttpErrorResponse && error.status === 404) return undefined;
|
if (error instanceof HttpErrorResponse && error.status === 404) return undefined;
|
||||||
throw error;
|
throw error;
|
||||||
@@ -232,6 +235,7 @@ export class Training {
|
|||||||
});
|
});
|
||||||
protected readonly uploading = signal(false);
|
protected readonly uploading = signal(false);
|
||||||
protected readonly message = signal('');
|
protected readonly message = signal('');
|
||||||
|
protected readonly uploadMessage = signal('');
|
||||||
protected readonly autoPromote = linkedSignal({ source: this.domain, computation: () => false });
|
protected readonly autoPromote = linkedSignal({ source: this.domain, computation: () => false });
|
||||||
protected readonly errorText = errorText;
|
protected readonly errorText = errorText;
|
||||||
|
|
||||||
@@ -245,13 +249,14 @@ export class Training {
|
|||||||
this.message.set('');
|
this.message.set('');
|
||||||
const domain = this.domain();
|
const domain = this.domain();
|
||||||
const name = this.name();
|
const name = this.name();
|
||||||
|
const source = model['source'] as TrainingSource | undefined;
|
||||||
const autoPromote = domain === 'tea' && this.autoPromote();
|
const autoPromote = domain === 'tea' && this.autoPromote();
|
||||||
try {
|
try {
|
||||||
const { run_id } = await this.api.invoke(train, {
|
const { run_id } = await this.api.invoke(train, {
|
||||||
domain,
|
domain,
|
||||||
body: {
|
body: {
|
||||||
as_of: model['as_of'] || undefined,
|
as_of: model['as_of'] || undefined,
|
||||||
source: model['source'] ?? undefined,
|
source: source?.kind === 'site' ? { kind: 'site' } : source,
|
||||||
execution: this.execution(),
|
execution: this.execution(),
|
||||||
...(name === 'all' ? {} : { models: [name] }),
|
...(name === 'all' ? {} : { models: [name] }),
|
||||||
},
|
},
|
||||||
@@ -276,11 +281,11 @@ export class Training {
|
|||||||
const files = Array.from(input.files ?? []);
|
const files = Array.from(input.files ?? []);
|
||||||
const allowed = this.inputs.hasValue() ? (this.inputs.value()?.allowed ?? []) : [];
|
const allowed = this.inputs.hasValue() ? (this.inputs.value()?.allowed ?? []) : [];
|
||||||
if (!files.length || files.some((file) => !allowedFile(file, allowed))) {
|
if (!files.length || files.some((file) => !allowedFile(file, allowed))) {
|
||||||
this.message.set('Archivos permitidos: ' + allowed.join(', '));
|
this.uploadMessage.set('Archivos permitidos: ' + allowed.join(', '));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.uploading.set(true);
|
this.uploading.set(true);
|
||||||
this.message.set('');
|
this.uploadMessage.set('');
|
||||||
try {
|
try {
|
||||||
await this.api.invoke(uploadTrainingInputs, {
|
await this.api.invoke(uploadTrainingInputs, {
|
||||||
domain: this.domain(),
|
domain: this.domain(),
|
||||||
@@ -290,9 +295,8 @@ export class Training {
|
|||||||
});
|
});
|
||||||
input.value = '';
|
input.value = '';
|
||||||
this.selectedFiles.set(null);
|
this.selectedFiles.set(null);
|
||||||
this.inputs.reload();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.message.set(errorText(error));
|
this.uploadMessage.set(errorText(error));
|
||||||
} finally {
|
} finally {
|
||||||
this.uploading.set(false);
|
this.uploading.set(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user