Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lazy loading #1041

Merged
merged 34 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
dfc2d9a
loader components
Huongg Aug 26, 2022
6c121df
test: passing props around for the loader components
Huongg Aug 26, 2022
c7712c1
apply dark and light themes colours
Huongg Aug 31, 2022
03edb8c
Merge branch 'main' of github.com:kedro-org/kedro-viz into feature/la…
Huongg Aug 31, 2022
ef0991b
remove commented code
Huongg Aug 31, 2022
08e5973
apply new gradients colours
Huongg Sep 1, 2022
c7ef86a
use variables for colours
Huongg Sep 1, 2022
5c5e188
clear console error
Huongg Sep 1, 2022
60277ca
add delay timing to show loaders
Huongg Sep 1, 2022
c0531ab
adjust alignments for meta-data
Huongg Sep 2, 2022
eb02c83
adjust alignments for tracking-data
Huongg Sep 5, 2022
12101dd
Merge branch 'main' of github.com:kedro-org/kedro-viz into feature/la…
Huongg Sep 5, 2022
0621283
alignments for third run
Huongg Sep 5, 2022
fec606d
adjust the gap between loaders
Huongg Sep 5, 2022
91ea0cc
store variables in config file instead
Huongg Sep 5, 2022
153df32
fix the gap for tracking data
Huongg Sep 5, 2022
f1cfeca
update states name and comments
Huongg Sep 6, 2022
0064b09
move the small loaders component to be in loaders file
Huongg Sep 6, 2022
af9af11
removed unused props
Huongg Sep 6, 2022
f479910
move gap value to the config file
Huongg Sep 6, 2022
bd2c61a
set speed back to the default value
Huongg Sep 6, 2022
f5c2824
update value for tracking data
Huongg Sep 6, 2022
176a864
Merge branch 'main' of github.com:kedro-org/kedro-viz into feature/la…
Huongg Sep 6, 2022
83b227b
update light theme colours
Huongg Sep 6, 2022
20e38ff
remove the fading in effect in comparison mode
Huongg Sep 6, 2022
023712b
nit sorting
Huongg Sep 6, 2022
1cd17c8
update release note
Huongg Sep 6, 2022
a0e3723
Update RELEASE.md
Huongg Sep 6, 2022
f7a1231
remove colour refactoring from the release note
Huongg Sep 6, 2022
8173519
increase the time to 500 for testing on gitpod
Huongg Sep 6, 2022
9adfe50
add the sliding animation back in
Huongg Sep 6, 2022
370e92a
add max-height for metadata and viewbox for tracking data to prevent …
Huongg Sep 6, 2022
c1a4e47
update delay timing to 200
Huongg Sep 6, 2022
a31faa7
use colour variables from variables file
Huongg Sep 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Please follow the established format:

- Upgrade to `dart-scss` and update the recommended Node version to v16. (#1026)
- Fix the export functionality of experiment tracking data. (#1033)
- Color cleanup and refactor. (#1007)
- Add lazy loading to experiment tracking. (#1041)
# Release 5.0.1

## Bug fixes and other changes
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"lodash.noop": "^3.0.1",
"lodash.sortby": "^4.7.0",
"plotly.js-dist-min": "^1.58.4",
"react-content-loader": "^6.2.0",
"react-csv": "^2.2.2",
"react-custom-scrollbars": "^4.2.1",
"react-json-view": "^1.21.3",
Expand Down
50 changes: 49 additions & 1 deletion src/components/experiment-tracking/details/details.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useEffect, useState } from 'react';
import classnames from 'classnames';
import RunMetadata from '../run-metadata';
import { SingleRunMetadataLoader } from '../run-metadata/run-metadata-loader';
import RunDataset from '../run-dataset';
import { SingleRunDatasetLoader } from '../run-dataset/run-dataset-loader';
import RunDetailsModal from '../run-details-modal';
import RunPlotsModal from '../run-plots-modal';
import RunExportModal from '../run-export-modal';
Expand All @@ -12,9 +14,11 @@ import './details.css';
const Details = ({
enableComparisonView,
enableShowChanges,
runDataError,
isRunDataLoading,
newRunAdded,
onRunSelection,
pinnedRun,
runDataError,
runMetadata,
runTrackingData,
selectedRunIds,
Expand All @@ -30,6 +34,33 @@ const Details = ({
}) => {
const [runMetadataToEdit, setRunMetadataToEdit] = useState(null);
const [runDatasetToShow, setRunDatasetToShow] = useState({});
const [showSingleRunLoader, setShowSingleRunLoader] = useState(false);
const [showRunLoader, setRunLoader] = useState(false);

// delay showing loader for 0.2s so it has enough time to load the data first
useEffect(() => {
// for single run
if (isRunDataLoading && !enableComparisonView) {
const showSingleRunLoaderTimer = setTimeout(() => {
setShowSingleRunLoader(true);
}, 200);

return () => clearTimeout(showSingleRunLoaderTimer);
} else {
setShowSingleRunLoader(false);
}

// for multiple runs when the comparison mode is active
if (isRunDataLoading && newRunAdded) {
const showRunLoaderTimer = setTimeout(() => {
setRunLoader(true);
}, 200);

return () => clearTimeout(showRunLoaderTimer);
} else {
setRunLoader(false);
}
}, [isRunDataLoading, newRunAdded, enableComparisonView]);

useEffect(() => {
if (runMetadata && !enableComparisonView) {
Expand All @@ -45,6 +76,19 @@ const Details = ({
return null;
}

if (showSingleRunLoader) {
return (
<div
className={classnames('kedro', 'details-mainframe', {
'details-mainframe--sidebar-visible': sidebarVisible,
})}
>
<SingleRunMetadataLoader theme={theme} />
<SingleRunDatasetLoader theme={theme} />
</div>
);
}

return (
<>
<ButtonTimeoutContextProvider>
Expand Down Expand Up @@ -84,6 +128,8 @@ const Details = ({
setPinnedRun={setPinnedRun}
setRunMetadataToEdit={setRunMetadataToEdit}
setShowRunDetailsModal={setShowRunDetailsModal}
showLoader={showRunLoader}
theme={theme}
/>
<RunDataset
enableComparisonView={enableComparisonView}
Expand All @@ -92,7 +138,9 @@ const Details = ({
pinnedRun={pinnedRun}
setRunDatasetToShow={setRunDatasetToShow}
setShowRunPlotsModal={setShowRunPlotsModal}
showLoader={showRunLoader}
trackingData={runTrackingData}
theme={theme}
/>
</div>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import ContentLoader from 'react-content-loader';
import {
experimentTrackingLazyLoadingColours,
experimentTrackingLazyLoadingGap,
} from '../../../config';

import './run-dataset.css';

const GAP = experimentTrackingLazyLoadingGap;

const SubCatLoader = ({ y }) => (
<>
<rect width="10" height="10" x="0" y={y + 3} />
<rect width="100" height="20" x="30" y={y} />
</>
);

const TitleLoader = ({ y }) => (
<>
<rect width="10" height="10" x="0" y={y + 3} />
<rect width="180" height="20" x="30" y={y} />
<rect width="50" height="16" x="0" y={y + GAP} />
<rect width="100" height="16" x="0" y={y + GAP * 2} />
</>
);

const DetailsLoader = ({ x, y }) => {
return (
<>
<rect width="0" height="0" x={x} y={y} />
<rect width="50" height="16" x={x} y={y + GAP} />
<rect width="180" height="16" x={x} y={y + GAP * 2} />
</>
);
};

export const SingleRunDatasetLoader = ({ theme }) => (
<div className="details-dataset">
<ContentLoader
viewBox="0 0 1000 625"
width="1000px"
height="100%"
backgroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.backgroundDarkTheme
: experimentTrackingLazyLoadingColours.backgroundLightTheme
}
foregroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.foregroundDarkTheme
: experimentTrackingLazyLoadingColours.foregroundLightTheme
}
>
<SubCatLoader y={0} />

<TitleLoader y={50} />
<DetailsLoader x={380} y={50} />

<TitleLoader y={185} />
<DetailsLoader x={380} y={185} />

<TitleLoader y={320} />
<DetailsLoader x={380} y={320} />
</ContentLoader>
</div>
);

export const DataSetLoader = ({ x, y, length, theme }) => {
return (
<ContentLoader
viewBox="0 10 200 30"
width="180px"
height="100%"
backgroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.backgroundDarkTheme
: experimentTrackingLazyLoadingColours.backgroundLightTheme
}
foregroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.foregroundDarkTheme
: experimentTrackingLazyLoadingColours.foregroundLightTheme
}
>
<rect width="150" height="16" x={x} y={y + length * 2} />
</ContentLoader>
);
};
28 changes: 25 additions & 3 deletions src/components/experiment-tracking/run-dataset/run-dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PinArrowIcon from '../../icons/pin-arrow';
import PlotlyChart from '../../plotly-chart';
import { sanitizeValue } from '../../../utils/experiment-tracking-utils';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
import { DataSetLoader } from './run-dataset-loader';

import getShortType from '../../../utils/short-type';
import './run-dataset.css';
Expand Down Expand Up @@ -49,7 +50,9 @@ const RunDataset = ({
pinnedRun,
setRunDatasetToShow,
setShowRunPlotsModal,
showLoader,
trackingData,
theme,
}) => {
if (!trackingData) {
return null;
Expand All @@ -76,7 +79,6 @@ const RunDataset = ({
>
{trackingData[group].map((dataset) => {
const { data, datasetType, datasetName, runIds } = dataset;

return (
<Accordion
className="details-dataset__accordion"
Expand Down Expand Up @@ -109,7 +111,9 @@ const RunDataset = ({
enableComparisonView,
enableShowChanges,
setRunDatasetToShow,
setShowRunPlotsModal
setShowRunPlotsModal,
showLoader,
theme
);
})}
</Accordion>
Expand Down Expand Up @@ -142,7 +146,9 @@ function buildDatasetDataMarkup(
enableComparisonView,
enableShowChanges,
setRunDatasetToShow,
setShowRunPlotsModal
setShowRunPlotsModal,
showLoader,
theme
) {
const isPlotlyDataset = getShortType(datasetType) === 'plotly';
const isImageDataset = getShortType(datasetType) === 'image';
Expand Down Expand Up @@ -181,6 +187,14 @@ function buildDatasetDataMarkup(
</CSSTransition>
))}
</TransitionGroup>
{showLoader && (
<DataSetLoader
length={datasetValues.length}
theme={theme}
x={0}
y={12}
/>
)}
</div>
) : null}
<div className="details-dataset__row">
Expand Down Expand Up @@ -248,6 +262,14 @@ function buildDatasetDataMarkup(
);
})}
</TransitionGroup>
{showLoader && (
<DataSetLoader
length={datasetValues.length}
theme={theme}
x={0}
y={12}
/>
)}
</div>
</React.Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

.details-dataset__accordion {
margin-bottom: 36px;
max-width: 75em;
width: 100%;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ $animation-timing: 0.3s;

.details-metadata__run--first-run-comparison-view .details-metadata__title {
opacity: 1;
transition: opacity $animation-timing ease-in;
transition: opacity $animation-timing linear;
}

// animation for other run when select or deselect
// needed to use react-cssTransition to animate when the run is not existed in the DOM anymore
// animation for other run when select or deselect
// needed to use react-cssTransition to animate when the run is not existed in the DOM anymore
.details-metadata__run-animation-enter,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React from 'react';
import ContentLoader from 'react-content-loader';
import {
experimentTrackingLazyLoadingColours,
experimentTrackingLazyLoadingGap,
} from '../../../config';

import './run-metadata.css';

const GAP = experimentTrackingLazyLoadingGap;

const TitleLoader = () => (
<>
<rect width="180" height="20" x="0" y="12" />
<rect width="88" height="16" x="0" y={12 + GAP} />
<rect width="88" height="16" x="0" y={12 + GAP * 2} />
<rect width="88" height="16" x="0" y={12 + GAP * 3} />
<rect width="88" height="16" x="0" y={12 + GAP * 4} />
<rect width="88" height="16" x="0" y={12 + GAP * 5} />
<rect width="88" height="16" x="0" y={12 + GAP * 6} />
</>
);

const DetailsLoader = ({ x }) => (
<>
<rect width="0" height="0" x={x} y="12" />
<rect width="30" height="16" x={x} y={12 + GAP} />
<rect width="180" height="16" x={x} y={12 + GAP * 2} />
<rect width="88" height="16" x={x} y={12 + GAP * 3} />
<rect width="50" height="16" x={x} y={12 + GAP * 4} />
<rect width="100" height="16" x={x} y={12 + GAP * 5} />
<rect width="150" height="16" x={x} y={12 + GAP * 6} />
</>
);

export const SingleRunMetadataLoader = ({ theme }) => (
<div className="details-metadata">
<ContentLoader
viewBox="0 0 1000 300"
width="1000px"
height="100%"
backgroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.backgroundDarkTheme
: experimentTrackingLazyLoadingColours.backgroundLightTheme
}
foregroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.foregroundDarkTheme
: experimentTrackingLazyLoadingColours.foregroundLightTheme
}
>
<TitleLoader />
<DetailsLoader x={380} />
</ContentLoader>
</div>
);

export const MetaDataLoader = ({ length, theme }) => {
const x = length > 1 ? 75 : 0;

return (
<tbody className="details-metadata__run-lazy-loader">
<tr>
<td>
<ContentLoader
viewBox="0 0 200 300"
width="200px"
height="100%"
backgroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.backgroundDarkTheme
: experimentTrackingLazyLoadingColours.backgroundLightTheme
}
foregroundColor={
theme === 'dark'
? experimentTrackingLazyLoadingColours.foregroundDarkTheme
: experimentTrackingLazyLoadingColours.foregroundLightTheme
}
>
<DetailsLoader x={x} />
</ContentLoader>
</td>
</tr>
</tbody>
);
};
Loading