Skip to content

Commit

Permalink
fix: handle null LiteralMap in RemoteLiteralMapViewer
Browse files Browse the repository at this point in the history
flyteidl generated JS code uses null as a default value for non-primitive
objects.
  • Loading branch information
kanterov committed Nov 10, 2020
1 parent d6a35b3 commit 4ef0ead
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ describe('RelaunchExecutionForm', () => {
task = createMockTask('MyTask');
executionData = {
inputs: { url: 'http://somePath', bytes: long(1000) },
outputs: {}
outputs: {},
fullInputs: null,
fullOutputs: null
};

mockGetWorkflow = jest.fn().mockResolvedValue(workflow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ const nodeRetryAttempts = {

const apiContext = mockAPIContextValue({
getExecution: () => Promise.resolve(workflowExecution),
getNodeExecutionData: () => Promise.resolve({ inputs: {}, outputs: {} }),
getNodeExecutionData: () =>
Promise.resolve({
inputs: {},
outputs: {},
fullInputs: null,
fullOutputs: null
}),
listTaskExecutions: nodeExecutionId => {
const length = nodeRetryAttempts[nodeExecutionId.nodeId] || 1;
const entities = Array.from({ length }, (_, retryAttempt) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const generateMocks = (variables: Record<string, Variable>) => {

const mockExecutionData: ExecutionData = {
inputs: { url: 'inputsUrl', bytes: Long.fromNumber(1000) },
outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) }
outputs: { url: 'outputsUrl', bytes: Long.fromNumber(1000) },
fullInputs: null,
fullOutputs: null
};

const mockExecutionInputs: LiteralMap = Object.keys(
Expand Down
4 changes: 2 additions & 2 deletions src/components/Literals/RemoteLiteralMapViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BlobTooLarge: React.FC<{ url: string }> = ({ url }) => (
*/
export const RemoteLiteralMapViewer: React.FC<{
blob: UrlBlob;
map?: LiteralMap;
map: LiteralMap | null;
}> = ({ blob, map }) => {
if (!blob.url || !blob.bytes) {
return (
Expand All @@ -38,7 +38,7 @@ export const RemoteLiteralMapViewer: React.FC<{
);
}

if (map !== undefined) {
if (map != null) {
return <LiteralMapViewer map={map} />;
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/Literals/test/RemoteLiteralMapViewer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('RemoteLiteralMapViewer', () => {
};

const { getAllByText } = render(
<RemoteLiteralMapViewer map={undefined} blob={blob} />
<RemoteLiteralMapViewer map={null} blob={blob} />
);

const items = getAllByText('No data is available.');
Expand All @@ -45,7 +45,7 @@ describe('RemoteLiteralMapViewer', () => {
expect(items.length).toBe(1);
});

it('fetches blob if map is undefined', () => {
it('fetches blob if map is null', () => {
const map: LiteralMap = {
literals: {
input1: {}
Expand All @@ -65,7 +65,7 @@ describe('RemoteLiteralMapViewer', () => {
};

const { getAllByText } = render(
<RemoteLiteralMapViewer map={undefined} blob={blob} />
<RemoteLiteralMapViewer map={null} blob={blob} />
);

const items = getAllByText('input1:');
Expand Down
4 changes: 3 additions & 1 deletion src/models/Execution/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ export const getExecution = (

const emptyExecutionData: ExecutionData = {
inputs: {},
outputs: {}
outputs: {},
fullInputs: null,
fullOutputs: null
};
/** Fetches data URLs for an `Execution` record */
export const getExecutionData = (
Expand Down
4 changes: 2 additions & 2 deletions src/models/Execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ export interface TaskExecutionClosure extends Admin.ITaskExecutionClosure {
export interface ExecutionData {
inputs: UrlBlob;
outputs: UrlBlob;
fullInputs?: LiteralMap;
fullOutputs?: LiteralMap;
fullInputs: LiteralMap | null;
fullOutputs: LiteralMap | null;
}

0 comments on commit 4ef0ead

Please sign in to comment.