From 645adb17beb46a73e97b7ac5a35d19bfd253910b Mon Sep 17 00:00:00 2001 From: Mindaugas Date: Thu, 6 Jan 2022 12:53:45 +0200 Subject: [PATCH] Improve batch screen (#6) Reformat Batches window Add Spark submit command to Batches window --- frontend/src/pages/Batch.module.scss | 6 ++ frontend/src/pages/Batch.tsx | 83 +++++++++++++++++++++++----- frontend/src/utils/batch.ts | 3 + 3 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 frontend/src/utils/batch.ts diff --git a/frontend/src/pages/Batch.module.scss b/frontend/src/pages/Batch.module.scss index 9fbde8dc..12d97ebb 100644 --- a/frontend/src/pages/Batch.module.scss +++ b/frontend/src/pages/Batch.module.scss @@ -5,3 +5,9 @@ font-size: 12px; } } + +.noWrapTable { + td { + white-space: nowrap; + } +} diff --git a/frontend/src/pages/Batch.tsx b/frontend/src/pages/Batch.tsx index 56b649b8..7921be8a 100644 --- a/frontend/src/pages/Batch.tsx +++ b/frontend/src/pages/Batch.tsx @@ -1,10 +1,13 @@ import {Code} from '@chakra-ui/layout'; import React, {useMemo} from 'react'; import {useParams} from 'react-router'; +import {Link} from '@chakra-ui/react'; +import {ExternalLinkIcon} from '@chakra-ui/icons'; import PageHeading from '../components/PageHeading'; import {useBatchLog, useBatch} from '../hooks/batch'; import styles from './Batch.module.scss'; import {Table, Thead, Tbody, Tr, Th, Td, Box} from '@chakra-ui/react'; +import {getSparkSubmitArg} from '../utils/batch'; const Batch: React.FC = () => { const {id} = useParams<{id: string}>(); @@ -18,7 +21,7 @@ const Batch: React.FC = () => { return ( - +
@@ -26,14 +29,18 @@ const Batch: React.FC = () => { - - - - + + + + + + + + @@ -54,10 +61,6 @@ const Batch: React.FC = () => { - - - - @@ -74,13 +77,9 @@ const Batch: React.FC = () => { - - - - {Object.entries(batch.submitParams.conf).map(([name, val]) => ( - + ))} @@ -90,11 +89,65 @@ const Batch: React.FC = () => { ); }, [batch]); + const sparkSubmitStr = useMemo(() => { + if (!batch) { + return null; + } + + return ( + + spark-submit + {getSparkSubmitArg('--name', batch.submitParams.name)} + {getSparkSubmitArg('--driver-cores', batch.submitParams.driverCores.toString())} + {getSparkSubmitArg('--driver-memory', batch.submitParams.driverMemory)} + {getSparkSubmitArg('--num-executors', batch.submitParams.numExecutors.toString())} + {getSparkSubmitArg('--executor-cores', batch.submitParams.executorCores.toString())} + {getSparkSubmitArg('--executor-memory', batch.submitParams.executorMemory)} + {getSparkSubmitArg('--py-files', batch.submitParams.pyFiles.join(','))} + {getSparkSubmitArg('--archives', batch.submitParams.archives.join(','))} + {getSparkSubmitArg('--files', batch.submitParams.files.join(','))} + {getSparkSubmitArg('--jars', batch.submitParams.jars.join(','))} + {Object.entries(batch.submitParams.conf).map(([name, val]) => ( + + {' '} + --conf {name} {val} + + ))} + {' ' + batch.submitParams.file} + {' ' + batch.submitParams.args.join(' ')} + + ); + }, [batch]); + + const logsStr = useMemo(() => { + if (!logs) { + return null; + } + + if (logs.log.startsWith('http')) { + return ( + + {logs?.log} + + ); + } + + return {logs.log}; + }, [logs]); + return (
Batch {id} - {logs?.log} + + Logs: + + {logsStr} + {appInfo} + + Spark submit command: + + {sparkSubmitStr}
); }; diff --git a/frontend/src/utils/batch.ts b/frontend/src/utils/batch.ts new file mode 100644 index 00000000..4f4f90bc --- /dev/null +++ b/frontend/src/utils/batch.ts @@ -0,0 +1,3 @@ +export function getSparkSubmitArg(key: string, value: string) { + return value ? ` ${key} ${value}` : null; +}
Property
Name (--name){batch.submitParams.name}
File {batch.submitParams.file}
Args{batch.submitParams.args.join(', ')}
Name (--name){batch.submitParams.name}
Driver Cores (--driver-cores) {batch.submitParams.driverCores}Executor Memory (--executor-memory) {batch.submitParams.executorMemory}
Args{batch.submitParams.args.join(', ')}
Python files (--py-files) {batch.submitParams.pyFiles.join(', ')}Additional JARs (--jars) {batch.submitParams.jars.join(', ')}
Config (--conf)Value
{name}--conf {name} {val}