-
Notifications
You must be signed in to change notification settings - Fork 15
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
[UI] Import Jupyter notebook #369
Conversation
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! Attaching a few minor comments.
ui/src/lib/store/canvasSlice.tsx
Outdated
// NOTE for import ipynb: we need to specify some reasonable height so that | ||
// the imported pods can be properly laid-out. 130 is a good one. | ||
// This number MUST match the number in Canvas.tsx (refer to "A BIG HACK" in Canvas.tsx). | ||
height: 130, |
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 magic number 130
must be kept consistent with the 130
in Canvas.tsx
. Let's store it in one global variable and access it in both files. Also, we can use some floating number to mark it special, e.g., 136.66
.
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.
Given it's a hacky way to apply autolayout, I think we can use 130 here. We need to find a better way for autolayer eventually.
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.
Given it's a hacky way
Precisely because it is hacky, we want to avoid breaking it accidentally, by:
- using a global variable to avoid potential inconsistency error
- using some floating numbers to prevent a pod from being the same value.
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 see you have changed to a global variable. The floating number isn't that critical (as long as it's not 120).
ui/src/lib/store/canvasSlice.tsx
Outdated
dirty: true, | ||
pending: true, | ||
}); | ||
get().moveIntoScope(node.id, scopeNode.id); |
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.
The current moveIntoScope
function is pretty heavy because it calls the three heavy functions adjustLevel()
, updateView
, and buildNode2Children
at its end (ref). I can see it to be very slow when a repo becomes large.
Those three functions only need to be called once at the end of the ipynbImport action. So let's add a moveIntoScopeLight
without those three functions and use it here.
moveIntoScopeLight() {...}
moveIntoScope() {
moveIntoScopeLight();
get().adjustLevel();
get().updateView();
get().buildNode2Children();
}
importIpynb() {
...
for() {...
moveIntoScopeLight()
}
get().adjustLevel();
get().updateView();
get().buildNode2Children();
...
}
ui/src/lib/store/canvasSlice.tsx
Outdated
@@ -1003,7 +1068,7 @@ export const createCanvasSlice: StateCreator<MyState, [], [], CanvasSlice> = ( | |||
/** | |||
* Use d3-force to auto layout the nodes. | |||
*/ | |||
autoLayout: (scopeId) => { | |||
autoLayout: async (scopeId) => { |
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 was for debugging. Not needed.
Thanks @senwang86. Maybe the import menu can be moved to the navigation bar? |
I initially placed the "import button" in the navigation bar, but later realized that the user may want to control "where" the imported notebook is inserted. In the end, I capture the right-click position on canvas and utilize it as the insertion position. |
Good thoughts. |
Thanks, Sen! |
Hi @senwang86, can I make a minor additional feature request? Can you allow |
Sure, I believe we can begin by importing a |
Yes, importing one |
Please check #374 . |
@senwang86, please add support to import execution output from a ipynb when you have time |
Summary
Test
Follow-up