fix progress in legacy tabs

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2026-08-11 10:41:08 +02:00
parent cc91a05870
commit 431774e6e2
7 changed files with 66 additions and 20 deletions
+4 -3
View File
@@ -29,8 +29,9 @@ def start_progress(name: str, total: int):
return None, None
from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn, TimeElapsedColumn
progress = Progress(TextColumn('[cyan]{task.description}'), BarColumn(), TaskProgressColumn(), TimeRemainingColumn(), TimeElapsedColumn(), console=console, transient=True)
task = progress.add_task(description=f'Autotune: kernel={name}', total=total)
progress.start()
return progress, progress.add_task(description=f'Autotune kernel: {name}', total=total)
return progress, task
def stop_progress(session):
@@ -57,7 +58,7 @@ def bench_hook(orig):
session['count'] += 1
if session['progress'] is not None:
session['progress'].update(session['task'], completed=session['count'])
shared.state.textinfo = f"Tuning kernel {session['name']} {session['count']}/{session['total']} (one-time per shape)"
shared.state.textinfo = f"Tuning kernel {session['name']} {session['count']}/{session['total']}"
except Exception as e:
log.debug(f'Kernel autotune: report error: {e}')
return orig(self, *args, config=config, **meta)
@@ -79,7 +80,7 @@ def make_autotune_listener(prior):
log.debug(f'Kernel autotune: kernel={name} shape={shape} cached')
else:
compile_s = (session['compile_us'] / 1e6) if session is not None else 0
log.info(f'Kernel autotune: kernel={name} shape={shape} time={duration or 0:.2f} compile={compile_s:.2f}')
log.debug(f'Kernel autotune: kernel={name} shape={shape} time={duration or 0:.2f} compile={compile_s:.2f}')
except Exception as e:
log.debug(f'Kernel autotune: report error: {e}')
if prior is not None:
+21 -6
View File
@@ -11118,9 +11118,10 @@ function requestProgress(id_task = "undefined", progressEl = null, galleryEl = n
livePreview.appendChild(img);
img.onload = () => {
img.style.width = `min(100%, max(${img.naturalWidth}px, 512px))`;
parentGallery.style.minHeight = `min(82vh, ${img.naturalHeight}px)`;
parentGallery.style.maxHeight = `min(82vh, ${img.naturalHeight}px)`;
parentGallery.style.overflow = "hidden";
const anchored = livePreview.parentElement === parentGallery;
if (anchored) {
parentGallery.style.overflow = "hidden";
}
};
};
const removeLivePreview = (useImage = false) => {
@@ -11141,8 +11142,6 @@ function requestProgress(id_task = "undefined", progressEl = null, galleryEl = n
parentGallery.removeChild(livePreview);
}
if (parentGallery) {
parentGallery.style.minHeight = "unset";
parentGallery.style.maxHeight = "unset";
parentGallery.style.overflow = "unset";
}
} catch {
@@ -11223,6 +11222,21 @@ window.requestInterrupt = requestInterrupt;
window.randomId = randomId;
window.requestProgress = requestProgress;
// ui/dynamicUI.ts
var lastCheckpoint = "";
async function updateUI(model) {
if (model.checkpoint === lastCheckpoint) return;
lastCheckpoint = model.checkpoint;
log("modelUpdate", model);
}
async function updateModel() {
const req = await authFetch2(`${window.api}/checkpoint`);
if (req.ok) {
const model = await req.json();
if (model?.type?.length > 0) updateUI(model);
}
}
// ui/ui.ts
window.opts = {};
window.localization = {};
@@ -11815,11 +11829,12 @@ async function reconnectUI() {
const sd_model = gradioApp().getElementById("setting_sd_model_checkpoint");
let loadingStarted = 0;
let loadingMonitor = null;
const sd_model_callback = () => {
const sd_model_callback = async () => {
const loading = sd_model.querySelector(".eta-bar");
if (!loading) {
loadingStarted = 0;
clearInterval(loadingMonitor);
updateModel();
} else if (loadingStarted === 0) {
loadingStarted = Date.now();
loadingMonitor = setInterval(() => {
+4 -4
View File
File diff suppressed because one or more lines are too long
+25
View File
@@ -0,0 +1,25 @@
import { log } from './logger';
import { authFetch } from './authWrap';
interface Model {
type: string;
class: string;
checkpoint: string;
title: string;
name: string;
}
let lastCheckpoint = '';
async function updateUI(model: Model) {
if (model.checkpoint === lastCheckpoint) return;
lastCheckpoint = model.checkpoint;
log('modelUpdate', model);
}
export async function updateModel() {
const req = await authFetch(`${window.api}/checkpoint`);
if (req.ok) {
const model = await req.json() as Model;
if (model?.type?.length > 0) updateUI(model);
}
}
+8 -5
View File
@@ -143,9 +143,12 @@ export function requestProgress(id_task = 'undefined', progressEl = null, galler
livePreview.appendChild(img);
img.onload = () => {
img.style.width = `min(100%, max(${img.naturalWidth}px, 512px))`;
parentGallery.style.minHeight = `min(82vh, ${img.naturalHeight}px)`;
parentGallery.style.maxHeight = `min(82vh, ${img.naturalHeight}px)`;
parentGallery.style.overflow = 'hidden';
const anchored = livePreview.parentElement === parentGallery;
if (anchored) {
// parentGallery.style.minHeight = `min(82vh, ${img.naturalHeight}px)`;
// parentGallery.style.maxHeight = `min(82vh, ${img.naturalHeight}px)`;
parentGallery.style.overflow = 'hidden';
}
};
};
@@ -167,8 +170,8 @@ export function requestProgress(id_task = 'undefined', progressEl = null, galler
parentGallery.removeChild(livePreview);
}
if (parentGallery) {
parentGallery.style.minHeight = 'unset';
parentGallery.style.maxHeight = 'unset';
// parentGallery.style.minHeight = 'unset';
// parentGallery.style.maxHeight = 'unset';
parentGallery.style.overflow = 'unset';
}
} catch { /* ignore */ }
+3 -1
View File
@@ -3,6 +3,7 @@ import { gradioApp, onAfterUiUpdate } from './script';
import { log, debug, error } from './logger';
import { timer } from './timers';
import { authFetch } from './authWrap';
import { updateModel } from './dynamicUI';
import { getENActiveTab, markSelectedCards } from './extraNetworks';
window.opts = {};
@@ -805,11 +806,12 @@ export async function reconnectUI() {
let loadingStarted = 0;
let loadingMonitor: ReturnType<typeof setInterval> | null = null;
const sd_model_callback = () => {
const sd_model_callback = async () => {
const loading = sd_model.querySelector('.eta-bar');
if (!loading) {
loadingStarted = 0;
clearInterval(loadingMonitor);
updateModel();
} else if (loadingStarted === 0) {
loadingStarted = Date.now();
loadingMonitor = setInterval(() => {