Code Monkey home page Code Monkey logo

gonb's People

Contributors

dougnut897 avatar janpfeifer avatar manics avatar neomantra avatar potoo0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gonb's Issues

docker pull image source can't not find

Is it a spelling error in README.md docker pull ?

What happen :
Execute docker pull janpfeifer/gonb_jupyter:latest return error message.

Message:
Error response from daemon: pull access denied for janpfeifer/gonb_jupyter, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

Suggestion:
docker pull janpfeifer/gonb_jupyter:latest => docker pull janpfeifer/gonb_jupyterlab:latest.

Compiler flags (and output?)

Hi @janpfeifer, I have some more special questions:

  • Can we add compiler flags? I was writing some benchmark code and wondered if I can get the output if go build -gcflags="-m" somehow (yeah, crazy to do that in the notebook).
  • Could we run the code with go test instead of go run? I guess that will only work for the full notebook, though?

Both if it is not critical. I just wonder if it would be possible and "easy" to implement?

gonb command is not found following the install commands on the github

see title, can you please add a little detail around how the final installation should look, where should i see x, y and z? it would really help adoption to make the install process as simple as possible without leaning on docker.

reference pocketbase for a simple install process.

❯ go version
go version go1.21.1 linux/amd64
❯ go install github.com/janpfeifer/gonb@latest &&
go install golang.org/x/tools/cmd/goimports@latest &&
go install golang.org/x/tools/gopls@latest &&
gonb --install
go: downloading github.com/janpfeifer/gonb v0.8.0
go: downloading k8s.io/klog/v2 v2.100.1
go: downloading github.com/go-zeromq/zmq4 v0.15.0
go: downloading golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
go: downloading github.com/pkg/errors v0.9.1
go: downloading github.com/fsnotify/fsnotify v1.6.0
go: downloading github.com/gofrs/uuid v4.4.0+incompatible
go: downloading github.com/go-language-server/jsonrpc2 v0.4.2
go: downloading github.com/go-language-server/protocol v0.7.0
go: downloading github.com/go-language-server/uri v0.2.0
go: downloading golang.org/x/mod v0.12.0
go: downloading github.com/fatih/color v1.15.0
go: downloading github.com/mattn/go-isatty v0.0.19
go: downloading github.com/mattn/go-colorable v0.1.13
go: downloading golang.org/x/sys v0.11.0
go: downloading github.com/go-logr/logr v1.2.4
go: downloading go.uber.org/zap v1.25.0
go: downloading golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
go: downloading golang.org/x/text v0.12.0
go: downloading golang.org/x/sync v0.3.0
go: downloading go.uber.org/multierr v1.11.0
go: downloading golang.org/x/tools v0.13.0
go: downloading golang.org/x/sys v0.12.0
go: downloading golang.org/x/tools/gopls v0.13.2
go: downloading honnef.co/go/tools v0.4.2
go: downloading mvdan.cc/gofumpt v0.4.0
go: downloading mvdan.cc/xurls/v2 v2.4.0
go: downloading golang.org/x/tools v0.11.2-0.20230810185051-cc6b5804b8cf
go: downloading golang.org/x/sys v0.10.0
go: downloading github.com/sergi/go-diff v1.1.0
go: downloading golang.org/x/vuln v0.0.0-20230110180137-6ad3e3d07815
go: downloading golang.org/x/text v0.11.0
go: downloading github.com/google/go-cmp v0.5.9
go: downloading golang.org/x/exp/typeparams v0.0.0-20221212164502-fae10dda9338
go: downloading github.com/BurntSushi/toml v1.2.1
go: downloading golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e

zsh: command not found: gonb

❯ gonb
zsh: command not found: gonb
❯ go

Feature Request: Cache Values

Hi Jan!

Thanks for the great work. It already became my favorite Go kernel and I'm using it on a JupyterHub cluster.
One thing, however, would be great: When declaring functions, types or variables they can be re-used over multiple cells. But, if a variable is holding the results of a function call

var lotsOfData = LoadOverTheInternet("https://.....")

and this variable is used later in another cell

%%
processData(lotsOfData)

then not the initial result that was loaded in the previous cell is used, but the function call is executed again.
Is there any chance to cache the data instead of executing the function over and over again?

BTW: If you need a Dockerfile, I already have (although a bit specific, since it is running in our cluster with some custom modifications)

Error with `gonbui.RequestInput()`?

I am sure we used gonbui.RequestInput() before and it worked, now we get an error. I tried to use the exact example from the tutorial an get:

GoNB Error:
A MIMEJupyterInput sent to GONB_PIPE without an associated protocol.InputRequest!?
github.com/janpfeifer/gonb/internal/jpyexec.(*Executor).pollNamedPipeReader
	/Users/anon/go/pkg/mod/github.com/janpfeifer/[email protected]/internal/jpyexec/namedpipes.go:187
runtime.goexit
	/usr/local/Cellar/go/1.21.4/libexec/src/runtime/asm_amd64.s:1650

This happens on at least two different systems (both running jupyter lab locally on mac, one intel one m1)

Strange effect with `!* go mod edit` which may need some documentation or some better solution.

I use !* go mod edit -replace git.jetbrains.space/metatexx/mxc/hog="/Users/$(id -un)/devsys/workspace/go/hog" in my first cell. But I want to do A/B testing and when I comment out this line. Thego.mod file does not "revert". I need to use an additional entry with !* go mod edit -dropreplace git.jetbrains.space/metatexx/mxc/hog to get rid of it. Could that be solved differently?

maybe add some icons

jupyterlab(4.0.10) "Running Terminals and Kernels" tab has render bug when no icons for the kernel (issues: jupyterlab/jupyterlab#14962),
maybe we can get those from go.dev.

go.dev icon:

kernel spec folder structure:

kernel.json
logo-32x32.png
logo-64x64.png
logo-svg.svg

Resource reference: https://github.com/jupyterlab/jupyterlab/blob/eff7d42d5437a1f7eef6ab88d96406c5eb5ec2c5/packages/running-extension/src/kernels.ts#L232

No autocompletion when using it on my Mac (Intel)

The problem is that I do not get auto-completion when running it on my Mac.

I compared the Colab version vs running locally and running through docker on the Mac. I got the code completion only using the Colab notebook. Which makes me wonder. Shouldn't the docker image work too? I am also on an Intel Mac, so the image should just run as everywhere.

I used it with Jupyter installed through homebrew, through conda with a manually pip install and through conda with the official jupiterlab installation.

I am going to check everything on Linux and Windows too.

About integration testing

You write in the README, that you did not find a good way to test with the running notebook. I wrote an (internal) testing package for our PWA using rod. There is some raw example code at rodgoapp. Maybe this goes into a direction you could use?

Plotly and HTML Widgets not working in VSCode

I was working to add go-echarts support for GoNB -- and was using VSCode to do so. Nothing was coming up and I was confused, but then I realized I should try out the Plotly integration first.

It ends up that the Plotly integration, along with the HTML widgets, do not work in VSCode (v1.87.2 on OSX). Simple HTML like the "I ❤️ GoNB!" work fine. The SVG, images, and text input widgets also work in VSCode, but noting that the Text Input ends up via a VSCode command palette-style.

These do work on my system using inside the Docker-based Jupyter notebook within a web browser.. ,except the Animated Widget appears but doesn't seem to do anything? So I'll continue trying out Echarts there and see how it goes.

This is what the output looks like, with an empty cell and then a cell that echos some code:
image

I can push on this more with some guidance. Thanks for this great tool!!

Change default username to something generically impersonal

To make using this in a professional capacity a tad easier, could the images published to the docker hub carry an impersonal username for the default user? Making this a build-arg would also be cool. It's just one less point of friction for using this at work.

The user for the images currently available on docker hub is "jovyan". Something like "gopher" or "notebook" would be less concerning if I or someone else had to shell into the instance or mount user-space files.

Making the username a build-arg, while not certainly feasible, might also be a pleasant touch for contextualizing the application to different spaces and conventions. It's easy enough to clone, modify, build, and push to my workplace's private image repo, contextualized as needed, but it would be nice to have that bit be hands-off, assuming that's viable.

Mac Installation

The README is not obvious, I've first tried it on Linux, then realized it's not working by itself on Mac.

The proper path on Mac to install the kernel is: /Users/${USER}/Library/Jupyter/kernels/

For the folks on Mac after gonb --install, just move the kernel definition to:

 mv /Users/${USER}/.local/share/jupyter/kernels/gonb  /Users/${USER}/Library/Jupyter/kernels/

Great work thanks for gonb!

fmt Scan* input prompt

It does not give an input prompt and One needs to interrupt as well
I'm using Sscan for now.

Generics on structs not working?

Hi Jan!

Just came across another problem connected with generic structs. The following code ...

type Model[T any] struct {
    Data T
}

results in

 # gonb_0224f8ff 
Cell[8]: Line 2 ./main.go:9:10: undefined: T 

Any workaround or quick fix available?

Tabs are added to raw strings

Hi Jan!

Looks like your are using some code beautifier behind the scenes? This has some unwanted aspects on raw strings. Here's an example:

result := 
`This is some text!
It is stored in a file!
Every file needs to have an end.
`
fmt.Println(result)

This produces:

This is some text!
	It is stored in a file!
	Every file needs to have an end.

Any idea how to fix this?

Unable to get gonb working on Raspberry pi

Hi,
I have jupyter lab running on a Pi 4 machine. The python part of Jupyter is working, but I'm having issues getting gonb to work. I'm able to run go on the CLI and I can type gonb on the CLI and get the help menu back. But when I try to open a Gonb notebook I get the following error:

Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]: [W 2023-07-11 15:16:55.403 ServerApp] wrote error: "[Errno 2] No such file or directory: 'gonb'"
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     Traceback (most recent call last):
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/sessions/handlers.py", line 89, in post
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         model = await sm.create_session(
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 287, in create_session
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         kernel_id = await self.start_kernel_for_session(
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/sessions/sessionmanager.py", line 345, in start_kernel_for_session
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         kernel_id = await self.kernel_manager.start_kernel(
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 233, in _async_start_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         kernel_id = await self.USERnned_superclass._async_start_kernel(self, **kwargs)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/multikernelmanager.py", line 219, in _async_start_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise km.ready.exception()  # type: ignore
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/multikernelmanager.py", line 166, in _add_kernel_when_ready
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         await kernel_awaitable
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_core/utils/__init__.py", line 182, in ensure_async
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         result = await obj
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 773, in wrapped_method
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise err
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 740, in wrapped_method
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         out = await method(self, *args, **kwargs)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/kernels/kernelmanager.py", line 842, in start_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         return await super().start_kernel(*args, **kwargs)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/manager.py", line 93, in wrapper
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise e
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/manager.py", line 85, in wrapper
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         out = await method(self, *args, **kwargs)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/manager.py", line 401, in _async_start_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         await self._async_launch_kernel(kernel_cmd, **kw)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/manager.py", line 317, in _async_launch_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         connection_info = await self.provisioner.launch_kernel(kernel_cmd, **kw)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/provisioning/local_provisioner.py", line 208, in launch_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         self.process = launch_kernel(cmd, **scrubbed_kwargs)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/launcher.py", line 170, in launch_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise ex
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_client/launcher.py", line 155, in launch_kernel
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         proc = Popen(cmd, **kwargs)  # noqa
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         self._execute_child(args, executable, preexec_fn, close_fds,
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise child_exception_type(errno_num, err_msg, err_filename)
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     FileNotFoundError: [Errno 2] No such file or directory: 'gonb'
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     The above exception was the direct cause of the following exception:
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     Traceback (most recent call last):
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/tornado/web.py", line 1786, in _execute
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         result = await result
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       File "/home/USER/.local/lib/python3.9/site-packages/jupyter_server/services/sessions/handlers.py", line 107, in post
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:         raise web.HTTPError(500, str(e)) from e
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:     tornado.web.HTTPError: HTTP 500: Internal Server Error ([Errno 2] No such file or directory: 'gonb')
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]: [E 2023-07-11 15:16:55.408 ServerApp] {
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       "Host": "HOSTNAME:8888",
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       "Accept": "*/*",
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       "Referer": "https://HOSTNAME:8888/lab/tree/Untitled.ipynb",
Jul 11 15:16:55 HOSTNAME jupyter-lab[49147]:       "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"

I just upgraded to 0.7.2 this morning, and the jupyter server is running under the USER account.

If there's any other info you need please let me know.

Contextual help not activating in VsCode

Latest VsCode and Jupyter extension running on MacOS.

Can't get mouseover contextual help in gonb notebooks. Shift-Tab and Ctrl-I have no effect. Context help works fine in normal go files.

Screen Shot 2024-03-21 at 1 40 49 PM

few ideas about gonb

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!

Can't install gonb undefined: exec

My setup is clean go install using go env manager goenv but the same issue occurred when doing clean install without go version manager.
>go version
go version go1.21.1 darwin/arm64

When running
>go install github.com/janpfeifer/gonb@latest
I get this error:

# github.com/janpfeifer/gonb/internal/goexec
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:18:9: undefined: exec
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:18:36: undefined: strconv
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:19:2: undefined: klog
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:20:15: undefined: os
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:25:5: undefined: klog
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:26:3: undefined: klog
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:29:11: undefined: strings
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:31:6: undefined: strings
go/1.21.1/pkg/mod/github.com/janpfeifer/[email protected]/internal/goexec/cwd_others.go:32:11: undefined: strings

Additional info:

>echo $GOPATH
/Users/XXX/go/1.21.1
>echo $GOROOT
/Users/XXX/.goenv/versions/1.21.1

Not sure if some dependency is missing or if my setup has some issues.

class param with point not work

@janpfeifer Hi

import (
    "fmt"
	"net"
)

type Server struct {
	host string
	port string
}

// why *Server not work
// func (server *Server) Run() {} // Not Work
 func (server Server) Run() {} // Work

func main() {
    s := Server{}
    s.Run()
    fmt.Printf("Hello World!")
}

image

File: "main"
[6fe4fbbe] 2023/02/12 12:19:28 Executing: /tmp/gonb_6fe4fbbe/gonb_6fe4fbbe []
[6fe4fbbe] 2023/02/12 12:19:28 Execution finished successfully
[6fe4fbbe] 2023/02/12 12:19:28 Reply(execute_reply):
[6fe4fbbe] 2023/02/12 12:19:28 PublishKernelStatus()
[6fe4fbbe] 2023/02/12 12:19:56 PublishKernelStatus()
File: "main"
[6fe4fbbe] 2023/02/12 12:19:56 PublishKernelStatus()
panic: interface conversion: ast.Expr is *ast.StarExpr, not *ast.Ident

goroutine 29 [running]:
github.com/janpfeifer/gonb/goexec.(*State).ParseImportsFromMainGo(0xc00006efc0, 0xc000136c60, 0xc000153790)
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/goexec/parser.go:84 +0x9ec
github.com/janpfeifer/gonb/goexec.(*State).ExecuteCell(0xc00006efc0, 0xbb?, {0xc0001370e0?, 0x11?, 0x0?}, 0x0?)
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/goexec/execcode.go:31 +0x36b
github.com/janpfeifer/gonb/dispatcher.handleExecuteRequest(0xc000136c60, 0x6a7cde?)
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/dispatcher/dispatcher.go:244 +0x425
github.com/janpfeifer/gonb/dispatcher.handleMsg(0xc000136c60, 0xc000153f58?)
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/dispatcher/dispatcher.go:97 +0x1fa
github.com/janpfeifer/gonb/dispatcher.RunKernel.func1.1()
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/dispatcher/dispatcher.go:35 +0x113
created by github.com/janpfeifer/gonb/dispatcher.RunKernel.func1
/root/go/pkg/mod/github.com/janpfeifer/[email protected]/dispatcher/dispatcher.go:28 +0xea

error line is : 89,(*ast.Ident).Name

gonb/goexec/parser.go

Lines 84 to 89 in e732dac

case *ast.FuncDecl:
// Incorporate functions.
key := typedDecl.Name.Name
if typedDecl.Recv != nil && len(typedDecl.Recv.List) > 0 {
key = fmt.Sprintf("%s~%s", typedDecl.Recv.List[0].Type.(*ast.Ident).Name, key)
}

Imports, struct and functions can be reused in other cells but variables don't

First of all thanks for this project, it is just what I was looking for. Everything works really good and I had been struggling to use most recent Go versions with other kernels.

This is mostly a question. From the next example I understand that imports, struct and functions can be reused in other cells but variables don't. I assume it has to do with the magic of "%%". I found this other related issue and the cache solution but I don't fully understand the cause of the issue and if it has something to do with how I am using %% cells (am I doing it wrong?).

Thanks for your help and for this awesome project!

Screen Shot 2024-01-15 at 12 49 39 PM

Not working in VSCode

Hi

Just installed on Mac M1 and vscode jupyter noodbook from Microsoft. I get:

expected declaration, found Hello
in goexec.ExecuteCell(): parsing go files in TempDir "[/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/gonb_0acd825](https://file+.vscode-resource.vscode-cdn.net/var/folders/ws/r3lmtqdj03d3jn5l3v3t_s3w0000gn/T/gonb_0acd825a)

From this code

import "fmt"

func Hello(){
    fmt.Println("hello world!")
}

Hello()

support %%shell in GoNB runtime

currentlt %%shell return the error -
"%%shell" unknown or not implemented yet.
This enhancement can allow bash commands to be executed in one process.

Not an issue, but a nice way to use local modules in the notebook

I started to use gonb to develop and write examples for some modules of a framework that we are developing and found that quite helpful and elegant.

I use "go.work" files while adding features over multiple modules and packages. When using go mod edit you need to add package names and absolute paths. I prefer using go.work files and found a way to add them to the "gonb" notebook, that I find particular nice and wanted to share. It uses the directory names and the current user is evaluated.

!* rm -f go.work && go work init && go work use . "/home/$(id -un)/workspace/localmod"

Support for animated Plotly charts

I came across this gem very recently and I'm loving this kernel already! It's really a nice addition to the Go ecosystem.

I come from the Python world, where I'm used to work with timeseries data using interactive plots with Plotly. I found the go-plotly library (https://github.com/MetalBlueberry/go-plotly) that provides decent functionality to generate the plots I need, but as far as I could tell, I can only generate html files that are opened on a browser tab.

Is there any way I could generate a figure and render it directly in a gonb notebook? That would be a killer feature which would allow me to transition some of my data analysis to Go.

PS: I tried the other charting libraries, but static images are not good enough for my use cases.

jupyterhub support

Hello Jan,

great work, I try to get it running on jupyterhub, but seems its unable to start the prebuild container:

  • Running Jupyterhub Docker Based on 3.0

jupyter/scipy-notebook runs without issues.

Is it possible that the entrypoint for hub based images is different?

  • start-single_notebook.sh vs. jupyter lab (gonb)

https://github.com/jupyter/docker-stacks/tree/main/images/base-notebook

upyterhub | [I 2024-03-12 04:34:54.074 JupyterHub app:3160] JupyterHub is now running at http://:8000
jupyterhub | [I 2024-03-12 04:35:03.546 JupyterHub log:186] 200 GET /hub/home ([email protected]) 51.33ms
jupyterhub | [I 2024-03-12 04:35:12.859 JupyterHub log:186] 200 GET /hub/spawn/malte ([email protected])) 7.48ms
jupyterhub | [W 2024-03-12 04:35:17.659 JupyterHub dockerspawner:92] DemoFormSpawner.container_image is deprecated in DockerSpawner 0.9.*, use DemoFormSpawner.image instead
jupyterhub | [I 2024-03-12 04:35:17.695 JupyterHub provider:651] Creating oauth client jupyterhub-user-malte
jupyterhub | [I 2024-03-12 04:35:17.730 JupyterHub dockerspawner:988] Container 'jupyter-malte' is gone
jupyterhub | [I 2024-03-12 04:35:17.747 JupyterHub dockerspawner:1272] Created container jupyter-malte (id: d5fed29) from image janpfeifer/gonb_jupyterlab:v0.9.6
jupyterhub | [I 2024-03-12 04:35:17.747 JupyterHub dockerspawner:1296] Starting container jupyter-malte (id: d5fed29)
jupyterhub | [I 2024-03-12 04:35:18.662 JupyterHub log:186] 302 POST /hub/spawn/malte -> /hub/spawn-pending/malte ([email protected]) 1006.74ms
jupyterhub | [I 2024-03-12 04:35:18.695 JupyterHub pages:394] malte is pending spawn
jupyterhub | [I 2024-03-12 04:35:18.696 JupyterHub log:186] 200 GET /hub/spawn-pending/malte ([email protected])) 3.58ms
jupyterhub | [I 2024-03-12 04:35:27.666 JupyterHub dockerspawner:988] Container 'jupyter-malte' is gone
jupyterhub | [W 2024-03-12 04:35:27.666 JupyterHub dockerspawner:963] Container not found: jupyter-malte
jupyterhub | Task exception was never retrieved
jupyterhub | future: <Task finished name='Task-48' coro=<BaseHandler.spawn_single_user() done, defined at /usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py:844> exception=HTTPError()>
jupyterhub | Traceback (most recent call last):
jupyterhub |   File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 1051, in spawn_single_user
jupyterhub |     await gen.with_timeout(
jupyterhub | asyncio.exceptions.TimeoutError: Timeout
jupyterhub | 
jupyterhub | During handling of the above exception, another exception occurred:
jupyterhub | 
jupyterhub | Traceback (most recent call last):
jupyterhub |   File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 1085, in spawn_single_user
jupyterhub |     raise web.HTTPError(
jupyterhub | tornado.web.HTTPError: HTTP 500: Internal Server Error (Spawner failed to start [status=0]. The logs for malte may contain details.)
jupyterhub | [I 2024-03-12 04:35:48.084 JupyterHub dockerspawner:988] Container 'jupyter-malte' is gone
jupyterhub | [W 2024-03-12 04:35:48.085 JupyterHub dockerspawner:963] Container not found: jupyter-malte
jupyterhub | [W 2024-03-12 04:36:01.731 JupyterHub user:881] malte's server never showed up at http://172.23.0.3:8888/user/malte/ after 30 seconds. Giving up.
jupyterhub |     
jupyterhub |     Common causes of this timeout, and debugging tips:
jupyterhub |     
jupyterhub |     1. The server didn't finish starting,
jupyterhub |        or it crashed due to a configuration issue.
jupyterhub |        Check the single-user server's logs for hints at what needs fixing.
jupyterhub |     2. The server started, but is not accessible at the specified URL.
jupyterhub |        This may be a configuration issue specific to your chosen Spawner.
jupyterhub |        Check the single-user server logs and resource to make sure the URL
jupyterhub |        is correct and accessible from the Hub.
jupyterhub |     3. (unlikely) Everything is working, but the server took too long to respond.
jupyterhub |        To fix: increase `Spawner.http_timeout` configuration
jupyterhub |        to a number of seconds that is enough for servers to become responsive.
jupyterhub |     
jupyterhub | [I 2024-03-12 04:36:01.737 JupyterHub dockerspawner:988] Container 'jupyter-malte' is gone
jupyterhub | [W 2024-03-12 04:36:01.737 JupyterHub dockerspawner:963] Container not found: jupyter-malte
jupyterhub | [E 2024-03-12 04:36:01.799 JupyterHub gen:630] Exception in Future <Task finished name='Task-49' coro=<BaseHandler.spawn_single_user.<locals>.finish_user_spawn() done, defined at /usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py:954> exception=TimeoutError("Server at http://172.23.0.3:8888/user/malte/ didn't respond in 30 seconds")> after timeout
jupyterhub |     Traceback (most recent call last):
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/tornado/gen.py", line 625, in error_callback
jupyterhub |         future.result()
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 961, in finish_user_spawn
jupyterhub |         await spawn_future
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/user.py", line 862, in spawn
jupyterhub |         await self._wait_up(spawner)
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/user.py", line 906, in _wait_up
jupyterhub |         raise e
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/user.py", line 876, in _wait_up
jupyterhub |         resp = await server.wait_up(
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/utils.py", line 288, in wait_for_http_server
jupyterhub |         re = await exponential_backoff(
jupyterhub |       File "/usr/local/lib/python3.10/dist-packages/jupyterhub/utils.py", line 236, in exponential_backoff
jupyterhub |         raise asyncio.TimeoutError(fail_message)
jupyterhub |     asyncio.exceptions.TimeoutError: Server at http://172.23.0.3:8888/user/malte/ didn't respond in 30 seconds

Better support for error messages in dark mode

Hi, thanks for this interesting project!

I'm using this in vscode in dark mode, but the error messages are hard to read. My hunch is that the background highlighting is a fixed color which works well if the text is dark.
image

Here is the same message in light mode:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.