Skip to content

Commit e6d0595

Browse files
author
Daniel Thom
authored
Merge pull request #97 from NREL/fix/attempt-id
Fix handling of attempt ID in the apps
2 parents 453886d + c71d5d8 commit e6d0595

7 files changed

Lines changed: 24 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ jobs:
7171
env:
7272
DATABASE_URL: sqlite:db/sqlite/dev.db
7373

74+
- name: Build test binaries (only necessary packages)
75+
run: cargo build --all-features -p torc -p torc-server
76+
env:
77+
RUST_BACKTRACE: 1
78+
7479
- name: Run tests (Windows - limited test set)
7580
if: matrix.os == 'windows-latest'
76-
run: cargo test --test test_full_workflows test_many_jobs_parameterized -- --test-threads 1
81+
run: cargo test --all-features --test test_full_workflows test_many_jobs_parameterized -- --test-threads 1
7782
env:
7883
RUST_BACKTRACE: 1
7984
OPENSSL_DIR: C:/vcpkg/installed/x64-windows-static-md
@@ -84,7 +89,7 @@ jobs:
8489

8590
- name: Run tests (Unix - full test suite)
8691
if: matrix.os != 'windows-latest'
87-
run: cargo test -- --test-threads 1
92+
run: cargo test --all-features -- --test-threads 1
8893
env:
8994
RUST_BACKTRACE: 1
9095

src/tui/app.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,10 +1540,11 @@ impl App {
15401540
let results = self.client.list_results(workflow_id)?;
15411541

15421542
// Find the most recent result for this job
1543+
// Sort by (run_id, attempt_id) to get the latest attempt of the latest run
15431544
if let Some(result) = results
15441545
.iter()
15451546
.filter(|r| r.job_id == viewer.job_id)
1546-
.max_by_key(|r| r.run_id)
1547+
.max_by_key(|r| (r.run_id, r.attempt_id.unwrap_or(1)))
15471548
{
15481549
// Construct log paths using the standard path pattern
15491550
// Default output directory is "output" in the current working directory

src/tui/ui.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ fn draw_results_table(f: &mut Frame, area: Rect, app: &mut App) {
688688
.add_modifier(Modifier::BOLD);
689689

690690
let header = Row::new(vec![
691-
"ID", "Job ID", "Run", "Return", "Status", "Peak Mem", "Peak CPU",
691+
"ID", "Job ID", "Run", "Attempt", "Return", "Status", "Peak Mem", "Peak CPU",
692692
])
693693
.style(header_style)
694694
.bottom_margin(1);
@@ -697,6 +697,7 @@ fn draw_results_table(f: &mut Frame, area: Rect, app: &mut App) {
697697
let id = result.id.map(|i| i.to_string()).unwrap_or_default();
698698
let job_id = result.job_id.to_string();
699699
let run_id = result.run_id.to_string();
700+
let attempt_id = result.attempt_id.unwrap_or(1).to_string();
700701
let return_code = result.return_code;
701702
let status = format!("{:?}", result.status);
702703

@@ -723,6 +724,7 @@ fn draw_results_table(f: &mut Frame, area: Rect, app: &mut App) {
723724
Cell::from(id),
724725
Cell::from(job_id),
725726
Cell::from(run_id),
727+
Cell::from(attempt_id),
726728
Cell::from(Span::styled(
727729
return_code.to_string(),
728730
Style::default().fg(row_color),
@@ -757,6 +759,7 @@ fn draw_results_table(f: &mut Frame, area: Rect, app: &mut App) {
757759
Constraint::Length(6), // ID
758760
Constraint::Length(8), // Job ID
759761
Constraint::Length(5), // Run
762+
Constraint::Length(7), // Attempt
760763
Constraint::Length(7), // Return
761764
Constraint::Length(12), // Status
762765
Constraint::Length(10), // Peak Mem

tests/test_full_workflows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ resource_requirements:
816816
let work_fail_latest = result_items
817817
.iter()
818818
.filter(|r| r.job_id == work_fail_job.id.unwrap())
819-
.max_by_key(|r| r.run_id)
819+
.max_by_key(|r| (r.run_id, r.attempt_id.unwrap_or(1)))
820820
.expect("work_fail should have results");
821821
assert_eq!(
822822
work_fail_latest.return_code, 0,
@@ -1151,7 +1151,7 @@ resource_requirements:
11511151
let work_fail_latest = result_items
11521152
.iter()
11531153
.filter(|r| r.job_id == work_fail_job.id.unwrap())
1154-
.max_by_key(|r| r.run_id)
1154+
.max_by_key(|r| (r.run_id, r.attempt_id.unwrap_or(1)))
11551155
.expect("work_fail should have results");
11561156
assert_eq!(
11571157
work_fail_latest.return_code, 0,

torc-dash/static/js/app-details.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ Object.assign(TorcDashboard.prototype, {
379379
<td><code>${result.job_id ?? '-'}</code></td>
380380
<td>${this.escapeHtml(jobNameMap[result.job_id] || '-')}</td>
381381
<td>${result.run_id ?? '-'}</td>
382+
<td>${result.attempt_id ?? 1}</td>
382383
<td class="${result.return_code === 0 ? 'return-code-0' : 'return-code-error'}">${result.return_code ?? '-'}</td>
383384
<td><span class="status-badge status-${statusNames[result.status]?.toLowerCase() || 'unknown'}">${statusNames[result.status] || result.status}</span></td>
384385
<td>${result.exec_time_minutes != null ? result.exec_time_minutes.toFixed(2) : '-'}</td>

torc-dash/static/js/app-job-details.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Object.assign(TorcDashboard.prototype, {
200200
<thead>
201201
<tr>
202202
<th>Run ID</th>
203+
<th>Attempt</th>
203204
<th>Return Code</th>
204205
<th>Status</th>
205206
<th>Exec Time (min)</th>
@@ -211,6 +212,7 @@ Object.assign(TorcDashboard.prototype, {
211212
${data.results.map(r => `
212213
<tr>
213214
<td>${r.run_id ?? '-'}</td>
215+
<td>${r.attempt_id ?? 1}</td>
214216
<td class="${r.return_code === 0 ? 'return-code-0' : 'return-code-error'}">${r.return_code ?? '-'}</td>
215217
<td><span class="status-badge status-${statusNames[r.status]?.toLowerCase() || 'unknown'}">${statusNames[r.status] || r.status}</span></td>
216218
<td>${r.exec_time_minutes != null ? r.exec_time_minutes.toFixed(2) : '-'}</td>
@@ -402,7 +404,7 @@ Object.assign(TorcDashboard.prototype, {
402404

403405
// Build run selector if multiple runs
404406
const runOptions = data.results.map((r, idx) =>
405-
`<option value="${idx}" ${idx === data.results.length - 1 ? 'selected' : ''}>Run ${r.run_id} (Return: ${r.return_code})</option>`
407+
`<option value="${idx}" ${idx === data.results.length - 1 ? 'selected' : ''}>Run ${r.run_id} Attempt ${r.attempt_id ?? 1} (Return: ${r.return_code})</option>`
406408
).join('');
407409

408410
contentEl.innerHTML = `
@@ -486,7 +488,9 @@ Object.assign(TorcDashboard.prototype, {
486488
const isStdout = (this._jobLogTab || 'stdout') === 'stdout';
487489

488490
// Construct log file path based on naming convention
489-
const stdioBase = `${outputDir}/job_stdio/job_wf${result.workflow_id}_j${result.job_id}_r${result.run_id}`;
491+
// Include attempt_id in the path (defaults to 1 if not present)
492+
const attemptId = result.attempt_id ?? 1;
493+
const stdioBase = `${outputDir}/job_stdio/job_wf${result.workflow_id}_j${result.job_id}_r${result.run_id}_a${attemptId}`;
490494
const filePath = isStdout ? `${stdioBase}.o` : `${stdioBase}.e`;
491495

492496
logPathEl.textContent = filePath;

torc-dash/static/js/app-tables.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Object.assign(TorcDashboard.prototype, {
138138
${this.renderSortableHeader('Job ID', 'job_id')}
139139
${this.renderSortableHeader('Job Name', 'job_name')}
140140
${this.renderSortableHeader('Run ID', 'run_id')}
141+
${this.renderSortableHeader('Attempt', 'attempt_id')}
141142
${this.renderSortableHeader('Return Code', 'return_code')}
142143
${this.renderSortableHeader('Status', 'status')}
143144
${this.renderSortableHeader('Exec Time (min)', 'exec_time_minutes')}
@@ -151,6 +152,7 @@ Object.assign(TorcDashboard.prototype, {
151152
<td><code>${result.job_id ?? '-'}</code></td>
152153
<td>${this.escapeHtml(jobNameMap[result.job_id] || '-')}</td>
153154
<td>${result.run_id ?? '-'}</td>
155+
<td>${result.attempt_id ?? 1}</td>
154156
<td class="${result.return_code === 0 ? 'return-code-0' : 'return-code-error'}">${result.return_code ?? '-'}</td>
155157
<td><span class="status-badge status-${statusNames[result.status]?.toLowerCase() || 'unknown'}">${statusNames[result.status] || result.status}</span></td>
156158
<td>${result.exec_time_minutes != null ? result.exec_time_minutes.toFixed(2) : '-'}</td>

0 commit comments

Comments
 (0)