-
Notifications
You must be signed in to change notification settings - Fork 30
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
Package Graph #102
Package Graph #102
Conversation
Maybe there are some parts that can be ported from the previous backend: https://github.com/mamba-org/mamba-navigator/blob/master/server/list_and_query.py |
}); | ||
if (ns.size >= 50) { | ||
return { | ||
name: 'circle', |
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.
Looking at the previous implementation from: https://github.com/mamba-org/mamba-navigator/blob/84a3d5a700b30017112d68b98fdd7e63adc9f182/src/components/Network.vue#L70
It looks like it was using the vis.Network
, which is likely to be the one from https://visjs.org:
Maybe it's a just a matter of using an equivalent as a cytoscape plugin to have a similar layout?
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, this one looks nicer.
I'll look for a similar layout and modify the backend to get the dependencies.
Maybe something like this one: https://cytoscape.org/cytoscape.js-cose-bilkent/
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.
it could also be good to have a lighter library than cytoscape.
Possible alternative:
- https://danielcaldas.github.io/react-d3-graph/docs/index.html
- vis.js has been splitted; the network part is there https://github.com/visjs/vis-network (react wrapper: https://github.com/crubier/react-graph-vis)
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 both for the info.
I changed the library and added an argument to the PackageHandler
API, so now we can request package dependencies.
Would be great to access this graph when clicking on a package in jupyter_conda
. Maybe having a new column for dependencies or a link in the package description to open the graph in a dialog
.
Let me know what do you think.
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.
Looks great!
Maybe having a new column for dependencies or a link in the package description to open the graph in a dialog.
Yes maybe that's the simplest and most visible way for now?
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 @hbcarlos It looks nice.
I left comments (quite a lot sorry).
I have also general question about the rendering. What happen in dark mode?
Could you add arrow to indicate the direction of the dependency?
Could you fade the node not directly dependent on the selected node?
I switch to
react-window
instead ofreact-virtualized
; the main change is where a cell renderer must be defined. Could you rebase your code please? Let me know if you need help.
jupyter_conda/envmanager.py
Outdated
{"package": List[dependencies]} | ||
""" | ||
resp = {} | ||
ans = await self._execute(self.manager, "repoquery", "depends", "--json", pkg) |
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 conda does not support this, the manager should be tested. And in this particular case a default value like {name: null
} to signify it can't be done is a good candidate.
jupyter_conda/envmanager.py
Outdated
if type(dep) is dict : | ||
deps = dep.get('depends', None) | ||
if deps : | ||
resp[dep['name']] = deps |
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 would returned an empty list rather than skipping the entry.
It seems strange to have:
pkg_depends("a") -> {"a": ["sub_a1", "sub_a2"]}
if a
has two dependencies. But
pkg_depends("b") -> {}
If b
has no dependency.
jupyter_conda/handlers.py
Outdated
query (str): optional string query | ||
""" | ||
pkg = self.get_query_argument("package", "") |
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 would rather use a query arguments like dependencies
equals to 0 or 1 to decide if we need to search or to get the dependencies (with default value to false).
See for example PackagesEnvironmentHandler.post
packages/common/package.json
Outdated
@@ -50,7 +50,11 @@ | |||
"@lumino/coreutils": "^1.3.0", | |||
"@lumino/signaling": "^1.2.0", | |||
"@lumino/widgets": "^1.6.0", | |||
"@types/react-d3-graph": "^2.3.4", |
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 a devDependencies
not a dependencies
packages/common/package.json
Outdated
"jupyterlab_toastify": "^4.1.2", | ||
"react": "^16.4.1", |
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.
"react": "^16.4.1", |
Unneeded as set as peerDependencies
packages/common/src/services.ts
Outdated
|
||
let idx: number; | ||
if (cancellable) { | ||
idx = this._cancellableStack.push(cancel) - 1; |
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.
Follow-up on cancellation changes:
idx = this._cancellableStack.push(cancel) - 1; | |
idx = this._cancellableStack.push({type: 'getDependencies', cancel}) - 1; |
} | ||
href="#" | ||
onClick={(evt): void => { | ||
this.props.onPkgGraph(rowData); |
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.
You need to stop the propagation of the event otherwise it will trigger an update or a remove action on the package.
this.props.onPkgGraph(rowData); | |
evt.stopPropagation(); | |
this.props.onPkgGraph(rowData); |
@@ -143,6 +147,23 @@ export class CondaPkgList extends React.Component<IPkgListProps> { | |||
return <span>{rowData.name}</span>; | |||
}; | |||
|
|||
const versionRender = ({ rowData }: ICellRender): JSX.Element => ( |
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.
What happen for not installed packages?
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.
Nothing. I think we should open this graph from another place, not from the version of the package but I'm not sure where to add 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.
What do you think of this mock-up?
The idea is to add an icon in the toolbar above the packages list (it will be absent if mamba is not available - or disabled with a title advertising mamba 😉 ).
On click on the button, this would open the dependency panel (not sure if on the right of the package list is a good place or if it needs to be a separated panel to allow positioning and resize by the user).
Then selecting a package will result in the display of its dependencies graph. If not package selected, a help message such Select a package to display its dependency graph.
This means also to change the current behavior as onClick on a row changes the status of the package. This should then be restricted to the status icon probably.
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.
Sounds good for me!
For Mamba, I would add a title in the toolbar when Mamba is not installed saying something like: "Install mamba to have all the functionalities" or maybe and alert icon to have a smaller icon in the toolbar.
if (this._package) this._updatePackages(); | ||
} | ||
|
||
public showGraph(pkg: string): void { |
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.
Unused?
|
||
import { Conda } from '../tokens'; | ||
|
||
export class PkgGraph extends ReactWidget { |
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.
Could you refractor this into a thin ReactWidget
and a React
component?
The React component would have:
- props
- pkgManager
- package
- state
- data: {nodes, links} | null
Call _updatePackages
in componentDidMount
and componentDidUpdate
_loading
is unneeded and could be replaced with _data === null
The idea is to have a component that will be easily extendable to display the dependency graph of an environment.
I applied all the changes except for:
Take a look and let me know if there is something wrong. |
I'll look at the test tonight or tomorrow. |
Pull Request Test Coverage Report for Build 388750202
💛 - Coveralls |
Great work @hbcarlos I have two requests regarding the style:
|
Sure, it's done. I'll do a new commit. Regarding:
Do you want to do it in this PR or open a new one? |
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 the reactivity, I added some final suggestions to finish simplifying the REST API and to add some documentation.
I also change a bit the default configuration because the font size of highlighted elements is not synchronized by default with the standard font size.
If you agree on those suggestions. Then we are good to go and pursuit as you suggested in another PR (I created #110 to keep track).
Thanks, @fcollonval. |
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 pushing this through @hbcarlos
A graph to visualize packages #83
The dependencies are not correct we need to get the dependencies of the packages to show them.
I'm reusing the code from jupyterlab-plugin-graph