Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Resource Allocation stats to trial detail #9533

Merged
merged 11 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions harness/determined/common/api/bindings.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions master/internal/api_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,31 @@ func (a *apiServer) GetTaskAcceleratorData(
return nil, err
}

var res []model.AcceleratorData
err := db.Bun().NewSelect().
ColumnExpr("alloc_acc.*").
res := []struct {
model.AcceleratorData
ResourcePool string
}{}

err := db.Bun().NewSelect().ColumnExpr("alloc_acc.*").
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update a test in api_tasks_intg_test.go to check resource pool is set right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, test added

Column("resource_pool").
TableExpr("allocation_accelerators alloc_acc").
Join("LEFT JOIN allocations alloc ON alloc_acc.allocation_id = alloc.allocation_id").
Order("start_time DESC").
Where("alloc.task_id = ?", req.TaskId).Scan(ctx, &res)
if err != nil {
return nil, fmt.Errorf("querying allocation accelerators: %w", err)
}

var accelerationData []*apiv1.AcceleratorData
for _, r := range res {
accelerationData = append(accelerationData, r.Proto())
accelerationData = append(accelerationData, &apiv1.AcceleratorData{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not modify the Proto() method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hesitate to change the model.AcceleratorData type, it will no longer match the allocation_accelerators table, also there are use cases where the resource_pool field is not necessary

ContainerId: r.ContainerID,
AllocationId: string(r.AllocationID),
NodeName: r.NodeName,
AcceleratorType: r.AcceleratorType,
AcceleratorUuids: r.AcceleratorUuids,
ResourcePool: r.ResourcePool,
})
}
return &apiv1.GetTaskAcceleratorDataResponse{AcceleratorData: accelerationData}, nil
}
Expand Down
523 changes: 267 additions & 256 deletions proto/pkg/apiv1/trial.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions proto/src/determined/api/v1/trial.proto
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@ message AcceleratorData {
string accelerator_type = 5;
// An array of UUIDs of the accelerators associated with the allocation.
repeated string accelerator_uuids = 6;
// The name of the resource pool.
string resource_pool = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a little awkward to me that we won't use this field when calling v1PostAllocationAcceleratorDataRequest but I think this is fine

}

// Arguments to an all gather.
Expand Down
81 changes: 40 additions & 41 deletions webui/react/src/pages/ResourcePool/Topology.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,51 @@
display: flex;
flex-flow: row wrap;
justify-content: flex-start;
}
.node {
align-items: flex-start;
color: var(--theme-status-active-strong);
display: flex;
flex-direction: column;
margin-bottom: 20px;
margin-right: 30px;

.node {
align-items: flex-start;
color: var(--theme-status-active-strong);
.nodeName {
display: inline-block;
font-size: var(--single-line-size-l);
margin-bottom: 6px;
overflow: hidden;
text-overflow: ellipsis;
text-transform: uppercase;
vertical-align: bottom;
white-space: nowrap;
}
.nodeCluster {
align-items: center;
border: 2px solid var(--theme-status-active-strong);
box-sizing: border-box;
display: flex;
flex-direction: column;
margin-bottom: 20px;
margin-right: 30px;
justify-content: space-around;
padding: 6px;

.nodeName {
display: inline-block;
font-size: var(--single-line-size-l);
margin-bottom: 6px;
overflow: hidden;
text-overflow: ellipsis;
text-transform: uppercase;
vertical-align: bottom;
white-space: nowrap;
}
.nodeCluster {
align-items: center;
border: 2px solid var(--theme-status-active-strong);
box-sizing: border-box;
display: flex;
justify-content: space-around;
padding: 6px;

.nodeSlot {
background-color: var(--theme-status-inactive-weak);
height: 20px;
margin-right: 6px;
width: 6px;
.nodeSlot {
background-color: var(--theme-status-inactive-weak);
height: 20px;
margin-right: 6px;
width: 6px;

&:last-of-type {
margin-right: 0;
}
}
.singleSlot {
width: 90px;
}
.coupleSlot {
width: 42px;
}
.active {
background-color: var(--theme-status-active-strong);
&:last-of-type {
margin-right: 0;
}
}
.singleSlot {
width: 90px;
}
.coupleSlot {
width: 42px;
}
.active {
background-color: var(--theme-status-active-strong);
}
}
}
34 changes: 18 additions & 16 deletions webui/react/src/pages/ResourcePool/Topology.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import Tooltip from 'hew/Tooltip';
import { range } from 'lodash';
import React, { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';

import Section from 'components/Section';
import { Agent, Resource, SlotsRecord } from 'types';
import { Agent } from 'types';

import css from './Topology.module.scss';

interface NodeElementProps {
name: string;
resources: Resource[];
slots?: SlotsRecord;
numOfSlots: number;
}

interface Props {
nodes: Agent[];
}

const NodeElement: React.FC<PropsWithChildren<NodeElementProps>> = ({ name, slots, resources }) => {
export const NodeElement: React.FC<PropsWithChildren<NodeElementProps>> = ({
name,
numOfSlots,
}) => {
const [containerWidth, setContainerWidth] = useState(0);
const shouldTruncate = useMemo(() => name.length > 5, [name]);
const slotsContainer = useRef<HTMLSpanElement>(null);
const slotsData = useMemo(
() => (slots !== undefined ? Object.values(slots) : resources),
[slots, resources],
);
const singleSlot = slotsData.length === 1;
const coupleSlot = slotsData.length === 2;
const singleSlot = numOfSlots === 1;
const coupleSlot = numOfSlots === 2;
const styles = [css.nodeSlot];

if (singleSlot) styles.push(css.singleSlot);
Expand All @@ -47,11 +46,8 @@ const NodeElement: React.FC<PropsWithChildren<NodeElementProps>> = ({ name, slot
<span className={css.nodeName}>{name}</span>
)}
<span className={css.nodeCluster} ref={slotsContainer}>
{slotsData.map(({ container }, idx) => (
<span
className={`${styles.join(' ')} ${container ? css.active : ''}`}
key={`slot${idx}`}
/>
{range(numOfSlots).map((idx) => (
<span className={`${styles.join(' ')} ${css.active}`} key={`slot${idx}`} />
))}
</span>
</div>
Expand All @@ -63,7 +59,13 @@ const Topology: React.FC<PropsWithChildren<Props>> = ({ nodes }) => {
<Section title="Topology">
<div className={`${css.mainContainer} ${css.nodesContainer}`}>
{nodes.map(({ id, resources, slots }) => {
return <NodeElement key={id} name={id} resources={resources} slots={slots} />;
return (
<NodeElement
key={id}
name={id}
numOfSlots={(slots !== undefined ? Object.values(slots) : resources).length}
/>
);
})}
</div>
</Section>
Expand Down
16 changes: 16 additions & 0 deletions webui/react/src/pages/TrialDetails/TrialInfoBox.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,19 @@
flex-direction: column;
}
}
.dataRow {
display: flex;
justify-content: space-between;
width: 100%;

.dashline {
border-bottom: 1px dashed var(--theme-ix-border-weak);
flex-grow: 1;
margin: 4px 8px;
}
.pools {
a {
margin-left: 4px;
}
}
}
9 changes: 6 additions & 3 deletions webui/react/src/pages/TrialDetails/TrialInfoBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ConfirmationProvider } from 'hew/useConfirm';

import {} from 'stores/cluster';

import { ThemeProvider } from 'components/ThemeProvider';
import { ExperimentBase, TrialDetails } from 'types';

import TrialInfoBox from './TrialInfoBox';
Expand All @@ -12,9 +13,11 @@ vi.useFakeTimers();
const setup = (trial: TrialDetails, experiment: ExperimentBase) => {
render(
<UIProvider theme={DefaultTheme.Light}>
<ConfirmationProvider>
<TrialInfoBox experiment={experiment} trial={trial} />
</ConfirmationProvider>
<ThemeProvider>
<ConfirmationProvider>
<TrialInfoBox experiment={experiment} trial={trial} />
</ConfirmationProvider>
</ThemeProvider>
</UIProvider>,
);
};
Expand Down
Loading
Loading