-
Notifications
You must be signed in to change notification settings - Fork 4k
Refactor: withHostCommunication -> HostCommunicationManager #6746
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
Conversation
09a12cb to
4c731bb
Compare
4c731bb to
e111339
Compare
a8d4e94 to
7cdfb9c
Compare
6ad52ec to
6d4effd
Compare
|
Notes on outstanding/followup items:
|
tconkling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really fantastic. Most of my feedback is just nitpicking, but there are a few correctness issues I want to make sure we nail before merging.
(Also I think it's probably worth having @vdonato and/or @lukasmasuch give a second review afterwards, to make sure I didn't miss anything important.)
tconkling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a few unimplemented test stubs that should be filled in before merging.
I also left some questions about some App.test.tsx tests that seem to have been removed, but it's quite likely they're made obsolete with these changes? Just want to verify.
(And I also noted a bunch of tests that were just rearranged in App.test.tsx - these are just notes to myself for future reviews, so that I don't go looking for them again. No need to respond to those ones!)
frontend/src/app/App.test.tsx
Outdated
| currentPageScriptHash: "hash1", | ||
| }) | ||
| }) | ||
| it("plumbs appPages and currentPageScriptHash to the AppView component", () => {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this test go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake - added back 👍🏼
| }) | ||
| }) | ||
|
|
||
| it("responds to page change requests", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this covered elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! this test forces update to HostCom HOC state (same thing as receiving REQUEST_PAGE_CHANGE message from host) to test onPageChange firing. This logic has moved to HostCommMgr -> the parallel test is on line 165 of HostCommunicationManager.test.tsx here
| expect(onModalReset).toBeCalled() | ||
| }) | ||
|
|
||
| it("changes scriptRunState and fires withHostCommunication callback when scriptStopRequested signal has been received", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test obsolete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, these are part of that loop pattern we eliminated and this callback firing is tested in HostCommunicationManager instead.
| onClose: () => {}, | ||
| }) | ||
|
|
||
| it("changes scriptRunState and fires withHostCommunication callback when scriptRerunRequested signal has been received", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this test obsolete? (I think the answer is yes, just noting where I see a test removal so I don't accidentally re-review tests that we expect to be removed.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! Ditto to above
| "stopScript" | ||
| ) | ||
|
|
||
| it("fires withHostCommunication callback when cacheClearRequested signal has been received", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verifying this is intended to be removed
| }) | ||
| ) | ||
|
|
||
| it("updates state.appPages when it receives a PagesChanged msg", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Tim note: test was moved)
| expect(instance.clearAppState).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it("sets hideSidebarNav based on the server config option and host setting", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Tim note: test was moved)
| expect(wrapper.find("DeployButton")).toHaveLength(0) | ||
| }) | ||
|
|
||
| it("button should be hidden for cloud environment", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did this test go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was moved to line 591 - title Deploy button should be hidden for cloud environment
frontend/src/app/App.test.tsx
Outdated
|
|
||
| expect(wrapper.instance().openClearCacheDialog).not.toBeCalled() | ||
| }) | ||
| it("Tests dev menu shortcuts cannot be accessed as a viewer", () => {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added back!
tconkling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a few unimplemented test stubs that should be filled in before merging.
I also left some questions about some App.test.tsx tests that seem to have been removed, but it's quite likely they're made obsolete with these changes? Just want to verify.
(And I also noted a bunch of tests that were just rearranged in App.test.tsx - these are just notes to myself for future reviews, so that I don't go looking for them again. No need to respond to those ones!)
vdonato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this LGTM!
I left some comments, but they're more or less a bunch of nits / small things (and a good number of them seem to overlap with Tim's recent review so may be outdated now). I don't think I have any concerns about the overall approach here / things look more or less like I would have guessed
|
Another thing that I think needs to be done (possibly even after a merge to Not sure how much we can fully test auth-token related things, but I have a small toy app that I used to test those changes locally that I can clean up and send your way with instructions tomorrow |
tconkling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff!
* develop: Remove tensorflow and pytorch from test requirements (streamlit#6807) Fix readme links (streamlit#6800) Update PR template to be simpler and more approachable (streamlit#6679) README updated with links to docs (streamlit#6780) Refactor: withHostCommunication -> HostCommunicationManager (streamlit#6746) Add python 3.11 to classifiers list. (streamlit#6786) Release/1.23.1 (streamlit#6777) We depend on typing-extensions 4.0.1 (streamlit#6776) Release/1.23.0 (streamlit#6773) Fix typo in data_editor docstring and deprecation msg: `edited_rows` -> `edited_cells` (streamlit#6770) Fix: Remove flaky date input calendar snapshot test (streamlit#6769) Fix 3218, patch pydantic in_ipython function (streamlit#6664) Upgrade react-range to fix memory usage of sliders (streamlit#6764) Make st.write pretty-print dataclasses using st.help (streamlit#6750) Replace curly with straightquotes in docstring examples (streamlit#6757)
📚 Description
Refactor our
withHostCommunicationHOC into aHostCommunicationManagerclass in an effort to simplify the current code & future extension.Tech Spec: link
🧪 Testing Done