Files
WebApp/src/app/governance/components/notebook-run-dialog/notebook-run-dialog.html
T
edgar 8192f92be9 Governance: choose a notebook kept in the code or upload one
The "Correr un notebook" dialog offers "Del código" (the domain's templates from /governance/notebook-templates, each
with the scenarios it can run for) or "Subir archivo". Choosing a template fills its scenario; a scenario it doesn't
serve keeps "Correr" disabled. The request sends the template's id and no file. A domain without templates opens on
the upload, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-22 00:23:28 -06:00

99 lines
4.6 KiB
HTML

<h2 mat-dialog-title>Correr un notebook</h2>
<mat-dialog-content class="content">
<p class="hint">
Elija un notebook del código (<code>models/&lt;dominio&gt;/&lt;escenario&gt;/notebooks/</code>) o suba uno. Corre
aislado en el servidor, sin red y con los datos de la cohorte que elija como única información: no
ve las bases de datos ni los demás archivos. Dentro usa <code>from models.notebook import experiment</code> para leer
la cohorte, cargar la versión elegida o entrenar; lo que entrene se registra como versión de desarrollo al terminar.
La corrida guarda el notebook, la página con sus resultados y con qué datos se corrió.
</p>
<mat-button-toggle-group [value]="source()" (change)="source.set($event.value)" aria-label="Origen del notebook">
<mat-button-toggle value="plantilla" [disabled]="!templates().length">Del código</mat-button-toggle>
<mat-button-toggle value="archivo">Subir archivo</mat-button-toggle>
</mat-button-toggle-group>
@if (source() === 'plantilla') {
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Notebook del código</mat-label>
<mat-select [ngModel]="template()" (ngModelChange)="setTemplate($event)" [compareWith]="sameTemplate">
@for (option of templates(); track option.id) {
<mat-option [value]="option">{{ templateLabel(option) }}</mat-option>
}
</mat-select>
@if (template(); as chosen) {
<mat-hint>Corre para: {{ chosen.scenarios.join(', ') }}</mat-hint>
}
</mat-form-field>
} @else {
<div class="file">
<button mat-stroked-button type="button" [disabled]="busy()" (click)="fileInput.click()">
<mat-icon aria-hidden="true">upload_file</mat-icon>Elegir notebook
</button>
<span class="file__name">{{ file()?.name ?? 'Ningún archivo (.ipynb)' }}</span>
<input #fileInput type="file" accept=".ipynb,application/x-ipynb+json" hidden (change)="pick($event)" />
</div>
}
<div class="grid">
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Dominio</mat-label>
<mat-select [ngModel]="domain()" (ngModelChange)="setDomain($event)">
@for (option of domains; track option.id) {
<mat-option [value]="option.id">{{ option.label }}</mat-option>
}
</mat-select>
</mat-form-field>
<mat-form-field appearance="outline" subscriptSizing="dynamic">
<mat-label>Escenario</mat-label>
<input matInput [ngModel]="scenario()" (ngModelChange)="setScenario($event)" placeholder="cin2_logistic" />
@if (scenario() && !scenarioValid()) {
<mat-error>Solo letras, números, guion y guion bajo.</mat-error>
} @else if (source() === 'plantilla' && template() && !notebookReady()) {
<mat-hint>Esta plantilla no corre para ese escenario.</mat-hint>
} @else {
<mat-hint>El de un modelo existente o uno nuevo para el experimento.</mat-hint>
}
</mat-form-field>
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="grid__wide">
<mat-label>Cohorte</mat-label>
<mat-select [ngModel]="build()" (ngModelChange)="build.set($event)" [compareWith]="sameBuild">
@for (option of builds(); track option.url + option.source + option.build) {
<mat-option [value]="option">{{ buildLabel(option) }}</mat-option>
}
</mat-select>
@if (!builds().length) {
<mat-hint>Este dominio no tiene cohortes exportadas a archivo.</mat-hint>
}
</mat-form-field>
<mat-form-field appearance="outline" subscriptSizing="dynamic" class="grid__wide">
<mat-label>Versión de modelo (opcional)</mat-label>
<mat-select [ngModel]="version()" (ngModelChange)="version.set($event)">
<mat-option value="">Ninguna</mat-option>
@for (option of versions(); track option.version) {
<mat-option [value]="option.version">{{ option.name }}:{{ option.version }} · {{ option.status }}</mat-option>
}
</mat-select>
<mat-hint>El notebook la carga con <code>experiment().model()</code>.</mat-hint>
</mat-form-field>
</div>
@if (busy()) {
<mat-progress-bar mode="indeterminate" aria-label="Iniciando"></mat-progress-bar>
}
@if (error(); as message) {
<p class="alert" role="alert"><mat-icon aria-hidden="true">error</mat-icon>{{ message }}</p>
}
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-button type="button" mat-dialog-close>Cancelar</button>
<button mat-flat-button type="button" [disabled]="!ready()" (click)="run()">
<mat-icon aria-hidden="true">play_arrow</mat-icon>Correr
</button>
</mat-dialog-actions>