Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

feat: warn on large datasets in Add Data (#3794)

Igor Dykhta8d72219cc368
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 000000000..3c902e89e
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,87 @@
+# kepler.gl Agent Instructions
+
+## Definition of done
+
+A coding task is not complete until:
+
+1. The requested behavior is implemented.
+2. Appropriate tests have been added or updated.
+3. `yarn agent:verify` passes.
+4. No unrelated files have been changed.
+5. Existing architecture and conventions are followed.
+6. For UI changes, the affected behavior has been exercised in the demo app.
+
+Never claim a task is complete if `yarn agent:verify` fails.
+
+If verification fails:
+
+- Investigate the failure.
+- Fix failures caused by the change.
+- Rerun verification.
+- Continue until it passes.
+
+If a failure appears unrelated or pre-existing:
+
+- Confirm it against the base branch if practical.
+- Report it explicitly in the PR.
+
+## Implementation
+
+Before changing code:
+
+1. Read the relevant implementation.
+2. Read nearby tests.
+3. Search for similar patterns elsewhere in kepler.gl.
+4. Prefer existing abstractions over introducing new ones.
+5. Avoid unrelated refactoring.
+
+## Testing
+
+During implementation, run targeted tests for fast feedback. `yarn agent:check` is the fast loop: Node >= 20, `tsc --noEmit`, and the Jest suite (`--watchAll=false` so it exits in a terminal).
+
+Before handing work to a human, always run:
+
+```bash
+yarn agent:verify
+```
+
+`agent:verify` is the blocking Node.js CI gates that pass on a clean tree:
+
+- `yarn check-circular-deps`
+- `yarn typescript`
+- Jest (`yarn test-jest --watchAll=false`)
+- Tape (`yarn test-fast`: node tests and jsdom browser tests)
+- `yarn test:sqlrooms`
+
+Run both commands from the repository root on Node >= 20 (Volta pin 20.19.3, the same as Node.js CI).
+
+Node.js CI runs those Jest and Tape tests as `xvfb-run yarn cover`. Coverage collection is what makes that step take about five minutes. There is no coverage threshold, so `agent:verify` runs the same tests without coverage.
+
+`test-fast` is the full Tape suite without the tap-spec printer. It is the slow half of the local suite, so it belongs in `agent:verify`.
+
+Leave `yarn lint` and `yarn lint:check` out of these commands. CI's lint step is `eslint --fix` because check-only mode fails on existing Prettier issues. `yarn lint` rewrites those existing issues into the working tree.
+
+For bug fixes, add a regression test whenever practical.
+
+## UI changes
+
+When behavior is visible in the UI:
+
+1. Start the demo application.
+2. Exercise the changed workflow.
+3. Check the browser console for errors.
+4. Capture screenshots showing the result where useful.
+
+## Pull requests
+
+PR descriptions must contain:
+
+- What changed
+- Why
+- Important implementation details
+- Tests added or changed
+- Verification commands and results
+- Screenshots for visual changes
+- Remaining uncertainties or decisions
+
+Do not hide uncertainty. If product or architectural judgment is required, explicitly mark it for human review.
diff --git a/package.json b/package.json
index 796b8c016..0e0a1c13a 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,8 @@
"test-jest": "jest",
"test-tape": "yarn test-node && yarn test-browser",
"test": "yarn test-jest && yarn test-tape",
+ "agent:check": "node ./scripts/assert-node-engine.js && yarn typescript && yarn test-jest --watchAll=false",
+ "agent:verify": "node ./scripts/assert-node-engine.js && yarn check-circular-deps && yarn agent:check && yarn test-fast && yarn test:sqlrooms",
"cover": "yarn cover-tape && yarn cover-jest && yarn cover-merge && yarn cover-report",
"cover-tape": "nyc --reporter=json --report-dir=tape-coverage --reporter=lcov yarn test-tape",
"cover-jest": "jest --coverage --reporter=lcov --watchAll=false",
diff --git a/scripts/assert-node-engine.js b/scripts/assert-node-engine.js
new file mode 100644
index 000000000..6fd528e2d
--- /dev/null
+++ b/scripts/assert-node-engine.js
@@ -0,0 +1,18 @@
+#!/usr/bin/env node
+
+// SPDX-License-Identifier: MIT
+// Copyright contributors to the kepler.gl project
+
+/**
+ * CI typechecks and tests on the Volta pin (Node 20). Node 18 crashes the
+ * Tape suite with ERR_REQUIRE_ESM, so the agent commands refuse it up front.
+ */
+const major = Number(process.versions.node.split('.')[0]);
+
+if (major < 20) {
+ console.error(
+ `Node ${process.versions.node} is below engines.node >=20. ` +
+ 'Node.js CI uses the Volta pin 20.19.3.'
+ );
+ process.exit(1);
+}
diff --git a/src/components/src/common/file-uploader/file-upload.tsx b/src/components/src/common/file-uploader/file-upload.tsx
index e495e299f..6454ab518 100644
--- a/src/components/src/common/file-uploader/file-upload.tsx
+++ b/src/components/src/common/file-uploader/file-upload.tsx
@@ -7,7 +7,11 @@ import {injectIntl, WrappedComponentProps} from 'react-intl';
import UploadButton from './upload-button';
import {DragNDrop, FileType} from '../icons';
import FileDrop from './file-drop';
-import UploadFileList, {UploadFileListItem} from './upload-file-list';
+import UploadFileList, {
+ countDatasetRows,
+ isLargeDatasetUpload,
+ UploadFileListItem
+} from './upload-file-list';
import {FileLoading, FileLoadingProgress} from '@kepler.gl/types';
import {GUIDES_FILE_FORMAT_DOC} from '@kepler.gl/constants';
@@ -211,7 +215,8 @@ type FileUploadProps = {
/** Parsed files held until Add Data, used if this uploader remounts. */
stagedToAdd?: Array<{
info?: {label?: string; format?: string};
- metadata?: {source?: string};
+ metadata?: {source?: string; size?: number};
+ data?: unknown;
}> | null;
/** Stage a remote URL without downloading it. Add Data runs the remote load. */
onAddRemoteDataset?: (remote: {url: string; format?: string}) => void;
@@ -247,6 +252,17 @@ function formatFileSize(size?: number): string {
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}
+function stagedByteSize(metadata?: {size?: number}): number | null {
+ return typeof metadata?.size === 'number' ? metadata.size : null;
+}
+
+function rowsForLocalFile(staged: FileUploadProps['stagedToAdd'], fileName: string): number | null {
+ const match = (staged || []).find(
+ item => item?.info?.label === fileName && !item?.metadata?.source
+ );
+ return match ? countDatasetRows(match.data) : null;
+}
+
function extensionOf(name: string): string {
const part = name.includes('.') ? name.split('.').pop() : '';
return part && part !== name ? part : '';
@@ -495,7 +511,11 @@ function FileUploadFactory() {
ext: extensionOf(name) || 'url',
status: source || intl.formatMessage({id: 'fileUploader.readyToAddNoSize'}),
percent: 1,
- isSuccess: true
+ isSuccess: true,
+ isLarge: isLargeDatasetUpload({
+ rows: countDatasetRows(item.data),
+ bytes: stagedByteSize(item.metadata)
+ })
},
key,
true
@@ -522,7 +542,13 @@ function FileUploadFactory() {
{
name: file.name,
ext: extensionOf(file.name),
- ...status
+ ...status,
+ isLarge:
+ !status.isError &&
+ isLargeDatasetUpload({
+ rows: rowsForLocalFile(stagedToAdd, file.name),
+ bytes: file.size
+ })
},
file.name,
!status.isError
diff --git a/src/components/src/common/file-uploader/upload-file-list.tsx b/src/components/src/common/file-uploader/upload-file-list.tsx
index ea0c699b0..cef3c693d 100644
--- a/src/components/src/common/file-uploader/upload-file-list.tsx
+++ b/src/components/src/common/file-uploader/upload-file-list.tsx
@@ -2,11 +2,88 @@
// Copyright contributors to the kepler.gl project
import React, {FC} from 'react';
+import {useIntl} from 'react-intl';
import styled, {keyframes} from 'styled-components';
import {media} from '@kepler.gl/styles';
+import {getApplicationConfig} from '@kepler.gl/utils';
import Checkbox from '../checkbox';
-import {FileType} from '../icons';
+import {FileType, WarningSign} from '../icons';
+import TippyTooltip from '../tippy-tooltip';
+
+function rowCountOf(record: Record<string, unknown>): number | null {
+ const arrowTable = record.arrowTable as {numRows?: number} | undefined;
+ if (typeof arrowTable?.numRows === 'number') {
+ return arrowTable.numRows;
+ }
+ if (Array.isArray(record.cols) && record.cols.length) {
+ const length = (record.cols[0] as {length?: number} | undefined)?.length;
+ if (typeof length === 'number' && length > 0) {
+ return length;
+ }
+ }
+ if (Array.isArray(record.rows)) {
+ return record.rows.length;
+ }
+ if (Array.isArray(record.allData)) {
+ return record.allData.length;
+ }
+ return null;
+}
+
+/** Row count for a parsed file, including Arrow columns and saved maps. */
+export function countDatasetRows(data: unknown, depth = 0): number | null {
+ if (!data || typeof data !== 'object' || depth > 4) {
+ return null;
+ }
+ const record = data as Record<string, unknown>;
+ const direct = rowCountOf(record);
+ if (direct != null) {
+ return direct;
+ }
+ if (record.data && record.data !== data) {
+ const nested = countDatasetRows(record.data, depth + 1);
+ if (nested != null) {
+ return nested;
+ }
+ }
+ if (Array.isArray(record.datasets)) {
+ let total = 0;
+ let known = false;
+ for (const dataset of record.datasets) {
+ const count = countDatasetRows(dataset, depth + 1);
+ if (count != null) {
+ known = true;
+ total += count;
+ }
+ }
+ return known ? total : null;
+ }
+ return null;
+}
+
+/** True when the row count or the file size reaches its configured warning cutoff. */
+export function isLargeDatasetUpload({
+ rows,
+ bytes
+}: {
+ rows?: number | null;
+ bytes?: number | null;
+} = {}): boolean {
+ const {largeDatasetWarningRows, largeDatasetWarningBytes} = getApplicationConfig();
+ if (
+ largeDatasetWarningRows !== false &&
+ typeof rows === 'number' &&
+ rows >= largeDatasetWarningRows
+ ) {
+ return true;
+ }
+ return (
+ largeDatasetWarningBytes !== false &&
+ typeof bytes === 'number' &&
+ bytes >= largeDatasetWarningBytes
+ );
+}
export type StagedDatasetRef = {
info?: {id?: string; label?: string};
@@ -36,6 +113,7 @@ export type UploadFileListItem = {
percent: number;
isError?: boolean;
isSuccess?: boolean;
+ isLarge?: boolean;
selectable?: boolean;
selected?: boolean;
selectionLabel?: string;
@@ -113,6 +191,13 @@ const CardText = styled.div`
flex: 1;
`;
+const CardNameRow = styled.div`
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+`;
+
const CardName = styled.div`
overflow: hidden;
text-overflow: ellipsis;
@@ -121,6 +206,37 @@ const CardName = styled.div`
font-weight: 500;
`;
+const LargeDatasetTooltip = styled.div`
+ max-width: 240px;
+ white-space: normal;
+ line-height: 1.4;
+`;
+
+const LargeDatasetTag = styled.button.attrs({
+ type: 'button',
+ className: 'upload-file-list__large-dataset'
+})`
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ gap: 3px;
+ height: 16px;
+ margin: 0;
+ padding: 0 5px 0 3px;
+ border: 0;
+ border-radius: 2px;
+ background: #fff4e5;
+ color: #9a5b00;
+ font-size: 10px;
+ font-weight: 600;
+ line-height: 16px;
+ cursor: help;
+
+ svg {
+ display: block;
+ }
+`;
+
const CardCheck = styled.div`
flex-shrink: 0;
display: flex;
@@ -202,6 +318,10 @@ const StatusSpinner = styled.span.attrs({
`;
const UploadFileList: FC<UploadFileListProps> = ({title, items}) => {
+ const intl = useIntl();
+ const largeDatasetLabel = intl.formatMessage({id: 'fileUploader.largeDataset'});
+ const largeDatasetWarning = intl.formatMessage({id: 'fileUploader.largeDatasetWarning'});
+
if (!items.length) {
return null;
}
@@ -219,7 +339,24 @@ const UploadFileList: FC<UploadFileListProps> = ({title, items}) => {
<FileType ext={item.ext} height="36px" fontSize="8px" />
</IconWrap>
<CardText>
- <CardName title={item.name}>{item.name}</CardName>
+ <CardNameRow>
+ <CardName title={item.name}>{item.name}</CardName>
+ {item.isLarge ? (
+ <TippyTooltip
+ placement="top"
+ isLightTheme
+ render={() => <LargeDatasetTooltip>{largeDatasetWarning}</LargeDatasetTooltip>}
+ >
+ <LargeDatasetTag
+ aria-label={largeDatasetWarning}
+ onClick={event => event.stopPropagation()}
+ >
+ <WarningSign height="12px" />
+ {largeDatasetLabel}
+ </LargeDatasetTag>
+ </TippyTooltip>
+ ) : null}
+ </CardNameRow>
<CardStatus $isError={item.isError} title={item.status}>
{item.status}
</CardStatus>
diff --git a/src/localization/src/translations/en.ts b/src/localization/src/translations/en.ts
index ab8b39c17..7244c2863 100644
--- a/src/localization/src/translations/en.ts
+++ b/src/localization/src/translations/en.ts
@@ -1073,6 +1073,9 @@ ${'```'}
dropMessage: 'Drag & Drop Your File(s) Here, {browse}, or',
toAdd: 'To add to map',
includeDataset: 'Include {name}',
+ largeDataset: 'Large',
+ largeDatasetWarning:
+ 'This dataset is large. It can run out of memory, layer creation can take a long time, and rendering can be laggy.',
readyToAdd: '{size} - Ready to add file to map',
readyToAddNoSize: 'Ready to add file to map',
loadingProgress: 'Loading ({loaded} / {total})',
diff --git a/src/processors/src/file-handler.ts b/src/processors/src/file-handler.ts
index 16a44c7ae..0c6586270 100644
--- a/src/processors/src/file-handler.ts
+++ b/src/processors/src/file-handler.ts
@@ -96,6 +96,8 @@ export type ProcessFileDataContent = {
etag?: string;
/** HTTP Last-Modified from the remote fetch, used for the next conditional refresh. */
lastModified?: string;
+ /** Original file size in bytes, kept so a remounted uploader can still warn. */
+ fileSize?: number;
/**
* When true, skip Arrow record-batch compaction. Set on intermediate
* progressive Arrow loads so each batch does not copy the growing table.
@@ -305,7 +307,8 @@ export async function* readBatch(
keplerFormat?: string,
refreshIntervalMs?: number,
etag?: string,
- lastModified?: string
+ lastModified?: string,
+ fileSize?: number
): AsyncGenerator {
let result: any = null;
const batches = <any>[];
@@ -348,6 +351,7 @@ export async function* readBatch(
}
: {}),
fileName,
+ ...(typeof fileSize === 'number' ? {fileSize} : {}),
// if dataset is CSV, data is set to the raw batches
data: result ? result : batches,
...(sourceUrl ? {sourceUrl} : {}),
@@ -437,7 +441,8 @@ export async function readFileInBatches({
keplerFormat,
refreshIntervalMs,
etag,
- lastModified
+ lastModified,
+ file.size
);
}
@@ -504,6 +509,24 @@ export async function processFileData({
const sourceUrl = content.sourceUrl;
const remoteFormat = getPersistedRemoteFormat(content.keplerFormat, content.fileName);
+ const fileSize = typeof content.fileSize === 'number' ? content.fileSize : undefined;
+ const metadata = {
+ ...(sourceUrl
+ ? {
+ source: sourceUrl,
+ ...(remoteFormat ? {sourceFormat: remoteFormat} : {}),
+ ...(typeof content.refreshIntervalMs === 'number' && content.refreshIntervalMs > 0
+ ? {refreshIntervalMs: content.refreshIntervalMs}
+ : {}),
+ ...(typeof content.etag === 'string' && content.etag ? {etag: content.etag} : {}),
+ ...(typeof content.lastModified === 'string' && content.lastModified
+ ? {lastModified: content.lastModified}
+ : {}),
+ lastFetchedAt: Date.now()
+ }
+ : {}),
+ ...(fileSize != null ? {size: fileSize} : {})
+ };
return [
...fileCache,
{
@@ -514,22 +537,7 @@ export async function processFileData({
format,
...(sourceUrl ? {type: DatasetType.EXTERNALLY_HOSTED} : {})
},
- ...(sourceUrl
- ? {
- metadata: {
- source: sourceUrl,
- ...(remoteFormat ? {sourceFormat: remoteFormat} : {}),
- ...(typeof content.refreshIntervalMs === 'number' && content.refreshIntervalMs > 0
- ? {refreshIntervalMs: content.refreshIntervalMs}
- : {}),
- ...(typeof content.etag === 'string' && content.etag ? {etag: content.etag} : {}),
- ...(typeof content.lastModified === 'string' && content.lastModified
- ? {lastModified: content.lastModified}
- : {}),
- lastFetchedAt: Date.now()
- }
- }
- : {})
+ ...(sourceUrl || fileSize != null ? {metadata} : {})
}
];
} else {
diff --git a/src/utils/src/application-config.ts b/src/utils/src/application-config.ts
index a51ac82d9..a251a14ee 100644
--- a/src/utils/src/application-config.ts
+++ b/src/utils/src/application-config.ts
@@ -277,6 +277,31 @@ export type KeplerApplicationConfig = {
*/
enableRemoteFileFormatSelector?: boolean;
+ /**
+ * Warn in the Add Data list when a dataset has at least this many rows.
+ * `false` shows no warning. The warning waits until the row count is known.
+ *
+ * @example
+ * ```
+ * initApplicationConfig({largeDatasetWarningRows: 1_000_000});
+ * initApplicationConfig({largeDatasetWarningRows: false});
+ * ```
+ */
+ largeDatasetWarningRows?: false | number;
+
+ /**
+ * Warn in the Add Data list when a file is at least this many bytes.
+ * `false` shows no file-size warning. Either this or {@link largeDatasetWarningRows}
+ * can show the same tag.
+ *
+ * @example
+ * ```
+ * initApplicationConfig({largeDatasetWarningBytes: 50 * 1024 * 1024});
+ * initApplicationConfig({largeDatasetWarningBytes: false});
+ * ```
+ */
+ largeDatasetWarningBytes?: false | number;
+
/**
* File formats Kepler may load from drag-and-drop, the file picker, and remote URLs.
* Values are format ids or extensions (`csv`, `geojson`, `kml`, `shp`, `xlsx`, `fgb`, …).
@@ -452,6 +477,10 @@ const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig> = {
enableRemoteFileFormatSelector: false,
+ largeDatasetWarningRows: 500_000,
+
+ largeDatasetWarningBytes: 1024 * 1024 * 1024,
+
acceptedFileFormats: null,
customIcons: [],
diff --git a/test/browser/components/common/file-uploader-test.js b/test/browser/components/common/file-uploader-test.js
index 3ba09dfb9..e3d10899c 100644
--- a/test/browser/components/common/file-uploader-test.js
+++ b/test/browser/components/common/file-uploader-test.js
@@ -22,6 +22,12 @@ test('Components -> FileUploader.render', t => {
t.equal(wrapper.find(FileDrop).length, 1, 'should render FileUploader');
t.equal(wrapper.find(UploadButton).length, 1, 'should render UploadButton');
+ t.ok(wrapper.text().includes('client-side application'), 'should render the privacy disclaimer');
+ t.equal(
+ wrapper.find('.file-uploader__chrome-message').length,
+ 0,
+ 'should not render a large-file footer'
+ );
t.end();
});
@@ -488,3 +494,140 @@ test('Components -> FileUpload remote URL format selector flag', t => {
initApplicationConfig({enableRemoteFileFormatSelector: false});
t.end();
});
+
+test('Components -> FileUpload large dataset tag', t => {
+ const defaultWarningConfig = {
+ largeDatasetWarningRows: 500_000,
+ largeDatasetWarningBytes: 1024 * 1024 * 1024
+ };
+ const stagedToAdd = [
+ {
+ info: {label: 'small.csv', format: 'csv'},
+ data: {rows: new Array(10)}
+ },
+ {
+ info: {label: 'rows.csv', format: 'csv'},
+ data: {rows: new Array(1000000)}
+ },
+ {
+ info: {label: 'arrow.csv', format: 'arrow'},
+ data: {rows: [], cols: [{length: 1000000}]}
+ }
+ ];
+ const mountUploader = () =>
+ mountWithTheme(
+ <IntlWrapper>
+ <FileUpload onFileUpload={() => {}} fileExtensions={['csv']} stagedToAdd={stagedToAdd} />
+ </IntlWrapper>
+ );
+ const tagFor = (wrapper, name) => {
+ const cards = wrapper.find('.file-upload-progress__message').hostNodes();
+ let count = 0;
+ for (let i = 0; i < cards.length; i++) {
+ const card = cards.at(i);
+ if (card.text().includes(name)) {
+ count += card.find('.upload-file-list__large-dataset').hostNodes().length;
+ }
+ }
+ return count;
+ };
+
+ try {
+ initApplicationConfig({largeDatasetWarningRows: false, largeDatasetWarningBytes: false});
+ let wrapper = mountUploader();
+ t.equal(
+ tagFor(wrapper, 'rows.csv'),
+ 0,
+ 'a large dataset has no warning when the flag is false'
+ );
+
+ initApplicationConfig({largeDatasetWarningRows: 1000000, largeDatasetWarningBytes: false});
+ wrapper = mountUploader();
+ t.equal(tagFor(wrapper, 'small.csv'), 0, 'a dataset under the row count has no warning tag');
+ t.equal(tagFor(wrapper, 'rows.csv'), 1, 'a dataset at the row count shows a warning tag');
+ t.equal(tagFor(wrapper, 'arrow.csv'), 1, 'an Arrow table at the row count shows a warning tag');
+ const tag = wrapper.find('.upload-file-list__large-dataset').hostNodes().at(0);
+ t.equal(tag.text(), 'Large', 'the tag labels the dataset as large');
+ t.ok(
+ tag.prop('aria-label').includes('run out of memory'),
+ 'the tag exposes the memory and performance warning'
+ );
+
+ wrapper
+ .find('.file-uploader__file-drop')
+ .at(0)
+ .simulate('drop', {
+ stopPropagation: () => {},
+ dataTransfer: {
+ types: ['Files'],
+ files: [{type: 'text/csv', name: 'heavy.csv', size: 50 * 1024 * 1024}]
+ }
+ });
+ wrapper.update();
+ t.equal(
+ tagFor(wrapper, 'heavy.csv'),
+ 0,
+ 'file size alone does not show a warning when that flag is off'
+ );
+
+ initApplicationConfig({
+ largeDatasetWarningRows: false,
+ largeDatasetWarningBytes: 50 * 1024 * 1024
+ });
+ wrapper = mountUploader();
+ t.equal(
+ tagFor(wrapper, 'rows.csv'),
+ 0,
+ 'row warnings stay off when only the file size flag is set'
+ );
+ wrapper
+ .find('.file-uploader__file-drop')
+ .at(0)
+ .simulate('drop', {
+ stopPropagation: () => {},
+ dataTransfer: {
+ types: ['Files'],
+ files: [{type: 'text/csv', name: 'heavy.csv', size: 50 * 1024 * 1024}]
+ }
+ });
+ wrapper.update();
+ t.equal(tagFor(wrapper, 'heavy.csv'), 1, 'a file at the byte count shows a warning tag');
+
+ wrapper
+ .find('.file-uploader__file-drop')
+ .at(0)
+ .simulate('drop', {
+ stopPropagation: () => {},
+ dataTransfer: {
+ types: ['Files'],
+ files: [{type: 'text/csv', name: 'tiny.csv', size: 100}]
+ }
+ });
+ wrapper.update();
+ t.equal(tagFor(wrapper, 'tiny.csv'), 0, 'a file under the byte count has no warning tag');
+
+ const remounted = mountWithTheme(
+ <IntlWrapper>
+ <FileUpload
+ onFileUpload={() => {}}
+ fileExtensions={['csv']}
+ stagedToAdd={[
+ {
+ info: {label: 'heavy.csv', format: 'csv'},
+ data: {rows: new Array(10)},
+ metadata: {size: 50 * 1024 * 1024}
+ }
+ ]}
+ />
+ </IntlWrapper>
+ );
+ t.equal(
+ tagFor(remounted, 'heavy.csv'),
+ 1,
+ 'a remounted file keeps the warning from its saved byte size'
+ );
+ } finally {
+ initApplicationConfig(defaultWarningConfig);
+ }
+ t.end();
+});
diff --git a/test/browser/file-handler-test.js b/test/browser/file-handler-test.js
index ea04c19d4..11e9c1307 100644
--- a/test/browser/file-handler-test.js
+++ b/test/browser/file-handler-test.js
@@ -49,6 +49,7 @@ test('#file-handler -> readFileInBatches.csv -> processFileData', async t => {
bytesUsed: 0,
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
fileName: 'text-data.csv',
+ fileSize: csvFile.size,
shape: 'metadata'
},
done: false
@@ -80,6 +81,7 @@ test('#file-handler -> readFileInBatches.csv -> processFileData', async t => {
cursor: 0,
data: csvWithNull,
fileName: 'text-data.csv',
+ fileSize: csvFile.size,
headers: [
'gps_data.utc_timestamp',
'gps_data.lat',
@@ -169,6 +171,7 @@ test('#file-handler -> readFileInBatches.GeoJSON FeatureCollection -> processFil
bytesUsed: 0,
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
fileName: 'text-data-1.geojson',
+ fileSize: geojsonFile.size,
shape: 'metadata'
},
done: false
@@ -203,7 +206,8 @@ test('#file-handler -> readFileInBatches.GeoJSON FeatureCollection -> processFil
bytesUsed: 0,
jsonpath: '$.features',
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
- fileName: 'text-data-1.geojson'
+ fileName: 'text-data-1.geojson',
+ fileSize: geojsonFile.size
},
done: false
};
@@ -306,6 +310,7 @@ test('#file-handler -> readFileInBatches.GeoJSON Single Feature -> processFileDa
bytesUsed: 0,
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
fileName: 'text-data-1.geojson',
+ fileSize: geojsonFile.size,
shape: 'metadata'
},
done: false
@@ -416,6 +421,7 @@ test('#file-handler -> readFileInBatches.row -> processFileData', async t => {
bytesUsed: 0,
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
fileName,
+ fileSize: rowFile.size,
shape: 'metadata'
},
done: false
@@ -550,6 +556,7 @@ test('#file-handler -> readFileInBatches.keplerMap -> processFileData', async t
bytesUsed: 0,
progress: {rowCount: 0, rowCountInBatch: 0, percent: 0},
fileName,
+ fileSize: keplerGlMap.size,
shape: 'metadata'
},
done: false
diff --git a/test/node/processors/file-handler-test.js b/test/node/processors/file-handler-test.js
index f533681b9..1e64974d7 100644
--- a/test/node/processors/file-handler-test.js
+++ b/test/node/processors/file-handler-test.js
@@ -257,6 +257,15 @@ test('#file-handler -> processFileData one-shot load does not enable polling', a
});
t.equal(local[0].info.type, undefined, 'local files are not marked externally-hosted');
t.equal(local[0].metadata, undefined, 'local files get no remote refresh metadata');
+ const sized = await processFileData({
+ content: {fileName: 'local.csv', data: rows, fileSize: 50 * 1024 * 1024},
+ fileCache: []
+ });
+ t.equal(
+ sized[0].metadata.size,
+ 50 * 1024 * 1024,
+ 'local files keep their byte size for a later warning'
+ );
const remote = await processFileData({
content: {