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

After a a println command "Ok" is printed instead of the actual string to be printed. #3

Closed
oroszgy opened this issue Sep 29, 2016 · 12 comments

Comments

@oroszgy
Copy link

oroszgy commented Sep 29, 2016

Having the row

println("hello")

Ok is printed and not "Hello"

@happy15
Copy link

happy15 commented Nov 12, 2016

+1

@apatrida
Copy link
Contributor

The result of println(...) is of type Unit and therefore on that type of response the Ok is printed as a result of the call. If you want to print "Hello" you can just put that string. or for example of a variable:

>>> val x = 10;
Ok

>>> x
10

Do other interpreters copy the output of stdout to the response?

@apatrida
Copy link
Contributor

So for something that returns Unit type, we can print <no return value> instead to make it clearer, ... I'm asking about capturing standard-out from the reply eval engine now, if so we can fix capturing stdout output as well.

@oroszgy
Copy link
Author

oroszgy commented Dec 29, 2016

Hi, thanks for the reply. Other interpreters tend to capture the stdout, so I think that would be a useful feature here as well.

@apatrida
Copy link
Contributor

I did a quick hack to check capturing stdout, and I was able to do so. But, it isn't pretty. Need to see if the evaluator can have it set directly instead of changing the global System.out printstream.

@apatrida
Copy link
Contributor

Ok, basically just forking the System.out both to the console and to the publishing of output back to Jupyter. Anything running that does output will accidentally send data back to Jupyter, so inadvertant output could come back. And not sure if Jupyter limits how much it accepts so that it doesn't end up with megs of data coming back on some accident. I think a configuration parameter would be good for turning the forking of stdout on, and also the limit per eval call that could be sent back as a fail-safe.

@apatrida
Copy link
Contributor

I have some refactoring to do, then will commit fixes for this and the repeat crash later...

@apatrida
Copy link
Contributor

When piping stdout back, it shows up in jupyter-console, but in jupyter-notebook it does not. So therefore stdout has to be mapped back as the return value. I'll take a look to see what other kernels do in the same situation (if they pass back something with a mime type, or just as a text value, ...)

@apatrida
Copy link
Contributor

If you want, please try my fork at https://github.com/apatrida/kotlin-jupyter

and I'll do a PR from there based on feedback.

@apatrida
Copy link
Contributor

screen shot 2016-12-29 at 11 06 44 am

@apatrida
Copy link
Contributor

What does not work is if you do output AND return a value, the value will win.

@apatrida
Copy link
Contributor

@ligee please close, fixed in previous PR

ileasile added a commit that referenced this issue Feb 8, 2021
ileasile added a commit that referenced this issue Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants