-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Big change] Server refactor (Part 1) #858
Conversation
Regarding the Socket-Wrappers & Handlers: One question from my side: Why has this seperation been done during development? I ask because I thought about merging these two types of handlers in case they are not actually handled differently. |
Excited to see these changes revived! You're right on the money for why there were different types of socket handlers. Back when we were driving internal visdom adoption we needed separate flows for writing to the server and reading from it for authentication reasons. The keepalive setups for each were different, and so we had to make a drop-in replacement for just one of the two paths. Nowadays we don't use this setup the same way anymore, so I'm happy to have things consolidated. |
Ah I see, thanks for the additional information! :) My tendency is not to simplify existing structures if they have a good reason like here. On the other hand, the code is indeed more complicated due to the split. Additionally, if nowadays more people need such a feature, probably a more complex role distribution (in contrast to just separating read and write) could become a long-term goal. |
3875f19
to
b1825cc
Compare
Rebased onto master to retrigger actions with the changes of #866 in place. |
Not sure yet, how to handle version-numbers correctly, especially for multiple parallel open PRs, or the question if every small PR should actually increase the version. Nevertheless, larger code changes such as this one could be given a new version number, i guess. |
e6a1e10
to
2989507
Compare
I am sorry, did a mistake here in the "force-push" history by rebasing onto the wrong branch. Last push sits correctly on top of |
2989507
to
4000d8f
Compare
(Just a rebase onto current master). |
4000d8f
to
f362176
Compare
Was missing #873 PR. Latest push contains that one as well. "Compare to previous Push"-Button should now show exactly those changes now. I am thinking what I could do to provide a clearer way to show if this PR is actually non-destructive somewhere. Possibly a script that reverts the split into sub-files? |
If this is still functional as expected (which, given the tests, it likely is) I'm happy to accept this sooner rather than later (instead of building out a solution to constantly keep it updated). |
Sure!
For both ways, merging this big PR, or, separating the two parts mentioned, I am happy to look into bugs that might have been introduced by me here. |
I'll take a review pass tomorrow - given #675 was mostly me directly copy-pasting into smaller files and then making changes on top, I'm fairly convinced that the majority of the underlying server code is present as it was, so I'll do a review on the following content. |
I didn't mean to push you. :) |
No worries, I've left this one sitting open for far too long 😅 |
See a minor mistake that I will fix tomorrow morning: all the file headers say "Facebook Inc." instead of "Visdom Team". 😅 |
f362176
to
015578d
Compare
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.
All-in-all this is a great set of changes. Thanks for the additional work to extend my original set to still be valid against the current codebase. I feel like this separation does a lot to make the inner workings of Visdom more approachable.
py/visdom/extra_deps/__init__.py
Outdated
@@ -1,5 +0,0 @@ | |||
# Copyright 2017-present, The Visdom Authors |
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.
Why do we drop this file? The core function of it is to retain the directory, wherein people can import optional dependencies for Visdom. Realistically, this is only useful for the bhtsne
library, but that may still be in use. Perhaps instead of just an __init__.py
, it makes sense to have a README.md
too, but that's out of scope for this PR.
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.
Ah, didn't know that. I've removed the deletion in the latest push below.
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.
Hm I'm not seeing the most recent push. I'll merge this in once it's there!
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.
Yes, I totally forgot to push, but it should be there now.
@@ -6,6 +6,8 @@ | |||
# This source code is licensed under the license found in the |
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.
As an aside, it's not the best that the entirety of visdom lives in the __init__.py
file too. For a future refactor 😉
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.
Yeah, that's true; the python-client code grew out of control. ^^
Considering some of the issues, there are quite some bugs to fix there as well, but tons of tiny things to keep track of at the same time. Any Idea how to improve the code efficiently?
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.
For things like this, I'd argue that visdom has reached a scale that we need to hit on more DevX and codebase quality. Before jumping into the small changes, reorganizing would come first. Then I'd probably want to start using typing
, though that can happen in parallel with small changes (every time you take a pass through to fix a bug, doing code quality improvements in the same pass). Typing and testing make sure that as you're making changes, the code is to some degree keeping track of things by itself so you don't have to.
# ============== # | ||
# About & Naming # | ||
# ============== # | ||
|
||
# 1. *Handler- & *Wrap-classes are intended to have the same functionality | ||
# - *Handler (e.g. VisSocketHandler) use WebSockets | ||
# - *Wrap (e.g. VisSocketWrap) use polling-based connections instead | ||
# - *Wrapper (e.g. VisSocketWrapper) is just a helper class for the respective *Wrap-class | ||
# to process the current state (instead of the state at the time of polling) | ||
# 2. VisSocket* classes (VisSocketHandler, VisSocketWrap & VisSocketWrapper) | ||
# Their goal is to register clients with write access of actual data. | ||
# 3. Socket* classes (SocketHandler, SocketWrap & SocketWrapper) | ||
# Their goal is to register clients with read access of data. | ||
# Write access is limited to data and view organization (i.e. layout settings, env removal and env saving) |
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.
Thanks for providing the demystifying details for these :)
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.
Yeah, wrapping my head around the code here was a bit tough. I felt that placing my notes here for others is surely helpful.
--
Maybe here is a good place to ask:
I am a bit unsure of how big of a PR one would like to have for changes like that, say, a refactoring of a large file. ;)
For instance, I do have worked a bit further on that file here; I merged the duplicated code as much as possible and placed the classes in a hierarchy, but felt that the change is altogether too much for one single PR.
Of course, larger code changes need more time to review, but on the other hand it does not make to much sense to split changes up too much, does it?
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.
Definitely too much for one PR. I think that a good PR can be large, so long as it's easily summarized. My rule of thumb is the simple sentence summary:
"Splitting up the server into related files, but retaining functionality" makes sense.
"Refactoring socket code to reduce duplicated code" also makes sense.
Putting these two together may be too much.
015578d
to
f54852f
Compare
Description
There has already been done lots of work regarding the refactoring and restructuring of the server code (see #675).
The goal of this PR is to merge these changes with the current server version to make room for further improvements on top of that. And most importantly: not loosing work in the long-run that has already been done.
(Note: Even though I tagged this PR as "Part 1", the changes suggested are still fully functional).
To accomplish the merge of #675
master
.reapply all changes since server refactor
.(The other way round would be possible as well, but I felt this was easier in this case).
Some minor changes on the way:
get_visdom_path
to useimportlib
instead ofinspect
to get the actual file name of static files. (I found the previous version could have caching-problems with static files during development if I remember correctly).LAYOUT_FILE
andMAX_SOCKET_WAIT
todefaults.py
(to match its location to that of the other global uppercased config variables).from X import *
to specific imports).Note:
I needed to add a change in the github workflow just for this PR: As the file structure changed (the executable python file is
py/visdom/server
instead ofpy/visdom/server.py
), the startup of the server would not work anymore for the "init"-stage of the cypress tests.This (last) commit can basically be reverted after or removed before the merge.
How Has This Been Tested?
Just did a short test myself using the demo + tested against default cypress integration tests.
Types of changes
Checklist:
py/visdom/VERSION
according to Semantic VersioningChanged from
0.2.1
to0.2.2
.