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

chore: format dashboard code #14961

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion dashboard/components/BackPressureTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function BackPressureTable({
let metrics = await getActorBackPressures()
metrics.outputBufferBlockingDuration = sortBy(
metrics.outputBufferBlockingDuration,
(m) => (m.metric.fragment_id, m.metric.downstream_fragment_id)
(m) => (m.metric.fragment_id, m.metric.downstream_fragment_id),
)
setBackPressuresMetrics(metrics)
await new Promise((resolve) => setTimeout(resolve, 5000)) // refresh every 5 secs
Expand Down
12 changes: 6 additions & 6 deletions dashboard/components/FragmentDependencyGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export default function FragmentDependencyGraph({
.attr("d", ({ points }: DagLink) => line(points))
.attr("fill", "none")
.attr("stroke-width", (d) =>
isSelected(d.source) || isSelected(d.target) ? 2 : 1
isSelected(d.source) || isSelected(d.target) ? 2 : 1,
)
.attr("stroke", (d) =>
isSelected(d.source) || isSelected(d.target)
? theme.colors.blue["500"]
: theme.colors.gray["300"]
: theme.colors.gray["300"],
)
const createEdge = (sel: Enter<EdgeSelection>) =>
sel.append("path").attr("class", "edge").call(applyEdge)
Expand All @@ -90,7 +90,7 @@ export default function FragmentDependencyGraph({
sel
.attr("transform", (d) => `translate(${d.x! + MARGIN_X}, ${d.y})`)
.attr("fill", (d) =>
isSelected(d) ? theme.colors.blue["500"] : theme.colors.gray["500"]
isSelected(d) ? theme.colors.blue["500"] : theme.colors.gray["500"],
)

const createNode = (sel: Enter<NodeSelection>) =>
Expand Down Expand Up @@ -119,7 +119,7 @@ export default function FragmentDependencyGraph({
.attr("alignment-baseline", "middle")
.attr("y", (d) => d.y!)
.attr("fill", (d) =>
isSelected(d) ? theme.colors.black["500"] : theme.colors.gray["500"]
isSelected(d) ? theme.colors.black["500"] : theme.colors.gray["500"],
)
.attr("font-weight", "600")
const createLabel = (sel: Enter<LabelSelection>) =>
Expand All @@ -141,12 +141,12 @@ export default function FragmentDependencyGraph({
.attr("x", STROKE_WIDTH)
.attr(
"height",
nodeRadius * 2 + edgeRadius * 2 - MARGIN_Y * 2 - STROKE_WIDTH * 2
nodeRadius * 2 + edgeRadius * 2 - MARGIN_Y * 2 - STROKE_WIDTH * 2,
)
.attr("width", svgWidth - STROKE_WIDTH * 2)
.attr(
"y",
(d) => d.y! - nodeRadius - edgeRadius + MARGIN_Y + STROKE_WIDTH
(d) => d.y! - nodeRadius - edgeRadius + MARGIN_Y + STROKE_WIDTH,
)
.attr("rx", 5)
.attr("fill", theme.colors.gray["500"])
Expand Down
10 changes: 5 additions & 5 deletions dashboard/components/FragmentGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type FragmentLayout = {

function treeLayoutFlip<Datum>(
root: d3.HierarchyNode<Datum>,
{ dx, dy }: { dx: number; dy: number }
{ dx, dy }: { dx: number; dy: number },
): d3.HierarchyPointNode<Datum> {
const tree = d3.tree<Datum>().nodeSize([dy, dx])

Expand All @@ -59,7 +59,7 @@ function boundBox<Datum>(
root: d3.HierarchyPointNode<Datum>,
{
margin: { top, bottom, left, right },
}: { margin: { top: number; bottom: number; left: number; right: number } }
}: { margin: { top: number; bottom: number; left: number; right: number } },
): { width: number; height: number } {
let x0 = Infinity
let x1 = -x0
Expand Down Expand Up @@ -111,7 +111,7 @@ export default function FragmentGraph({
setCurrentStreamNode(node)
onOpen()
},
[onOpen, setCurrentStreamNode]
[onOpen, setCurrentStreamNode],
)

const planNodeDependencyDagCallback = useCallback(() => {
Expand Down Expand Up @@ -148,7 +148,7 @@ export default function FragmentGraph({
return { width, height, id, ...data }
}),
fragmentDistanceX,
fragmentDistanceY
fragmentDistanceY,
)
const fragmentLayoutPosition = new Map<string, Position>()
fragmentLayout.forEach(({ id, x, y }: FragmentBoxPosition) => {
Expand Down Expand Up @@ -250,7 +250,7 @@ export default function FragmentGraph({
.attr("stroke-width", ({ id }) => (isSelected(id) ? 3 : 1))
.attr("rx", 5)
.attr("stroke", ({ id }) =>
isSelected(id) ? theme.colors.blue[500] : theme.colors.gray[500]
isSelected(id) ? theme.colors.blue[500] : theme.colors.gray[500],
)

// Stream node edges
Expand Down
14 changes: 7 additions & 7 deletions dashboard/components/RelationDependencyGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { CatalogModal, useCatalogModal } from "./CatalogModal"

function boundBox(
relationPosition: RelationPointPosition[],
nodeRadius: number
nodeRadius: number,
): {
width: number
height: number
Expand Down Expand Up @@ -73,14 +73,14 @@ export default function RelationDependencyGraph({
nodes,
layerMargin,
rowMargin,
nodeRadius
nodeRadius,
).map(
({ x, y, ...data }) =>
({
x: x + layoutMargin,
y: y + layoutMargin,
...data,
} as RelationPointPosition)
}) as RelationPointPosition,
)
const links = generateRelationEdges(layoutMap)
const { width, height } = boundBox(layoutMap, nodeRadius)
Expand Down Expand Up @@ -120,15 +120,15 @@ export default function RelationDependencyGraph({
.attr("fill", "none")
.attr("stroke-width", 1)
.attr("stroke-width", (d) =>
isSelected(d.source) || isSelected(d.target) ? 4 : 2
isSelected(d.source) || isSelected(d.target) ? 4 : 2,
)
.attr("opacity", (d) =>
isSelected(d.source) || isSelected(d.target) ? 1 : 0.5
isSelected(d.source) || isSelected(d.target) ? 1 : 0.5,
)
.attr("stroke", (d) =>
isSelected(d.source) || isSelected(d.target)
? theme.colors.blue["500"]
: theme.colors.gray["300"]
: theme.colors.gray["300"],
)

const createEdge = (sel: Enter<EdgeSelection>) =>
Expand Down Expand Up @@ -200,7 +200,7 @@ export default function RelationDependencyGraph({

typeTooltip.text(
({ relation }) =>
`${relation.name} (${relationTypeTitleCase(relation)})`
`${relation.name} (${relationTypeTitleCase(relation)})`,
)

// Relation modal
Expand Down
2 changes: 1 addition & 1 deletion dashboard/components/Relations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const streamingJobColumns = [dependentsColumn, fragmentsColumn]
export function Relations<R extends Relation>(
title: string,
getRelations: () => Promise<R[]>,
extraColumns: Column<R>[]
extraColumns: Column<R>[],
) {
const { response: relationList } = useFetch(getRelations)
const [modalData, setModalId] = useCatalogModal(relationList)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/hook/useErrorToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ export default function useErrorToast() {
isClosable: true,
})
},
[toast]
[toast],
)
}
2 changes: 1 addition & 1 deletion dashboard/lib/algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function treeBfs(root: GraphNode, step: GraphTraverseStep) {
export function graphBfs(
root: GraphNode,
step: GraphTraverseStep,
neighborListKey?: string
neighborListKey?: string,
) {
let key = (neighborListKey || "nextNodes") as keyof typeof root
let visitedNodes = new Set()
Expand Down
36 changes: 16 additions & 20 deletions dashboard/lib/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ import { Relation } from "../pages/api/streaming"
import { TableFragments_Fragment } from "../proto/gen/meta"
import { GraphNode } from "./algo"

export type Enter<Type> = Type extends d3.Selection<
any,
infer B,
infer C,
infer D
>
? d3.Selection<d3.EnterElement, B, C, D>
: never
export type Enter<Type> =
Type extends d3.Selection<any, infer B, infer C, infer D>
? d3.Selection<d3.EnterElement, B, C, D>
: never

interface DagNode {
node: GraphNode
Expand Down Expand Up @@ -164,7 +160,7 @@ function dagLayout(nodes: GraphNode[]) {
isStraightLineOccupied(
node2Layer.get(node),
node2Layer.get(nextNode),
++r
++r,
)
) {}
putNodeInPosition(node, r)
Expand All @@ -189,7 +185,7 @@ function dagLayout(nodes: GraphNode[]) {
!isStraightLineOccupied(
node2Layer.get(node) + 1,
node2Layer.get(nextNode),
r
r,
)
) {
putNodeInPosition(nextNode, r)
Expand All @@ -202,7 +198,7 @@ function dagLayout(nodes: GraphNode[]) {
isStraightLineOccupied(
node2Layer.get(node) + 1,
node2Layer.get(nextNode),
++r
++r,
)
) {}
putNodeInPosition(nextNode, r)
Expand All @@ -224,7 +220,7 @@ function dagLayout(nodes: GraphNode[]) {
* @returns Layer and row of the item
*/
function gridLayout<I extends LayoutItemBase>(
items: Array<I>
items: Array<I>,
): Map<I, [number, number]> {
// turn item to GraphNode
let idToItem = new Map<String, I>()
Expand Down Expand Up @@ -318,7 +314,7 @@ export interface Edge {
export function layoutItem<I extends LayoutItemBase>(
items: Array<I>,
layerMargin: number,
rowMargin: number
rowMargin: number,
): (I & Position)[] {
let layoutMap = gridLayout(items)
let layerRequiredWidth = new Map<number, number>()
Expand Down Expand Up @@ -350,7 +346,7 @@ export function layoutItem<I extends LayoutItemBase>(
index: number,
margin: number,
resultMap: Map<number, number>,
marginMap: Map<number, number>
marginMap: Map<number, number>,
): number => {
let rtn = resultMap.get(index)
if (rtn) {
Expand All @@ -377,7 +373,7 @@ export function layoutItem<I extends LayoutItemBase>(
i,
layerMargin,
layerCumulativeWidth,
layerRequiredWidth
layerRequiredWidth,
)
}
for (let i = 0; i <= maxRow; ++i) {
Expand Down Expand Up @@ -406,7 +402,7 @@ function layoutRelation(
relations: Array<RelationPoint>,
layerMargin: number,
rowMargin: number,
nodeRadius: number
nodeRadius: number,
): RelationPointPosition[] {
const result = layoutItem(relations, layerMargin, rowMargin)
return result.map(({ x, y, ...data }) => ({
Expand All @@ -420,13 +416,13 @@ export function flipLayoutRelation(
relations: Array<RelationPoint>,
layerMargin: number,
rowMargin: number,
nodeRadius: number
nodeRadius: number,
): RelationPointPosition[] {
const fragmentPosition = layoutRelation(
relations,
rowMargin,
layerMargin,
nodeRadius
nodeRadius,
)
return fragmentPosition.map(({ x, y, ...data }) => ({
x: y,
Expand All @@ -436,7 +432,7 @@ export function flipLayoutRelation(
}

export function generateRelationEdges(
layoutMap: RelationPointPosition[]
layoutMap: RelationPointPosition[],
): Edge[] {
const links = []
const relationMap = new Map<string, RelationPointPosition>()
Expand All @@ -460,7 +456,7 @@ export function generateRelationEdges(
}

export function generateFragmentEdges(
layoutMap: FragmentBoxPosition[]
layoutMap: FragmentBoxPosition[],
): Edge[] {
const links = []
const fragmentMap = new Map<string, FragmentBoxPosition>()
Expand Down
2 changes: 1 addition & 1 deletion dashboard/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
output: "export",
trailingSlash: true,
}

Expand Down
4 changes: 2 additions & 2 deletions dashboard/pages/api/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export async function getClusterMetrics() {

export async function getClusterInfoFrontend() {
const res: WorkerNode[] = (await api.get("/clusters/1")).map(
WorkerNode.fromJSON
WorkerNode.fromJSON,
)
return res
}

export async function getClusterInfoComputeNode() {
const res: WorkerNode[] = (await api.get("/clusters/2")).map(
WorkerNode.fromJSON
WorkerNode.fromJSON,
)
return res
}
2 changes: 1 addition & 1 deletion dashboard/pages/api/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import useErrorToast from "../../hook/useErrorToast"
export default function useFetch<T>(
fetchFn: () => Promise<T>,
intervalMs: number | null = null,
when: boolean = true
when: boolean = true,
) {
const [response, setResponse] = useState<T>()
const toast = useErrorToast()
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/api/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface BackPressuresMetrics {

export async function getActorBackPressures() {
const res: BackPressuresMetrics = await api.get(
"/metrics/actor/back_pressures"
"/metrics/actor/back_pressures",
)
return res
}
Expand Down
8 changes: 4 additions & 4 deletions dashboard/pages/api/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function getActors(): Promise<ActorLocation[]> {

export async function getFragments(): Promise<TableFragments[]> {
let fragmentList: TableFragments[] = (await api.get("/fragments2")).map(
TableFragments.fromJSON
TableFragments.fromJSON,
)
fragmentList = sortBy(fragmentList, (x) => x.tableId)
return fragmentList
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function getStreamingJobs() {
await getMaterializedViews(),
await getTables(),
await getIndexes(),
await getSinks()
await getSinks(),
)
jobs = sortBy(jobs, (x) => x.id)
return jobs
Expand All @@ -84,14 +84,14 @@ export async function getRelations() {
await getTables(),
await getIndexes(),
await getSinks(),
await getSources()
await getSources(),
)
relations = sortBy(relations, (x) => x.id)
return relations
}

async function getTableCatalogsInner(
path: "tables" | "materialized_views" | "indexes" | "internal_tables"
path: "tables" | "materialized_views" | "indexes" | "internal_tables",
) {
let list: Table[] = (await api.get(`/${path}`)).map(Table.fromJSON)
list = sortBy(list, (x) => x.id)
Expand Down
2 changes: 1 addition & 1 deletion dashboard/pages/await_tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function AwaitTreeDump() {

try {
const response: StackTraceResponse = StackTraceResponse.fromJSON(
await api.get(`/monitor/await_tree/${computeNodeId}`)
await api.get(`/monitor/await_tree/${computeNodeId}`),
)

const actorTraces = _(response.actorTraces)
Expand Down
Loading
Loading