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

Ray Dashboard Serve page polish #46811

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export type LogVirtualViewProps = {
};

type LogLineDetailDialogProps = {
formattedLogLine: string;
message?: string;
formattedLogLine: string | null;
message: string;
onClose: () => void;
};

Expand All @@ -119,41 +119,45 @@ const LogLineDetailDialog = ({
width: "100%",
}}
>
{formattedLogLine !== null && (
<React.Fragment>
<Typography
variant="h5"
sx={{
marginBottom: 2,
}}
>
Raw log line
</Typography>
<Box
sx={(theme) => ({
padding: 1,
bgcolor: "#EEEEEE",
borderRadius: 1,
border: `1px solid ${theme.palette.divider}`,
marginBottom: 2,
})}
>
<Typography
component="pre"
variant="body2"
sx={{
whiteSpace: "pre",
overflow: "auto",
height: "300px",
}}
data-testid="raw-log-line"
>
{formattedLogLine}
</Typography>
</Box>
</React.Fragment>
)}
<Typography
variant="h5"
sx={{
marginBottom: 2,
}}
>
Raw log line
</Typography>
<Box
sx={(theme) => ({
padding: 1,
bgcolor: "#EEEEEE",
borderRadius: 1,
border: `1px solid ${theme.palette.divider}`,
})}
>
<Typography
component="pre"
variant="body2"
sx={{
whiteSpace: "pre",
overflow: "auto",
height: "300px",
}}
data-testid="raw-log-line"
>
{formattedLogLine}
</Typography>
</Box>
<Typography
variant="h5"
sx={{
marginTop: 2,
marginBottom: 2,
}}
>
Formatted message
</Typography>
Expand Down Expand Up @@ -209,9 +213,9 @@ const LogVirtualView: React.FC<LogVirtualViewProps> = ({
listRef.current = outter.current;
}
const [selectedLogLine, setSelectedLogLine] =
useState<[string, string | undefined]>();
useState<[string | null, string]>();
const handleLogLineClick = useCallback(
(logLine: string, message?: string) => {
(logLine: string | null, message: string) => {
setSelectedLogLine([logLine, message]);
},
[],
Expand All @@ -221,7 +225,7 @@ const LogVirtualView: React.FC<LogVirtualViewProps> = ({
const { i, origin } = logs[revert ? logs.length - 1 - index : index];

let message = origin;
let formattedLogLine = origin;
let formattedLogLine: string | null = null;
try {
const parsedOrigin = JSON.parse(origin);
// Iff the parsed origin has a message field, use it as the message.
Expand All @@ -238,7 +242,9 @@ const LogVirtualView: React.FC<LogVirtualViewProps> = ({
}
formattedLogLine = JSON.stringify(parsedOrigin, null, 2);
} catch (e) {
// Keep the `origin` as message and formattedLogLine, if json parsing failed.
// Keep the `origin` as message, if json parsing failed.
// If formattedLogLine is null, then the log line is not JSON and we will
// not show the raw json dialog pop up.
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const ServeDeploymentsListPage = () => {
controller={serveDetails.controller_info}
proxies={proxies}
deployments={serveDeployments}
showDeploymentName
/>
</CollapsibleSection>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ServeEntityLogsProps = {
controller?: ServeSystemActor;
proxies?: ServeSystemActor[];
deployments: ServeDeployment[];
showDeploymentName?: boolean;
};

/**
Expand All @@ -28,6 +29,7 @@ export const ServeEntityLogViewer = ({
controller,
proxies,
deployments,
showDeploymentName = false,
}: ServeEntityLogsProps) => {
const [params, setParams] = useSearchParams();

Expand All @@ -48,23 +50,37 @@ export const ServeEntityLogViewer = ({
({ actor_id }) => actor_id === selectedProxyId,
);

const allReplicas = deployments.flatMap(({ replicas }) => replicas);
const allReplicas = deployments.flatMap(
({ name: deploymentName, replicas }) =>
replicas.map((replica) => ({
...replica,
name: showDeploymentName
? `${deploymentName}#${replica.replica_id}`
: replica.replica_id,
})),
);

const selectedReplicaId =
params.get("replicaId") || allReplicas[0]?.replica_id || undefined;

// Effect to update URL params to initial values if they are not set
useEffect(() => {
let paramsModified = false;
if (!params.get("entityGroup") && showEntityGroups) {
params.set("entityGroup", defaultEntityGroupName);
paramsModified = true;
}
if (!params.get("proxyId") && selectedProxyId) {
params.set("proxyId", selectedProxyId);
paramsModified = true;
}
if (!params.get("replicaId") && selectedReplicaId) {
params.set("replicaId", selectedReplicaId);
paramsModified = true;
}
if (paramsModified) {
setParams(params, { replace: true });
}
setParams(params, { replace: true });
}, [
params,
setParams,
Expand All @@ -80,13 +96,18 @@ export const ServeEntityLogViewer = ({

// Detect if replicaId or http proxy does not exist. If not, reset the selected log.
useEffect(() => {
let paramsModified = false;
if (selectedProxyId && !selectedProxy) {
params.delete("proxyId");
paramsModified = true;
}
if (selectedReplicaId && !selectedReplica) {
params.delete("replicaId");
paramsModified = true;
}
if (paramsModified) {
setParams(params, { replace: true });
}
setParams(params, { replace: true });
}, [
params,
setParams,
Expand Down Expand Up @@ -272,9 +293,9 @@ export const ServeEntityLogViewer = ({
);
}}
>
{allReplicas.map(({ replica_id }) => (
{allReplicas.map(({ replica_id, name }) => (
<MenuItem key={replica_id} value={replica_id}>
{replica_id}
{name}
</MenuItem>
))}
</TextField>
Expand Down