Skip to content

Commit

Permalink
Add support for JSON highlighting (mlflow#11619)
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
  • Loading branch information
BenWilson2 authored Apr 4, 2024
1 parent b0cd952 commit b3a2ee2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('ModelVersionTable', () => {
modelName: modelName,
usingNextModelsUI: true,
modelVersions: [mockModelVersionDetailed(modelName, 1, Stages.NONE, ModelVersionStatus.READY)],
aliases: [{alias: 'champion', version: '1'}]
aliases: [{ alias: 'champion', version: '1' }],
};
renderWithProviders(<ModelVersionTable {...props} />);
expect(screen.queryByRole('columnheader', { name: 'Stage' })).not.toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type ModelVersionTableProps = {
modelEntity?: ModelEntity;
onMetadataUpdated: () => void;
usingNextModelsUI: boolean;
aliases?: ModelAliasMap
aliases?: ModelAliasMap;
};

type ModelVersionColumnDef = ColumnDef<ModelVersionInfoEntity> & {
Expand All @@ -83,7 +83,7 @@ export const ModelVersionTable = ({
modelEntity,
onMetadataUpdated,
usingNextModelsUI,
aliases
aliases,
}: ModelVersionTableProps) => {
const aliasesByVersion = useMemo(() => {
const result: Record<string, string[]> = {};
Expand All @@ -92,7 +92,7 @@ export const ModelVersionTable = ({
result[version] = [];
}
result[version].push(alias);
})
});
return result;
}, [aliases]);
const versions = useMemo(
Expand Down
4 changes: 3 additions & 1 deletion mlflow/server/js/src/shared/web-shared/snippet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter';
import python from 'react-syntax-highlighter/dist/cjs/languages/prism/python';
import json from 'react-syntax-highlighter/dist/cjs/languages/prism/json';

SyntaxHighlighter.registerLanguage('python', python);
SyntaxHighlighter.registerLanguage('json', json);

import duotoneDarkStyle from './theme/databricks-duotone-dark';
import lightStyle from './theme/databricks-light';
Expand All @@ -22,7 +24,7 @@ const themesStyles: Record<CodeSnippetTheme, any> = {
duotoneDark: duotoneDarkStyle,
};

export type CodeSnippetLanguage = 'python';
export type CodeSnippetLanguage = 'python' | 'json';

export interface CodeSnippetProps {
/**
Expand Down

0 comments on commit b3a2ee2

Please sign in to comment.