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

Update nextjs to version 12 and upgrate Vitessce to latest #897

Conversation

ivababukova
Copy link
Member

@ivababukova ivababukova commented Sep 22, 2023

Description

Staged link: https://ui-ivababukova-upgrades.scp-staging.biomage.net/

Details

URL to issue

N/A

Link to staging deployment URL (or set N/A)

N/A

Links to any PRs or resources related to this PR

Integration test branch

master

Merge checklist

Your changes will be ready for merging after all of the steps below have been completed.

Code updates

Have best practices and ongoing refactors being observed in this PR

  • Migrated any selector / reducer used to the new format.
  • All new dependency licenses have been checked for compatibility.

Manual/unit testing

  • Tested changes using InfraMock locally or no tests required for change, e.g. Kubernetes chart updates.
  • Validated that current unit tests for code work as expected and are sufficient for code coverage or no unit tests required for change, e.g. documentation update.
  • Unit tests written or no unit tests required for change, e.g. documentation update.

Integration testing

You must check the box below to run integration tests on the latest commit on your PR branch.
Integration tests have to pass before the PR can be merged. Without checking the box, your PR
will not pass the required status checks for merging.

  • Started end-to-end tests on the latest commit.

Documentation updates

  • Relevant Github READMEs updated or no GitHub README updates required.
  • Relevant Wiki pages created/updated or no Wiki updates required.

Optional

  • Staging environment is unstaged before merging.
  • Photo of a cute animal attached to this PR.

@ivababukova ivababukova added the safe to run Sensitive jobs are safe to be run label Sep 22, 2023
Signed-off-by: ivababukova <[email protected]>
Signed-off-by: ivababukova <[email protected]>
@ivababukova ivababukova changed the title Ivababukova/update nextjs Update nextjs to version 12 Sep 22, 2023
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Merging #897 (658d9e1) into master (e36cc58) will decrease coverage by 0.30%.
The diff coverage is 87.50%.

❗ Current head 658d9e1 differs from pull request most recent head 8caf367. Consider uploading reports for the commit 8caf367 to get more accurate results

@@            Coverage Diff             @@
##           master     #897      +/-   ##
==========================================
- Coverage   86.19%   85.90%   -0.30%     
==========================================
  Files         544      544              
  Lines       10084    10089       +5     
  Branches     2125     2126       +1     
==========================================
- Hits         8692     8667      -25     
- Misses       1342     1371      +29     
- Partials       50       51       +1     
Files Coverage Δ
src/components/EditableField.jsx 98.57% <ø> (ø)
src/components/NoStyleAntdMenuItem.jsx 66.66% <ø> (ø)
...omponents/data-exploration/embedding/Embedding.jsx 85.82% <100.00%> (ø)
...nents/data-exploration/heatmap/HeatmapSettings.jsx 100.00% <ø> (ø)
...exploration/hierarchical-tree/HierarchicalTree.jsx 96.29% <ø> (ø)
...ponents/data-management/PrivacyPolicyIntercept.jsx 28.57% <ø> (ø)
src/components/data-management/SamplesTable.jsx 86.66% <ø> (-1.67%) ⬇️
...c/components/data-management/SamplesTableCells.jsx 95.34% <ø> (ø)
src/components/plots/PlotsTablesContainer.jsx 100.00% <ø> (ø)
.../hierarchical-tree-genes/HierarchicalTreeGenes.jsx 100.00% <ø> (ø)
... and 2 more

... and 9 files with indirect coverage changes

@ivababukova ivababukova changed the title Update nextjs to version 12 Update nextjs to version 12 and upgrate Vitessce to latest Sep 28, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
@hms-dbmi-cellenics hms-dbmi-cellenics deleted a comment from github-actions bot Oct 3, 2023
test: /\.(js|jsx)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
options: { presets: ['@babel/preset-env', '@babel/preset-react'] },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already set the presets in the .babelrc.js file. Do you need to have this configuration here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have it. If I comment it out, I get this build error:
Screenshot 2023-10-04 at 12 30 28

testPathIgnorePatterns: [
'.*\\.mock\\.js',
'test-utils',
],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest',
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So jest doesnt need this transform function anymore? Was this ran before for every file that is not js|jsx|ts|tsx|css|json ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we don't need it anymore. I will also delete fileTransform.js because it doesn't seem to be referenced anywhere else

@@ -1,181 +1,161 @@
import React from 'react';
import { mount } from 'enzyme';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't have any enzyme tests anymore, can you remove the module?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid we still have enzyme tests -- for example ColorPicker.test.jsx, PipelineLoadingScreen.test.jsx

await act(async () => {
fireEvent.click(sampleOrGroupOption);
});
userEvent.click(selectSampleOrGroup);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the act. We dont need it anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userEvent is a library built on top of fireEvent that provides a more user-centric API for triggering events. userEvent automatically wraps all its methods in act(), so you don't need to use act() when using userEvent in most cases. This is one of the reasons why userEvent is recommended for most interaction testing over fireEvent.

In other words, userEvent takes care of using act() internally, ensuring that all state updates and effects are processed when the event is fired, which is why act is not needed anymore in the revised code snippet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's from chatgpt I think it sums it well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in reality, when this test was failing, I looked at Agi's changes: https://github.com/biomage-org/ui-old/pull/200/files to see how he fixed the test and I copied what he did, which worked.

@@ -0,0 +1,6 @@
// Due to a bug with dynamic imports and webpack, we need to create
// a wrapper component to import the Scatterplot component.
// See https://github.com/webpack/webpack/issues/13865
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very weird bug. So importing it here in the wrapper works, but not in other places? How?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is super weird. I think that the bug is that you can't both import the real thing (@vitessce/heatmap) and use dynamic imports in one place -- you have to do it one by one, because webpack doesn't like they syntax of it written all at once. This is why it works when you do it with a wrapper. This is my understanding.

@@ -32,10 +32,9 @@ import {
} from 'utils/plotUtils';
import getContainingCellSetsProperties from 'utils/cellSets/getContainingCellSetsProperties';

const Scatterplot = dynamic(
() => import('vitessce/dist/umd/production/scatterplot.min').then((mod) => mod.Scatterplot),
Copy link
Member

@StefanBabukov StefanBabukov Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you use the relative path it will work. Can you try?
webpack/webpack#13865 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works can you do it in the other places (I saw the same for the heatmap import)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that and it doesn't work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I recommend you put all the vitessce wrappers in one file so its less confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I have done that in my new branch and PR.

@@ -12,8 +12,7 @@ import EditableField from 'components/EditableField';
import ColorPicker from 'components/ColorPicker';
import FocusButton from 'components/FocusButton';
import HideButton from 'components/data-exploration/cell-sets-tool/HideButton';

import 'components/data-exploration/hierarchical-tree/hierarchicalTree.css';
// import styles from '.hierarchicalTree.module.css';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment

Signed-off-by: ivababukova <[email protected]>
…t happen anymore. Delete commented out css import

Signed-off-by: ivababukova <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

📦 Next.js Bundle Analysis for ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 583.79 KB (🟢 -17.37 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Nineteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/401 241 B (🟢 -2.08 KB) 584.02 KB
/404 241 B (🟢 -2.08 KB) 584.02 KB
/_error 244 B (🟢 -2.46 KB) 584.02 KB
/data-management 237.69 KB (🟢 -18.02 KB) 821.48 KB
/experiments/[experimentId]/data-exploration 515.87 KB (🟢 -100.71 KB) 1.07 MB
/experiments/[experimentId]/data-processing 533.11 KB (🟢 -29.4 KB) 1.09 MB
/experiments/[experimentId]/plots-and-tables 15.7 KB (🟡 +591 B) 599.48 KB
/experiments/[experimentId]/plots-and-tables/batch-differential-expression 74.33 KB (🟢 -6.4 KB) 658.11 KB
/experiments/[experimentId]/plots-and-tables/dot-plot 489.18 KB (🟢 -85.06 KB) 1.05 MB
/experiments/[experimentId]/plots-and-tables/embedding-categorical 480.19 KB (🟢 -39.29 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/embedding-continuous 481.58 KB (🟢 -87.3 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/frequency 482.06 KB (🟢 -34.75 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/marker-heatmap 581.41 KB (🟢 -89.9 KB) 1.14 MB
/experiments/[experimentId]/plots-and-tables/normalized-matrix 170.64 KB (🟢 -10.76 KB) 754.42 KB
/experiments/[experimentId]/plots-and-tables/trajectory-analysis 483.67 KB (🟢 -39.54 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/violin 511.29 KB (🟢 -86.01 KB) 1.07 MB
/experiments/[experimentId]/plots-and-tables/volcano 485.11 KB (🟢 -39.03 KB) 1.04 MB
/repository 108.78 KB (🟡 +5.92 KB) 692.57 KB
/settings/profile 25.63 KB (🟢 -4.22 KB) 609.42 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Signed-off-by: ivababukova <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2023

📦 Next.js Bundle Analysis for ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 583.79 KB (🟢 -17.37 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Nineteen Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/401 241 B (🟢 -2.08 KB) 584.02 KB
/404 241 B (🟢 -2.08 KB) 584.02 KB
/_error 244 B (🟢 -2.46 KB) 584.02 KB
/data-management 237.69 KB (🟢 -18.02 KB) 821.48 KB
/experiments/[experimentId]/data-exploration 515.87 KB (🟢 -100.71 KB) 1.07 MB
/experiments/[experimentId]/data-processing 533.11 KB (🟢 -29.4 KB) 1.09 MB
/experiments/[experimentId]/plots-and-tables 15.7 KB (🟡 +591 B) 599.48 KB
/experiments/[experimentId]/plots-and-tables/batch-differential-expression 74.33 KB (🟢 -6.4 KB) 658.11 KB
/experiments/[experimentId]/plots-and-tables/dot-plot 489.18 KB (🟢 -85.06 KB) 1.05 MB
/experiments/[experimentId]/plots-and-tables/embedding-categorical 480.19 KB (🟢 -39.29 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/embedding-continuous 481.58 KB (🟢 -87.3 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/frequency 482.06 KB (🟢 -34.75 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/marker-heatmap 581.41 KB (🟢 -89.9 KB) 1.14 MB
/experiments/[experimentId]/plots-and-tables/normalized-matrix 170.64 KB (🟢 -10.76 KB) 754.42 KB
/experiments/[experimentId]/plots-and-tables/trajectory-analysis 483.67 KB (🟢 -39.54 KB) 1.04 MB
/experiments/[experimentId]/plots-and-tables/violin 511.29 KB (🟢 -86.01 KB) 1.07 MB
/experiments/[experimentId]/plots-and-tables/volcano 485.11 KB (🟢 -39.03 KB) 1.04 MB
/repository 108.78 KB (🟡 +5.92 KB) 692.57 KB
/settings/profile 25.63 KB (🟢 -4.22 KB) 609.42 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@ivababukova
Copy link
Member Author

I had to close this PR and reopen a new one, because of some commits not being signed. Here is the new PR: #904

@ivababukova ivababukova closed this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to run Sensitive jobs are safe to be run
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants