bwhmather / ssort

Tool for automatically sorting python statements within a module
MIT License
358 stars 10 forks source link

Support Jupyter notebooks #76

Open gsganden opened 1 year ago

gsganden commented 1 year ago

Would it be feasible and desirable to extend ssort to support Jupyter notebooks? Jupyter supports running cells out of order, which makes it easy to have a notebook that won't run top to bottom. Using ssort to arrange the cells (and content within cells?) in an order that respects dependencies could be a helpful tool for resolving those issues.

bwhmather commented 1 year ago

I must confess that I have no idea how to go about it. In particular, I'm not certain what the workflow would look like, and basically whether it would be safe to run ssort offline on a notebook file or if it would need to be built in to jupyter somehow.

I do expect that sorting Jupyter notebooks would require a lot of the same dependency analysis that we already have in ssort so, if the workflow does make sense, I think it would be appropriate for us to support it in this repo. I would also not be opposed to increasing the python API surface area if necessary to support sorting directly in Jupyter.

I am personally only a very light user of jupyter, and this is therefore not something I can commit to lead on, but I would be very happy to review PRs or talk you through any parts of the code that might not be obvious. I believe that ssort is already used in https://github.com/joouha/euporie to sort code within cells, so that would probably be the first place to look.

Short answer: Desirable: in some form, absolutely, certainly, yes. Feasible: probably. When: due to constraints on my own time I am going to have mark this as Help Wanted.