mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-11-04 01:25:06 +01:00 
			
		
		
		
	feat: add new distribution plots to status view
- numCores and numAccs
This commit is contained in:
		@@ -280,7 +280,7 @@ func (r *queryResolver) JobsStatistics(ctx context.Context, filter []*model.JobF
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if requireField(ctx, "histDuration") || requireField(ctx, "histNumNodes") {
 | 
						if requireField(ctx, "histDuration") || requireField(ctx, "histNumNodes") || requireField(ctx, "histNumCores") || requireField(ctx, "histNumAccs") {
 | 
				
			||||||
		if groupBy == nil {
 | 
							if groupBy == nil {
 | 
				
			||||||
			stats[0], err = r.Repo.AddHistograms(ctx, filter, stats[0])
 | 
								stats[0], err = r.Repo.AddHistograms(ctx, filter, stats[0])
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -442,6 +442,18 @@ func (r *JobRepository) AddHistograms(
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						stat.HistNumCores, err = r.jobsStatisticsHistogram(ctx, "job.num_hwthreads as value", filter)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Warn("Error while loading job statistics histogram: num hwthreads")
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						stat.HistNumAccs, err = r.jobsStatisticsHistogram(ctx, "job.num_acc as value", filter)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Warn("Error while loading job statistics histogram: num acc")
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log.Debugf("Timer AddHistograms %s", time.Since(start))
 | 
						log.Debugf("Timer AddHistograms %s", time.Since(start))
 | 
				
			||||||
	return stat, nil
 | 
						return stat, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,6 +44,8 @@
 | 
				
			|||||||
        stats: jobsStatistics(filter: $filter) {
 | 
					        stats: jobsStatistics(filter: $filter) {
 | 
				
			||||||
            histDuration { count, value }
 | 
					            histDuration { count, value }
 | 
				
			||||||
            histNumNodes { count, value }
 | 
					            histNumNodes { count, value }
 | 
				
			||||||
 | 
					            histNumCores { count, value }
 | 
				
			||||||
 | 
					            histNumAccs { count, value }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        allocatedNodes(cluster: $cluster) { name, count }
 | 
					        allocatedNodes(cluster: $cluster) { name, count }
 | 
				
			||||||
@@ -324,4 +326,32 @@
 | 
				
			|||||||
            {/key}
 | 
					            {/key}
 | 
				
			||||||
        </Col>
 | 
					        </Col>
 | 
				
			||||||
    </Row>
 | 
					    </Row>
 | 
				
			||||||
 | 
					    <Row cols={2}>
 | 
				
			||||||
 | 
					        <Col class="p-2">
 | 
				
			||||||
 | 
					            <div bind:clientWidth={colWidth2}>
 | 
				
			||||||
 | 
					                {#key $mainQuery.data.stats}
 | 
				
			||||||
 | 
					                    <Histogram
 | 
				
			||||||
 | 
					                        data={convert2uplot($mainQuery.data.stats[0].histNumCores)}
 | 
				
			||||||
 | 
					                        width={colWidth2 - 25}
 | 
				
			||||||
 | 
					                        title="Number of Cores Distribution"
 | 
				
			||||||
 | 
					                        xlabel="Allocated Cores"
 | 
				
			||||||
 | 
					                        xunit="Cores" 
 | 
				
			||||||
 | 
					                        ylabel="Number of Jobs"
 | 
				
			||||||
 | 
					                        yunit="Jobs"/>
 | 
				
			||||||
 | 
					                {/key}
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					        </Col>
 | 
				
			||||||
 | 
					        <Col class="p-2">
 | 
				
			||||||
 | 
					            {#key $mainQuery.data.stats}
 | 
				
			||||||
 | 
					                <Histogram
 | 
				
			||||||
 | 
					                    data={convert2uplot($mainQuery.data.stats[0].histNumAccs)}
 | 
				
			||||||
 | 
					                    width={colWidth2 - 25}
 | 
				
			||||||
 | 
					                    title="Number of Accelerators Distribution"
 | 
				
			||||||
 | 
					                    xlabel="Allocated Accs"
 | 
				
			||||||
 | 
					                    xunit="Accs" 
 | 
				
			||||||
 | 
					                    ylabel="Number of Jobs"
 | 
				
			||||||
 | 
					                    yunit="Jobs"/>
 | 
				
			||||||
 | 
					            {/key}
 | 
				
			||||||
 | 
					        </Col>
 | 
				
			||||||
 | 
					    </Row>
 | 
				
			||||||
{/if}
 | 
					{/if}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user