Skip to content

Commit

Permalink
Improve batch screen (#6)
Browse files Browse the repository at this point in the history
Reformat Batches window
Add Spark submit command to Batches window
  • Loading branch information
Minutis authored Jan 6, 2022
1 parent 3a443e4 commit 645adb1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 15 deletions.
6 changes: 6 additions & 0 deletions frontend/src/pages/Batch.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
font-size: 12px;
}
}

.noWrapTable {
td {
white-space: nowrap;
}
}
83 changes: 68 additions & 15 deletions frontend/src/pages/Batch.tsx
Original file line number Diff line number Diff line change
@@ -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}>();
Expand All @@ -18,22 +21,26 @@ const Batch: React.FC = () => {

return (
<Box mt="5">
<Table variant="simple" size="sm">
<Table className={styles.noWrapTable} variant="simple" size="sm">
<Thead>
<Tr>
<Th>Property</Th>
<Th>Value</Th>
</Tr>
</Thead>
<Tbody>
<Tr>
<Td>Name (--name)</Td>
<Td>{batch.submitParams.name}</Td>
</Tr>
<Tr>
<Td>File</Td>
<Td>{batch.submitParams.file}</Td>
</Tr>
<Tr>
<Td>Args</Td>
<Td>{batch.submitParams.args.join(', ')}</Td>
</Tr>
<Tr>
<Td>Name (--name)</Td>
<Td>{batch.submitParams.name}</Td>
</Tr>
<Tr>
<Td>Driver Cores (--driver-cores)</Td>
<Td>{batch.submitParams.driverCores}</Td>
Expand All @@ -54,10 +61,6 @@ const Batch: React.FC = () => {
<Td>Executor Memory (--executor-memory)</Td>
<Td>{batch.submitParams.executorMemory}</Td>
</Tr>
<Tr>
<Td>Args</Td>
<Td>{batch.submitParams.args.join(', ')}</Td>
</Tr>
<Tr>
<Td>Python files (--py-files)</Td>
<Td>{batch.submitParams.pyFiles.join(', ')}</Td>
Expand All @@ -74,13 +77,9 @@ const Batch: React.FC = () => {
<Td>Additional JARs (--jars)</Td>
<Td>{batch.submitParams.jars.join(', ')}</Td>
</Tr>
<Tr>
<Th>Config (--conf)</Th>
<Th>Value</Th>
</Tr>
{Object.entries(batch.submitParams.conf).map(([name, val]) => (
<Tr key={name}>
<Td>{name}</Td>
<Td>--conf {name}</Td>
<Td>{val}</Td>
</Tr>
))}
Expand All @@ -90,11 +89,65 @@ const Batch: React.FC = () => {
);
}, [batch]);

const sparkSubmitStr = useMemo(() => {
if (!batch) {
return null;
}

return (
<Code className={styles.logs}>
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]) => (
<span key={name}>
{' '}
--conf {name} {val}
</span>
))}
{' ' + batch.submitParams.file}
{' ' + batch.submitParams.args.join(' ')}
</Code>
);
}, [batch]);

const logsStr = useMemo(() => {
if (!logs) {
return null;
}

if (logs.log.startsWith('http')) {
return (
<Link href={logs.log} isExternal>
{logs?.log} <ExternalLinkIcon mx="2px" marginBottom="5px" />
</Link>
);
}

return <Code className={styles.logs}>{logs.log}</Code>;
}, [logs]);

return (
<div className={styles.batch}>
<PageHeading>Batch {id}</PageHeading>
<Code className={styles.logs}>{logs?.log}</Code>
<Box textStyle="caption" mt="5">
Logs:
</Box>
<Box mt="1">{logsStr}</Box>

{appInfo}
<Box textStyle="caption" mt="5">
Spark submit command:
</Box>
<Box mt="1">{sparkSubmitStr}</Box>
</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils/batch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getSparkSubmitArg(key: string, value: string) {
return value ? ` ${key} ${value}` : null;
}

0 comments on commit 645adb1

Please sign in to comment.