question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Actor not printing when launched in jupyter

See original GitHub issue

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • Ray installed from (source or binary): pip3 install ray
  • Ray version: 0.6.1
  • Python version: 3.5.2
  • Exact command to reproduce: run following code from inside a Jupyter notebook or from a vanilla python file

Describe the problem

Printing inside actors should show up in the stdout/stdrr or at least in logs when launched from inside a Jupyter notebook. For the moment, nothing is visible.

Source code / logs

import ray
ray.init()

@ray.remote
class Counter(object):
    def __init__(self):
        self.value = 0

    def increment(self):
        self.value += 1
        print(self.value)
        return self.value
    
c = Counter.remote()
print(ray.get(c.increment.remote()))

Give 1 then 1 when python3 test.py but only 1 inside notebook.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
robertnishiharacommented, Jan 5, 2019

Interesting, I can reproduce it. The actor print statements seem to be redirected to my terminal where I ran jupyter-notebook (also it wasn’t flushed immediately).

I can reproduce it even more easily in a Jupyter notebook just by running

import subprocess
subprocess.Popen(['ls'])

That will show up in the terminal where you started the jupyter-notebook and not in the notebook itself.

0reactions
ErikEngerdcommented, Dec 26, 2020

Still not working for me. Using ray 1.1.0

ray.init(ignore_reinit_error=True)
@ray.remote
def getcwd():
    cwd = os.path.realpath(".")
    print(cwd)
    return cwd
ray.get(getcwd.remote())

OS: centos 7

> pip list | grep jupyter
jupyter                            1.0.0              
jupyter-client                     5.3.4              
jupyter-console                    6.1.0              
jupyter-contrib-core               0.3.3              
jupyter-contrib-nbextensions       0.5.1              
jupyter-core                       4.6.1              
jupyter-highlight-selected-word    0.2.0              
jupyter-latex-envs                 1.4.6              
jupyter-nbextensions-configurator  0.4.1              
jupyterlab                         1.2.6              
jupyterlab-server                  1.0.6   

The weird thing is that I see the expected output when I use the jupyter-lab interface but not when using the old jupyter notebook interface. So switching to the new interface fixes the issue. To be specific: new interface is the lab URL (animation when launching), old interface is the tree URL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

why there is no printout when using #[derive(Debug)] for rust ...
I am new in rusting studying. when i am trying to execute some codes written by Rust in jupyter-notebook. I can not get...
Read more >
Bluehive jupyter
Formed as an exhibit and design firm focused on revamping and revitalizing the exhibit world, BlueHive transitioned from merely creating static spaces to ......
Read more >
What to do when things go wrong - The Jupyter Notebook
If you're using a menu shortcut or Anaconda launcher to start it, try opening a terminal or command prompt and running the command...
Read more >
Is it bad practice to start with Jupyter Notebooks? - Reddit
You wrap that in the function, replace the print with return if needed, add the missing attributes to the def, and test it...
Read more >
Working with Jupyter Notebooks & JupyterLab — Ray 2.2.0
This causes Ray to pin the objects even though you application may not actually be using them. Therefore, explicitly calling print or repr...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found