Display table of all jobs on jobs page

This commit is contained in:
mmcwilliams 2023-12-14 11:19:42 -05:00
parent 80cb29c98f
commit 018a240f84
4 changed files with 129 additions and 18 deletions

43
dist/index.js vendored
View File

@ -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) => {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -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);
}); });

View File

@ -3,20 +3,52 @@
<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">
<select name="model" id="model" required> <div class="row" style="center : true;">
<option value="yolov5s_onnx">YOLOv5 (small) -> ONNX</option> <form method="POST" enctype="multipart/form-data" class="u-full-width">
<option value="yolov5m_onnx">YOLOv5 (medium) -> ONNX</option> <select name="model" id="model" required>
<option value="yolov5l_onnx">YOLOv5 (large) -> ONNX</option> <option value="yolov5s_onnx">YOLOv5 (small) -> ONNX</option>
</select> <option value="yolov5m_onnx">YOLOv5 (medium) -> ONNX</option>
<br /> <option value="yolov5l_onnx">YOLOv5 (large) -> ONNX</option>
<input type="text" name="name" id="name" placeholder="Model name" required /> </select>
<br /> <br />
<input type="email" name="email" id="email" placeholder="Email" required /> <input type="text" name="name" id="name" placeholder="Model name" required />
<br /> <br />
<input type="file" name="dataset" id="dataset" required /> <input type="email" name="email" id="email" placeholder="Email" required />
<br /> <br />
<input type="submit" /> <input type="file" name="dataset" id="dataset" required />
</form> <br />
<input type="submit" />
</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>