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

feat: migrate image list #2615

Merged
merged 1 commit into from
Aug 27, 2024
Merged

feat: migrate image list #2615

merged 1 commit into from
Aug 27, 2024

Conversation

gahyuun
Copy link
Member

@gahyuun gahyuun commented Aug 7, 2024

This PR resolves #2586 issue

TL;DR

migrate ImageList

Why make this change?

To migrate from lit component to react component

What changed?

  • ImageInstallModal

    • Component that install images
    • I deselected the rows when clicking the install button in the modal because I felt the flow of deselecting the rows was more natural, whereas before it would not deselect the rows.
    • The newly added phrases are written in en and ko only
    • However, I didn't proceed with replacing "download" with "install". This was because there were more download phrases than I thought, and I thought it might be more confusing if I replaced a lot of them
  • ImageList

    • I used suspense to prevent the entire screen from loading when the image list is first rendered
  • ManageAppsModal, ManageImageResourceLimitModal

    • I modified it because it's called from a React component, not a lit component.
    • Implemented the getServicePorts function in ManageAppsModal without passing service port as a prop
  • ResourceNumber

    • I added ranges via the range and max properties ( ex 1~∞ Core )
    • The ResourceNumber component made rendering the table too slow, so I used Memo

How to test?

  • imageList
  1. enter the environment page
  2. select the row
  3. sort the column
  • ManageImageResourceLimitModal
  1. click button
  2. change resource
  3. click Okay button
  4. check if the resource has changed
  • ManageAppsModal
  1. click button
  2. add port
  3. delete port
  4. check if the ports has changed
  • ImageInstallModal
  1. select uninstalled images

  2. click install button

  3. check uninstalled images info

  4. click install button and check if an notification appears

  5. select installed images

  6. check warn message

  7. select uninstalled images and installed images

  8. check exclude message

@gahyuun gahyuun self-assigned this Aug 7, 2024
Copy link

graphite-app bot commented Aug 7, 2024

Your org requires the Graphite merge queue for merging into main

Add the label “flow:merge-queue” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “flow:hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added area:ux UI / UX issue. area:i18n Localization size:XL 500~ LoC labels Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
5.27% (+0.54% 🔼)
322/6109
🔴 Branches
4.96% (+0.22% 🔼)
208/4191
🔴 Functions
3.03% (+0.36% 🔼)
61/2013
🔴 Lines
5.16% (+0.55% 🔼)
308/5965
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / ImageInstallModal.tsx
0% 0% 0% 0%
🔴
... / ImageList.tsx
0% 0% 0% 0%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / ResourceNumber.tsx
26.67% (-4.1% 🔻)
0% 0%
26.67% (-4.1% 🔻)
🔴
... / FlexActivityIndicator.tsx
0%
0% (-100% 🔻)
0% 0%

Test suite run success

82 tests passing in 9 suites.

Report generated by 🧪jest coverage report action from 7156dd4

@gahyuun gahyuun marked this pull request as ready for review August 8, 2024 04:23
@gahyuun gahyuun marked this pull request as draft August 8, 2024 04:30
@gahyuun gahyuun marked this pull request as ready for review August 8, 2024 04:42
react/src/index.tsx Outdated Show resolved Hide resolved
@gahyuun gahyuun marked this pull request as draft August 8, 2024 09:44
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

Currently, we don't have pagination, so It's getting too much data and it's causing lag on page navigation and other interactions. Can you take a look at this as well?

@gahyuun gahyuun marked this pull request as ready for review August 9, 2024 04:54
@gahyuun gahyuun requested a review from ironAiken2 August 9, 2024 05:16
@gahyuun gahyuun force-pushed the refactor/migrate-image-list branch from 77c19ae to 77064b1 Compare August 9, 2024 05:37
return null;
}

const handleClick = () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

key: 'installed',
sorter: sortBasedOnInstalled,
render: (text, row) => {
if (row?.id && installingImages.includes(row.id))
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 used the installingImages state to show the installing tag

Comment on lines 63 to 53
const sortBasedOnInstalled = (a: EnvironmentImage, b: EnvironmentImage) => {
return a?.installed && !b?.installed
? -1
: !a?.installed && b?.installed
? 1
: 0;
};

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

While checking ImageList, I added the parts that didn't have metaData.

@@ -251,7 +260,49 @@ export const useBackendAIImageMetaData = () => {
const { tags } = getImageMeta(imageName);
return tags[1];
},
getBaseImages: (tag: string, name: string) => {
Copy link
Member Author

@gahyuun gahyuun Aug 9, 2024

Choose a reason for hiding this comment

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

getBaseImages,getConstraints,getLangs implemented a new function without modifying the getBaseImage,getCustomTag,getFilteredRequirementsTag,getImageLang because of side effects ( ex. SessionKernelTags uses getBaseImage. )
Also, because of the side effect, I didn't modify MyEnvironmentPage to any values except the constraints. I think it's better to do this in a new task.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

Please resolve conflict :)

Comment on lines +13 to +31
(global as any).fetch = jest.fn(async () =>
Promise.resolve({
ok: true,
status: 200,
json: () =>
Promise.resolve({
imageInfo: {},
tagAlias: {
pytorch: 'PyTorch',
r: 'R',
'r-base': 'R',
py3: 'Python3',
ngc: 'Nvidia GPU Cloud',
py310: 'Python3',
},
tagReplace: {},
}),
}),
);
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 used jest.fn because suspense can't wait for the test to complete while fetching data

Comment on lines 150 to 156
globalThis.lablupNotification.text = painKiller.relieve(error.title);
// @ts-ignore
globalThis.lablupNotification.detail = error.message;
// @ts-ignore
globalThis.lablupNotification.show(true, error);
indicator.set(100, t('environment.DescProblemOccurred'));
indicator.end(1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you didn't use upsertNotification in this part?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@gahyuun we can change this part using upsertNotification with promise. This is an example.

Comment on lines 159 to 163
setInstallingImages(
imagesToInstall
.map((item) => item?.id)
.filter((id): id is string => id !== null && id !== undefined),
);
Copy link
Contributor

@ironAiken2 ironAiken2 Aug 12, 2024

Choose a reason for hiding this comment

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

Isn't it duplicated with ref? And it seems that the problem will occur if you download another image additionally without refreshing the page.

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 modified the rendering to only show the successful API image after clicking the install button.
I made the requests in parallel and only updated the state of the successful images.

ded9e49

@gahyuun gahyuun force-pushed the refactor/migrate-image-list branch from 2c21cf2 to 9137e18 Compare August 12, 2024 07:13
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 modified it because I wanted to resize the spinner

Comment on lines 29 to 49
const CellWrapper = ({
children,
style,
}: {
children: ReactNode;
style?: React.CSSProperties;
}) => {
if (!children) return null;
return (
<div
style={{
display: 'flex',
alignItems: 'center',
height: '100%',
...style,
}}
>
{children}
</div>
);
};
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 Ant Design's Table component, when using virtual mode and specifying a scroll.y value, the vertical center alignment does not seem to be applied correctly because the cells have a fixed height.
So, I implemented a component called CellWrapper and did the vertical alignment myself.

Since I was doing a custom render, the ellipsis property was not applied, so I applied ellipsis directly as well

rowKey="id"
scroll={{
x: 1600,
y: window.innerHeight - 145 - 56 - 54,
Copy link
Member Author

Choose a reason for hiding this comment

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

@rapsealk
Copy link
Member

Please resolve the conflicts!

@gahyuun gahyuun added this to the 24.03 milestone Aug 16, 2024
Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

I'm working to resolve blow list:

  • Make the entire row clickable.
  • Resource Limitation Column: The rows in this table do not have a fixed height, so 'virtual' is not appropriate. Changing to a fixed height is not possible due to the resource limitation UI column.
  • Base and Constraint Columns: Display them in one line.
  • When you modify an image, the order can be changed. To prevent this, let's set the order using 'humanized_name'.

I'll share soon.

Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

I got an error when I try to update using Manage app modal. Please check it again.

image.png

Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

LGTM

}
},
})}
showSorterTooltip={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
showSorterTooltip={false}
showSorterTooltip={false}
sortDirections={['descend', 'ascend', 'descend']}

Logic to limit data sorting to ascending and descending order is not needed in the webui?

Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

graphite-app bot commented Aug 27, 2024

Merge activity

<!--
Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes,
and how it affects the users and other developers.
-->

### This PR resolves [#2586 ](#2586) issue
### TL;DR

migrate ImageList

###  Why make this change?

To migrate from lit component to react component

### What changed?

- ImageInstallModal
    - Component that install images
    - I deselected the rows when clicking the install button in the modal because I felt the flow of deselecting the rows was more natural, whereas before it would not deselect the rows.
    - The newly added phrases are written in en and ko only
    - However, I didn't proceed with replacing "download" with "install". This was because there were more download phrases than I thought, and I thought it might be more confusing if I replaced a lot of them

- ImageList
    - I used suspense to prevent the entire screen from loading when the image list is first rendered

- ManageAppsModal, ManageImageResourceLimitModal
    - I modified it because it's called from a React component, not a lit component.
    - Implemented the getServicePorts function in ManageAppsModal without passing service port as a prop

- ResourceNumber
    - I added ranges via the range and max properties ( ex 1~∞ Core )
    - The ResourceNumber component made rendering the table too slow, so I used Memo

### How to test?

- imageList
1. enter the environment page
2. select the row
3. sort the column

- ManageImageResourceLimitModal
1. click button
3. change resource
4. click Okay button
5. check if the resource has changed

- ManageAppsModal
1. click button
2. add port
3. delete port
4. check if the ports has changed

- ImageInstallModal
1. select uninstalled images
2. click install button
3. check uninstalled images info
4. click install button and check if an notification appears

1. select installed images
2. check warn message

1. select uninstalled images and installed images
2. check exclude message
@graphite-app graphite-app bot merged commit 7156dd4 into main Aug 27, 2024
8 checks passed
@graphite-app graphite-app bot deleted the refactor/migrate-image-list branch August 27, 2024 10:01
agatha197 pushed a commit that referenced this pull request Sep 3, 2024
### TL;DR

After #2615, the Resource Number displays an infinity symbol unexpectedly.

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/XqC2uNFuj0wg8I60sMUh/ee78810c-da7e-4312-be4a-09aa269931b9.png)

This PR fixes that bug and refactors the code related to the `max` display.
yomybaby added a commit that referenced this pull request Sep 3, 2024
### TL;DR

After #2615, the Resource Number displays an infinity symbol unexpectedly.

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/XqC2uNFuj0wg8I60sMUh/ee78810c-da7e-4312-be4a-09aa269931b9.png)

This PR fixes that bug and refactors the code related to the `max` display.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:i18n Localization area:ux UI / UX issue. size:XL 500~ LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

migrate image list in environment page from lit to React
4 participants