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

Lineage UI: Add a graph depth config option #2525

Merged
merged 9 commits into from
Jun 21, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased](https://github.com/MarquezProject/marquez/compare/0.35.0...HEAD)
### Added
* UI: add an option for configuring the depth of the lineage graph [`#2525`](https://github.com/MarquezProject/marquez/pull/2525) [@jlukenoff](https://github.com/jlukenoff)
*Makes the lineage UI a bit easier to navigate especially for larger lineage graphs*

## [0.35.0](https://github.com/MarquezProject/marquez/compare/0.34.0...0.35.0) - 2023-06-13
### Added
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/bottom-bar/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const styles = (theme: Theme) => {
right: 0,
width: `calc(100% - ${DRAWER_WIDTH}px)`,
bottom: 0,
position: 'fixed'
position: 'fixed',
zIndex: theme.zIndex.appBar + 1
}
})
}
Expand Down
30 changes: 23 additions & 7 deletions web/src/components/lineage/Lineage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ import { WithStyles, createStyles, withStyles } from '@material-ui/core/styles'
import { Zoom } from '@visx/zoom'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { fetchLineage, resetLineage, setSelectedNode } from '../../store/actionCreators'
import {
fetchLineage,
resetLineage,
setLineageGraphDepth,
setSelectedNode
} from '../../store/actionCreators'
import { generateNodeId } from '../../helpers/nodes'
import { localPoint } from '@visx/event'
import DepthConfig from './components/depth-config/DepthConfig'
import Edge from './components/edge/Edge'
import MqEmpty from '../core/empty/MqEmpty'
import MqText from '../core/text/MqText'
Expand All @@ -44,6 +50,7 @@ const DOUBLE_CLICK_MAGNIFICATION = 1.1
interface StateProps {
lineage: LineageGraph
selectedNode: string
depth: number
}

interface LineageState {
Expand Down Expand Up @@ -96,24 +103,30 @@ export class Lineage extends React.Component<LineageProps, LineageState> {
this.props.fetchLineage(
this.props.match.params.nodeType.toUpperCase() as JobOrDataset,
this.props.match.params.namespace,
this.props.match.params.nodeName
this.props.match.params.nodeName,
this.props.depth
)
}
}

componentDidUpdate(prevProps: Readonly<LineageProps>) {
if (
JSON.stringify(this.props.lineage) !== JSON.stringify(prevProps.lineage) &&
(JSON.stringify(this.props.lineage) !== JSON.stringify(prevProps.lineage) ||
this.props.depth !== prevProps.depth) &&
this.props.selectedNode
) {
this.initGraph()
this.buildGraphAll(this.props.lineage.graph)
}
if (this.props.selectedNode !== prevProps.selectedNode) {
if (
this.props.selectedNode !== prevProps.selectedNode ||
this.props.depth !== prevProps.depth
) {
this.props.fetchLineage(
this.props.match.params.nodeType.toUpperCase() as JobOrDataset,
this.props.match.params.namespace,
this.props.match.params.nodeName
this.props.match.params.nodeName,
this.props.depth
)
this.getEdges()
}
Expand Down Expand Up @@ -224,6 +237,7 @@ export class Lineage extends React.Component<LineageProps, LineageState> {
</MqEmpty>
</Box>
)}
<DepthConfig depth={this.props.depth} />
{this.state.graph && (
<ParentSize>
{parent => (
Expand Down Expand Up @@ -303,15 +317,17 @@ export class Lineage extends React.Component<LineageProps, LineageState> {

const mapStateToProps = (state: IState) => ({
lineage: state.lineage.lineage,
selectedNode: state.lineage.selectedNode
selectedNode: state.lineage.selectedNode,
depth: state.lineage.depth
})

const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
bindActionCreators(
{
setSelectedNode: setSelectedNode,
fetchLineage: fetchLineage,
resetLineage: resetLineage
resetLineage: resetLineage,
setDepth: setLineageGraphDepth
},
dispatch
)
Expand Down
70 changes: 70 additions & 0 deletions web/src/components/lineage/components/depth-config/DepthConfig.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2018-2023 contributors to the Marquez project
// SPDX-License-Identifier: Apache-2.0

import * as Redux from 'redux'
import { Box, Typography } from '@material-ui/core'
import { Theme, WithStyles, createStyles, withStyles } from '@material-ui/core/styles'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { setLineageGraphDepth } from '../../../../store/actionCreators'
import React from 'react'
import TextField from '@material-ui/core/TextField'

const styles = (theme: Theme) =>
createStyles({
root: {
position: 'absolute',
display: 'flex',
justifyContent: 'space-evenly',
alignItems: 'center',
right: 0,
marginRight: '3rem',
padding: '1rem',
zIndex: theme.zIndex.appBar
},
title: {
textAlign: 'center'
},
textField: {
width: '4rem',
marginLeft: '0.5rem'
}
})

interface DepthConfigProps extends WithStyles<typeof styles> {
depth: number
setDepth: (depth: number) => void
}

const DepthConfig: React.FC<DepthConfigProps> = ({ classes, setDepth, depth }) => {
const i18next = require('i18next')
const GRAPH_TITLE = i18next.t('lineage.graph_depth_title')
return (
<Box className={classes.root}>
<Typography>{GRAPH_TITLE}</Typography>
<TextField
type='number'
value={depth}
onChange={e => setDepth(isNaN(parseInt(e.target.value)) ? 0 : parseInt(e.target.value))}
variant='outlined'
size='small'
aria-label={GRAPH_TITLE}
className={classes.textField}
inputProps={{
min: 0,
max: 100
}}
/>
</Box>
)
}

const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
bindActionCreators(
{
setDepth: setLineageGraphDepth
},
dispatch
)

export default connect(null, mapDispatchToProps)(withStyles(styles)(DepthConfig))
3 changes: 2 additions & 1 deletion web/src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ i18next
},
lineage: {
empty_title: 'No node selected',
empty_body: 'Try selecting a node through search or the jobs or datasets page.'
empty_body: 'Try selecting a node through search or the jobs or datasets page.',
graph_depth_title: 'Graph Depth'
},
sidenav: {
jobs: 'JOBS',
Expand Down
1 change: 1 addition & 0 deletions web/src/store/actionCreators/actionTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const RESET_EVENTS = 'RESET_EVENTS'
export const FETCH_LINEAGE = 'FETCH_LINEAGE'
export const FETCH_LINEAGE_SUCCESS = 'FETCH_LINEAGE_SUCCESS'
export const RESET_LINEAGE = 'RESET_LINEAGE'
export const SET_LINEAGE_GRAPH_DEPTH = 'SET_LINEAGE_GRAPH_DEPTH'

// search
export const FETCH_SEARCH = 'FETCH_SEARCH'
Expand Down
15 changes: 13 additions & 2 deletions web/src/store/actionCreators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,18 @@ export const setBottomBarHeight = (height: number) => ({
payload: height
})

export const fetchLineage = (nodeType: JobOrDataset, namespace: string, name: string) => ({
export const fetchLineage = (
nodeType: JobOrDataset,
namespace: string,
name: string,
depth: number
) => ({
type: actionTypes.FETCH_LINEAGE,
payload: {
nodeType,
namespace,
name
name,
depth
}
})

Expand All @@ -235,6 +241,11 @@ export const resetLineage = () => ({
type: actionTypes.RESET_LINEAGE
})

export const setLineageGraphDepth = (depth: number) => ({
type: actionTypes.SET_LINEAGE_GRAPH_DEPTH,
payload: depth
})

export const selectNamespace = (namespace: string) => ({
type: actionTypes.SELECT_NAMESPACE,
payload: namespace
Expand Down
16 changes: 13 additions & 3 deletions web/src/store/reducers/lineage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ import {
FETCH_LINEAGE_SUCCESS,
RESET_LINEAGE,
SET_BOTTOM_BAR_HEIGHT,
SET_LINEAGE_GRAPH_DEPTH,
SET_SELECTED_NODE
} from '../actionCreators/actionTypes'
import { HEADER_HEIGHT } from '../../helpers/theme'
import { LineageGraph } from '../../types/api'
import { Nullable } from '../../types/util/Nullable'
import { setBottomBarHeight, setSelectedNode } from '../actionCreators'
import { setBottomBarHeight, setLineageGraphDepth, setSelectedNode } from '../actionCreators'

export interface ILineageState {
lineage: LineageGraph
selectedNode: Nullable<string>
bottomBarHeight: number
depth: number
}

const initialState: ILineageState = {
lineage: { graph: [] },
selectedNode: null,
bottomBarHeight: (window.innerHeight - HEADER_HEIGHT) / 3
bottomBarHeight: (window.innerHeight - HEADER_HEIGHT) / 3,
depth: 5
}

type ILineageActions = ReturnType<typeof setSelectedNode> & ReturnType<typeof setBottomBarHeight>
type ILineageActions = ReturnType<typeof setSelectedNode> &
ReturnType<typeof setBottomBarHeight> &
ReturnType<typeof setLineageGraphDepth>

const DRAG_BAR_HEIGHT = 8

Expand All @@ -42,6 +47,11 @@ export default (state = initialState, action: ILineageActions) => {
Math.max(2, action.payload)
)
}
case SET_LINEAGE_GRAPH_DEPTH:
return {
...state,
depth: action.payload
}
case RESET_LINEAGE: {
return { ...state, lineage: { graph: [] } }
}
Expand Down
13 changes: 11 additions & 2 deletions web/src/store/requests/lineage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import { JobOrDataset } from '../../components/lineage/types'
import { generateNodeId } from '../../helpers/nodes'
import { genericFetchWrapper } from './index'

export const getLineage = async (nodeType: JobOrDataset, namespace: string, name: string) => {
const url = `${API_URL}/lineage/?nodeId=${generateNodeId(nodeType, namespace, name)}`
export const getLineage = async (
nodeType: JobOrDataset,
namespace: string,
name: string,
depth: number
) => {
const params = new URLSearchParams({
nodeId: generateNodeId(nodeType, namespace, name),
depth: depth.toString()
})
const url = `${API_URL}/lineage/?${params.toString()}`
return genericFetchWrapper(url, { method: 'GET' }, 'fetchLineage')
}
8 changes: 7 additions & 1 deletion web/src/store/sagas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ export function* fetchLineage() {
while (true) {
try {
const { payload } = yield take(FETCH_LINEAGE)
const result = yield call(getLineage, payload.nodeType, payload.namespace, payload.name)
const result = yield call(
getLineage,
payload.nodeType,
payload.namespace,
payload.name,
payload.depth
)
yield put(fetchLineageSuccess(result))
} catch (e) {
yield put(applicationError('Something went wrong while fetching lineage'))
Expand Down