Skip to content

Commit

Permalink
Total number of allocs running now maps over job.groups
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Feb 17, 2023
1 parent 9f4ca0b commit 4a5591f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion ui/app/components/job-status/allocation-row.js
Expand Up @@ -22,7 +22,6 @@ export default class JobStatusAllocationRowComponent extends Component {
@action
captureElement(element) {
this.element = element;
console.log('elly', element.clientWidth);
}

}
2 changes: 1 addition & 1 deletion ui/app/components/job-status/panel.hbs
Expand Up @@ -43,7 +43,7 @@
{{#each this.allocTypes as |type|}}
<span class="legend-item">
<span class="represented-allocation {{type.label}}"></span>
{{capitalize type.label}}
{{get this.allocBlocks type.label}} {{capitalize type.label}}
</span>
{{/each}}
</legend>
Expand Down
27 changes: 21 additions & 6 deletions ui/app/components/job-status/panel.js
Expand Up @@ -6,14 +6,15 @@ import { action } from '@ember/object';

export default class JobStatusPanelComponent extends Component {

// Build note: allocTypes order matters! We will fill up to 100% of totalAllocs in this order.
allocTypes = [
"running",
// "failed",
"failed",
"unknown",
// "queued",
"starting",
"lost",
"queued",
"complete",
// "starting",
// "lost"
].map((type) => {
return {
label: type,
Expand All @@ -22,8 +23,17 @@ export default class JobStatusPanelComponent extends Component {
})

get allocBlocks() {
let totalAllocs = this.totalAllocs;

// Only fill up to 100% of totalAllocs. Once we've filled up, we can stop counting.
return this.allocTypes.reduce((blocks, type) => {
blocks[type.label] = this.args.job[type.property];
if (totalAllocs > 0) {
blocks[type.label] = Math.min(totalAllocs, this.args.job[type.property]);
totalAllocs -= blocks[type.label];
} else {
blocks[type.label] = 0;
}
// blocks[type.label] = this.args.job[type.property];
return blocks;
}, {});
}
Expand All @@ -40,7 +50,12 @@ export default class JobStatusPanelComponent extends Component {

// TODO: eventually we will want this from a new property on a job.
get totalAllocs() {
return this.allocTypes.reduce((sum, type) => sum + this.args.job[type.property], 0);
// v----- Experimental method: Count all allocs. Good for testing but not a realistic representation of "Desired"
// return this.allocTypes.reduce((sum, type) => sum + this.args.job[type.property], 0);

// v----- Realistic method: Tally a job's task groups' "count" property
return this.args.job.taskGroups.reduce((sum, tg) => sum + tg.count, 0);

}

@action
Expand Down

0 comments on commit 4a5591f

Please sign in to comment.