Display table of all jobs on jobs page
This commit is contained in:
parent
80cb29c98f
commit
018a240f84
|
@ -239,8 +239,49 @@ async function complete(id, meta) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async function all() {
|
||||||
|
const query = `SELECT * FROM queue ORDER BY created DESC;`;
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
return db.all(query, [], (err, rows) => {
|
||||||
|
if (err)
|
||||||
|
return reject(err);
|
||||||
|
return resolve(rows);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function annotate(row) {
|
||||||
|
row.hasModel = row.completed != null;
|
||||||
|
if (row.completed != null) {
|
||||||
|
row.status = 'Completed';
|
||||||
|
}
|
||||||
|
else if (row.failed != null) {
|
||||||
|
row.status = 'Failed';
|
||||||
|
}
|
||||||
|
else if (row.started != null) {
|
||||||
|
row.status = 'Training';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
row.status = 'Waiting';
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
app.get('/', async (req, res, next) => {
|
app.get('/', async (req, res, next) => {
|
||||||
const html = index({});
|
let html;
|
||||||
|
let rows;
|
||||||
|
let input;
|
||||||
|
try {
|
||||||
|
rows = await all();
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
log.error(err);
|
||||||
|
return next('ERROR: Could not retrieve jobs from queue');
|
||||||
|
}
|
||||||
|
rows = rows.map(annotate);
|
||||||
|
input = {
|
||||||
|
rows,
|
||||||
|
hasTable: typeof rows == 'undefined' ? false : rows.length > 0
|
||||||
|
};
|
||||||
|
html = index(input);
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
app.post('/', uploadZip.single('dataset'), async (req, res, next) => {
|
app.post('/', uploadZip.single('dataset'), async (req, res, next) => {
|
||||||
|
|
File diff suppressed because one or more lines are too long
40
src/index.ts
40
src/index.ts
|
@ -217,8 +217,46 @@ async function complete (id : string, meta : string | null) : Promise<boolean> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function all () : Promise<any[]> {
|
||||||
|
const query : string = `SELECT * FROM queue ORDER BY created DESC;`;
|
||||||
|
return new Promise((resolve : Function, reject : Function) => {
|
||||||
|
return db.all(query, [], (err : Error, rows : any) => {
|
||||||
|
if (err) return reject(err);
|
||||||
|
return resolve(rows);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function annotate (row : any) {
|
||||||
|
row.hasModel = row.completed != null;
|
||||||
|
if (row.completed != null) {
|
||||||
|
row.status = 'Completed';
|
||||||
|
} else if (row.failed != null) {
|
||||||
|
row.status = 'Failed';
|
||||||
|
} else if (row.started != null) {
|
||||||
|
row.status = 'Training';
|
||||||
|
} else {
|
||||||
|
row.status = 'Waiting';
|
||||||
|
}
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
app.get('/', async (req : Request, res : Response, next : NextFunction) => {
|
app.get('/', async (req : Request, res : Response, next : NextFunction) => {
|
||||||
const html = index({});
|
let html : string;
|
||||||
|
let rows : any[];
|
||||||
|
let input : any;
|
||||||
|
try {
|
||||||
|
rows = await all();
|
||||||
|
} catch (err) {
|
||||||
|
log.error(err);
|
||||||
|
return next('ERROR: Could not retrieve jobs from queue');
|
||||||
|
}
|
||||||
|
rows = rows.map(annotate);
|
||||||
|
input = {
|
||||||
|
rows,
|
||||||
|
hasTable : typeof rows == 'undefined' ? false : rows.length > 0
|
||||||
|
};
|
||||||
|
html = index(input);
|
||||||
res.send(html);
|
res.send(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
<title>YOLOv5 Training Web</title>
|
<title>YOLOv5 Training Web</title>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" integrity="sha512-EZLkOqwILORob+p0BXZc+Vm3RgJBOe1Iq/0fiI7r/wJgzOFZMlsqTa29UEl6v6U6gsV4uIpsNZoV32YZqrCRCQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" integrity="sha512-EZLkOqwILORob+p0BXZc+Vm3RgJBOe1Iq/0fiI7r/wJgzOFZMlsqTa29UEl6v6U6gsV4uIpsNZoV32YZqrCRCQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
<body>
|
<body>
|
||||||
<form method="POST" enctype="multipart/form-data">
|
<div class="container">
|
||||||
|
<div class="row" style="center : true;">
|
||||||
|
<form method="POST" enctype="multipart/form-data" class="u-full-width">
|
||||||
<select name="model" id="model" required>
|
<select name="model" id="model" required>
|
||||||
<option value="yolov5s_onnx">YOLOv5 (small) -> ONNX</option>
|
<option value="yolov5s_onnx">YOLOv5 (small) -> ONNX</option>
|
||||||
<option value="yolov5m_onnx">YOLOv5 (medium) -> ONNX</option>
|
<option value="yolov5m_onnx">YOLOv5 (medium) -> ONNX</option>
|
||||||
|
@ -18,5 +20,35 @@
|
||||||
<br />
|
<br />
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
{{#if hasTable}}
|
||||||
|
<table class="u-full-width">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Job</th>
|
||||||
|
<th>Model</th>
|
||||||
|
<th>Status</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each rows}}
|
||||||
|
<tr>
|
||||||
|
<td>{{this.name}}</td>
|
||||||
|
{{#if this.hasModel}}
|
||||||
|
<td><a href="/model/{{this.id}}">{{this.id}}</a></td>
|
||||||
|
{{else}}
|
||||||
|
<td>{{this.id}}</td>
|
||||||
|
{{/if}}
|
||||||
|
<td>{{this.status}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{else}}
|
||||||
|
<div><i>No jobs listed in queue</i></div>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue