mirror of
https://github.com/wassname/ray.git
synced 2026-07-05 10:34:05 +08:00
[dashboard] Pipe resource assignments to dashboard (#8998)
This commit is contained in:
@@ -133,9 +133,18 @@ export type NodeInfoResponse = {
|
||||
|
||||
export const getNodeInfo = () => get<NodeInfoResponse>("/api/node_info", {});
|
||||
|
||||
export type ResourceSlot = {
|
||||
slot: number;
|
||||
allocation: number;
|
||||
};
|
||||
|
||||
export type ResourceAllocations = {
|
||||
resourceSlots: ResourceSlot[];
|
||||
};
|
||||
|
||||
export type RayletCoreWorkerStats = {
|
||||
usedResources: {
|
||||
[key: string]: number;
|
||||
[key: string]: ResourceAllocations;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -168,7 +177,7 @@ export type RayletActorInfo =
|
||||
taskQueueLength: number;
|
||||
timestamp: number;
|
||||
usedObjectStoreMemory: number;
|
||||
usedResources: { [key: string]: number };
|
||||
usedResources: { [key: string]: ResourceAllocations };
|
||||
currentTaskDesc?: string;
|
||||
numPendingTasks?: number;
|
||||
webuiDisplay?: Record<string, string>;
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
launchProfiling,
|
||||
RayletActorInfo,
|
||||
} from "../../../api";
|
||||
import { sum } from "../../../common/util";
|
||||
import ActorDetailsPane from "./ActorDetailsPane";
|
||||
import Actors from "./Actors";
|
||||
|
||||
@@ -137,7 +138,12 @@ class Actor extends React.Component<Props & WithStyles<typeof styles>, State> {
|
||||
Object.entries(actor.usedResources).length > 0 &&
|
||||
Object.entries(actor.usedResources)
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.map(([key, value]) => `${value.toLocaleString()} ${key}`)
|
||||
.map(
|
||||
([key, value]) =>
|
||||
`${sum(
|
||||
value.resourceSlots.map((slot) => slot.allocation),
|
||||
)} ${key}`,
|
||||
)
|
||||
.join(", "),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -63,13 +63,22 @@ export const NodeGPU: NodeFeatureComponent = ({ node }) => {
|
||||
|
||||
export const WorkerGPU: WorkerFeatureComponent = ({ rayletWorker }) => {
|
||||
const workerRes = rayletWorker?.coreWorkerStats.usedResources;
|
||||
const workerUsedGPUResources = workerRes?.["GPU"] || NaN;
|
||||
const message = isNaN(workerUsedGPUResources) ? (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
N/A
|
||||
</Typography>
|
||||
) : (
|
||||
<b>`${workerUsedGPUResources} GPUs in use`</b>
|
||||
);
|
||||
const workerUsedGPUResources = workerRes?.["GPU"];
|
||||
let message;
|
||||
if (workerUsedGPUResources === undefined) {
|
||||
message = (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
N/A
|
||||
</Typography>
|
||||
);
|
||||
} else {
|
||||
const aggregateAllocation = sum(
|
||||
workerUsedGPUResources.resourceSlots.map(
|
||||
(resourceSlot) => resourceSlot.allocation,
|
||||
),
|
||||
);
|
||||
const plural = aggregateAllocation === 1 ? "" : "s";
|
||||
message = <b>{`${aggregateAllocation} GPU${plural} in use`}</b>;
|
||||
}
|
||||
return <div style={{ minWidth: 60 }}>{message}</div>;
|
||||
};
|
||||
|
||||
@@ -223,7 +223,13 @@ def test_raylet_info_endpoint(shutdown_only):
|
||||
raise Exception(
|
||||
"Timed out while waiting for dashboard to start.")
|
||||
|
||||
assert parent_actor_info["usedResources"]["CPU"] == 2
|
||||
def cpu_resources(actor_info):
|
||||
cpu_resources = 0
|
||||
for slot in actor_info["usedResources"]["CPU"]["resourceSlots"]:
|
||||
cpu_resources += slot["allocation"]
|
||||
return cpu_resources
|
||||
|
||||
assert cpu_resources(parent_actor_info) == 2
|
||||
assert parent_actor_info["numExecutedTasks"] == 4
|
||||
for _, child_actor_info in children.items():
|
||||
if child_actor_info["state"] == -1:
|
||||
@@ -231,7 +237,7 @@ def test_raylet_info_endpoint(shutdown_only):
|
||||
else:
|
||||
assert child_actor_info["state"] == 1
|
||||
assert len(child_actor_info["children"]) == 0
|
||||
assert child_actor_info["usedResources"]["CPU"] == 1
|
||||
assert cpu_resources(child_actor_info) == 1
|
||||
|
||||
profiling_id = requests.get(
|
||||
webui_url + "/api/launch_profiling",
|
||||
|
||||
Reference in New Issue
Block a user