Skip to content
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

few ideas about gonb #119

Open
HaveF opened this issue May 18, 2024 · 3 comments
Open

few ideas about gonb #119

HaveF opened this issue May 18, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@HaveF
Copy link

HaveF commented May 18, 2024

First of all, thank you very much for your repo, I find it very interesting. Because I am a newcomer to the Go language, I am still exploring many places. Because of gonb, then I think it will be very convenient for me to record my learning code and results.

I have some more ideas for reference. Since I noticed that you are an expert in machine learning, I will keep it short.

I don’t know if you know the nbdev library (related to fast ai, you may know it). There are some points in its library that I think we can learn from:

  • #| default_exp core command, this command can export the contents of the current notebook to core.py , which can be combined with the existing py ecosystem. I feel like gonb could also borrow this idea.
  • nbdev's buiding, testing and release process is very smooth. You can even write something and publish it on pip or conda in less ten minutes. I feel like we can learn from this part of the content. Maybe we can make our Developing Go libraries process better.

Of course, the objects faced by these two libraries are different, and the usage scenarios will be very different. reinventing the wheel is not a good thing. It's just that I don't have a way to combine the benefits of these two tools. But in short, these are some rough thoughts when I first observed your tool, for reference!

Thanks again for your repo!

@janpfeifer janpfeifer added the enhancement New feature or request label May 20, 2024
@janpfeifer
Copy link
Owner

hi @HaveF , thanks for the comments, and sharing the ideas -- sorry I'm travelling this week and next, so I'm not so responsive.

I quickly browsed nbdev and loved it -- if I understood correctly. It seems very doable to create a plugin, or separate code in Go that would do something similar (but not exactly the same) for gonb.

I've discussed about adding code generation with AI, probably using Ollama, and it's high in my todo list. It's just that ... it's some amount of work and I confess I haven't figured out exactly what is the abstraction to use: gonb is a kernel, and it can change the code it maintains for the user, but it's not able to create a new cell and inject the generated code there for the user to review / edit. There is a typescript extension for that in JupyterLab, but I never got the time to learn typescript and figure out JupyterLab build system to develop something like that. We are taking contributions if this is a project that entices you.

I haven't figure out btw how the #| default_exp core command works ... I wonder if this is an extension for the ipython kernel, or if nbdev is a kernel itself ? Any ideas how it works ?

cheers

ps.: again apologies if I take a while to respond this coming week.

@HaveF
Copy link
Author

HaveF commented May 20, 2024

@janpfeifer I don’t think it has anything to do with Typescript. nbdev is a pure python package that was developed by itself --- if I understand correctly, it just defines some opinionated annotations by default, then parses the ipynb file and extracts these agreed annotated cells into in a separate file.

This process feels the same as yours.

Whenever a cell is executed, gonb saves the cell content of the cell to a Go file, auto-imports missing dependencies (when it can guess), compiles and runs it. It may seem a lot, but its pretty fast (except maybe the first cell run that is usually a little slower) and feels interactive.

Easy, right ? Now when trying different things, to avoid having to write func main() at every cell, gonb provides a short cut: "%%". Anything after a "%%" will be wrapped inside a func main() { ... }.

%%
fmt.Printf("Hello World!")

My idea is to borrow the concept of nbdev. Image:

  • %%| export_exp src/db/db.go Configure which go file the content should be exported to. Or //| export_exp src/db/db.go, something like that.
  • %%| export Configure this cell should be exported.
  • If the cell without any annotations. Just run it as your current default behavior.

Maybe it needs to be designed opinionated annotations, I just gave an example above. Literary programming is very attractive. Feel free to explore in the notebook, leave some ideas, experiments and even tests, and finally export some pure exploration results.

Have a nice trip :-)

@HaveF
Copy link
Author

HaveF commented May 20, 2024

Here is it's nbdev's api design notebook, we can see Jeremy's API design thinking process in it. After he finished the notebook, the api is done. I can only use nbdev now, but I can’t change its code yet(Although I don’t quite understand it yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants