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: replace clone function with structuredClone and add polyfill #7624

Merged
merged 14 commits into from
Aug 22, 2023

Conversation

thiagodallacqua-hpe
Copy link
Contributor

@thiagodallacqua-hpe thiagodallacqua-hpe commented Aug 14, 2023

Ticket: WEB-946

This PR intends to convert the current structure into using the available structuredClone and add a polyfill for it.

Description

Test Plan

there're a few places where the clone function is used, I suggest testing with the hyperparameter search modal, as it clones with the previous arg for deep as true.

Commentary (optional)

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

Ticket

@cla-bot cla-bot bot added the cla-signed label Aug 14, 2023
@netlify
Copy link

netlify bot commented Aug 14, 2023

Deploy Preview for determined-ui ready!

Name Link
🔨 Latest commit 74e72ce
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/64e4e15dee51870008d7883c
😎 Deploy Preview https://deploy-preview-7624--determined-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@thiagodallacqua-hpe thiagodallacqua-hpe changed the title feat: use structuredClone in the internal "clone" function and add a … feat: use structuredClone in the internal "clone" function and add polyfill Aug 14, 2023
@thiagodallacqua-hpe thiagodallacqua-hpe requested review from keita-determined and a team and removed request for a team August 14, 2023 18:29
@thiagodallacqua-hpe thiagodallacqua-hpe marked this pull request as ready for review August 14, 2023 18:29
@thiagodallacqua-hpe thiagodallacqua-hpe requested a review from a team as a code owner August 14, 2023 18:29
@thiagodallacqua-hpe thiagodallacqua-hpe removed the request for review from a team August 14, 2023 18:29
webui/react/package.json Show resolved Hide resolved
webui/react/src/utils/data.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@keita-determined keita-determined left a comment

Choose a reason for hiding this comment

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

seems like .swcrc is not working as expected

webui/react/.swcrc Outdated Show resolved Hide resolved
webui/react/src/utils/data.ts Outdated Show resolved Hide resolved
@ashtonG
Copy link
Contributor

ashtonG commented Aug 15, 2023

We only use swc for transpilation in dev -- in production we use esbuild. Can you confirm the swc polyfill method works on older browsers with a production bundle?

@thiagodallacqua-hpe
Copy link
Contributor Author

We only use swc for transpilation in dev -- in production we use esbuild. Can you confirm the swc polyfill method works on older browsers with a production bundle?

After adding the polyfill back, I've checked the preview link on chrome 97 and it works.

Copy link
Contributor

@keita-determined keita-determined left a comment

Choose a reason for hiding this comment

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

tested on local chromium v93 and its mostly good in production mode
but polyfill is not applied on dev mode. do we wanna support it in dev mode too?

webui/react/src/components/ResourcePoolCard.tsx Outdated Show resolved Hide resolved
webui/react/src/App.tsx Outdated Show resolved Hide resolved
webui/react/src/components/HpSelect.tsx Outdated Show resolved Hide resolved
webui/react/src/components/HpSelect.tsx Outdated Show resolved Hide resolved
webui/react/src/components/ResourcePoolDetails.tsx Outdated Show resolved Hide resolved
webui/react/src/components/ResourcePoolCard.tsx Outdated Show resolved Hide resolved
@ashtonG
Copy link
Contributor

ashtonG commented Aug 17, 2023

circling back, i'm noticing that by default the old clone did a shallow clone and we only need deep clones (i.e., what structuredClone does) when true is passed to the "deep" argument.

can we replace calls that would have been shallow clones with the object spread instead to keep the semantics consistent?

@thiagodallacqua-hpe
Copy link
Contributor Author

circling back, i'm noticing that by default the old clone did a shallow clone and we only need deep clones (i.e., what structuredClone does) when true is passed to the "deep" argument.

can we replace calls that would have been shallow clones with the object spread instead to keep the semantics consistent?

I looked at this, as the old clone had the arg deep = true, and I couldn't find any call signature with clone(<cloned_stuff>, false)...

clone = (data: any, deep = true): any => // ...

@keita-determined
Copy link
Contributor

tested on local chromium v93 and its mostly good in production mode but polyfill is not applied on dev mode. do we wanna support it in dev mode too?

@ashtonG do you think polyfill should be applied in dev? or we expect engineers to use the latest browser so it doesn't matter?

@ashtonG
Copy link
Contributor

ashtonG commented Aug 18, 2023

i'd be suprised the polyfill isn't working in dev -- barring an explicit IS_DEV switch, i'd expect the module doing the pollyfilling to work the same regardless.

@thiagodallacqua-hpe can you investigate what's happening here?

Copy link
Contributor

@keita-determined keita-determined left a comment

Choose a reason for hiding this comment

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

Looks mostly good, but i got an issue in the new exp table.
in Chrome v116, the new exp table doesn't show data correctly. I didn't see the issue in main branch so i think this PR introduced the issue.

Screen.Recording.2023-08-21.at.11.26.37.AM.mov

Copy link
Contributor

@keita-determined keita-determined left a comment

Choose a reason for hiding this comment

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

Could you change the appropriate PR title?

@thiagodallacqua-hpe thiagodallacqua-hpe changed the title feat: use structuredClone in the internal "clone" function and add polyfill feat: replace clone function with structuredClone and add polyfill Aug 22, 2023
@thiagodallacqua-hpe thiagodallacqua-hpe merged commit e2f2173 into main Aug 22, 2023
@thiagodallacqua-hpe thiagodallacqua-hpe deleted the thiago/WEB-946 branch August 22, 2023 19:14
@dannysauer dannysauer added this to the 0.25.0 milestone Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants