From d7c42a01f3cbfcf5c4d804b315fd6d5b25fca55b Mon Sep 17 00:00:00 2001 From: Dominik Haentsch Date: Wed, 14 Feb 2024 09:53:15 +0100 Subject: [PATCH] display loading error on failed refresh --- renumics/spotlight/app.py | 5 ++-- src/stores/dataset/dataset.ts | 45 ++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/renumics/spotlight/app.py b/renumics/spotlight/app.py index d39ea2ab..6ab7b28e 100644 --- a/renumics/spotlight/app.py +++ b/renumics/spotlight/app.py @@ -350,9 +350,8 @@ def update(self, config: AppConfig) -> None: self.filebrowsing_allowed = config.filebrowsing_allowed if config.dtypes is not None or config.dataset is not None: - data_source = self._data_source - assert data_source is not None - self._data_store = DataStore(data_source, self._user_dtypes) + assert self._data_source is not None + self._data_store = DataStore(self._data_source, self._user_dtypes) self._broadcast(RefreshMessage()) self._update_issues() self._update_embeddings() diff --git a/src/stores/dataset/dataset.ts b/src/stores/dataset/dataset.ts index b6b78dab..df9fa1f7 100644 --- a/src/stores/dataset/dataset.ts +++ b/src/stores/dataset/dataset.ts @@ -222,13 +222,11 @@ export const useDataset = create( try { const { uid, generationID, filename, dataframe } = await fetchTable(); - const columnStats = { full: makeColumnsStats(dataframe.columns, dataframe.data), selected: {}, filtered: {}, }; - set({ uid, generationID, @@ -303,23 +301,32 @@ export const useDataset = create( }); }, refresh: async () => { - const { uid, generationID, filename, dataframe } = await fetchTable(); - const columnStats = { - full: makeColumnsStats(dataframe.columns, dataframe.data), - selected: {}, - filtered: {}, - }; - set(() => ({ - uid, - generationID, - filename, - length: dataframe.length, - loading: false, - columns: dataframe.columns, - columnsByKey: _.keyBy(dataframe.columns, 'key'), - columnData: dataframe.data, - columnStats, - })); + try { + const { uid, generationID, filename, dataframe } = + await fetchTable(); + const columnStats = { + full: makeColumnsStats(dataframe.columns, dataframe.data), + selected: {}, + filtered: {}, + }; + set(() => ({ + uid, + generationID, + filename, + length: dataframe.length, + loading: false, + columns: dataframe.columns, + columnsByKey: _.keyBy(dataframe.columns, 'key'), + columnData: dataframe.data, + columnStats, + })); + } catch (error) { + const problem = await api.parseError(error); + set({ + loading: false, + loadingError: problem, + }); + } }, getRow: (index: number) => { const state = get();