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.

[Bug] %run magic with jupyter notebook

See original GitHub issue

🐛 Bug

Expect to run hydra in a notebook cell and get realtime output like in Terminal.

Two ways of running a python file in Jupyter !python (calling the terminal directly) -> but cannot get real time output %run (Jupyter way of running python file, but does not seems compatible with Hydra directly)

I am expecting this can run %run runner.py exp_name=abc

To reproduce

hydra_tqdm_notebook.py

import hydra
@hydra.main(config_path="configs/config.yaml")
def experiment_runner(cfg) -> None:
    from tqdm import tqdm_notebook as tqdm


    for i in tqdm(range(5)):
        import time
        time.sleep(0.02)
        print('helloworld')

if __name__ == "__main__":
    experiment_runner()

** Stack trace/error message ** image

Expected Behavior

The only difference between test_hydra_tqdm_notebook.py and test_tqdm_notebook.py is I wrapped it inside the Hydra runner. I expect the output to be the same. image

System information

  • Hydra Version :
  • Python version :
  • Virtual environment type and version :
  • Operating system :

Additional context

test_tqdm_notebook.py

from tqdm import tqdm_notebook as tqdm
for i in tqdm(range(100)):
    import time
    time.sleep(0.02)
    print('helloworld')

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
omrycommented, Mar 7, 2020

Your example is a bit convoluted. can you try to minimize it a bit? I am not sure I understand the role of each of the 3 files.

0reactions
omrycommented, Apr 14, 2020

Hi, It also happened in The Jupyter Lab Terminal: image image

I have a fix coming for this issue (%run). If this does not solve the other problem file a different issue and explain how to reproduce. I have never used Jupyter Lab Terminal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in magic commands — IPython 8.7.0 documentation
Changed in version 7.3: When running code, user variables are no longer expanded, the magic line is always left unmodified. positional arguments: statement...
Read more >
Magic Commands - Problem Solving with Python
One of the most popular magic commands is: %matplotlib inline. Entering the %matplotlib inline command at the top of a Jupyter notebook renders...
Read more >
iPython/Jupyter %run magic appending .py to filename and ...
I am running this code in two notebooks in the same directory, however, in one of them I get this error: ERROR:root:File `'../Tools/imports....
Read more >
Episode 2: How to use Jupyter Notebook's Magic Commands?
Refer this for more - http://ipython.readthedocs.io/en/stab... … Show more ... running jupyter notebooks on a remote cluster. Tyler Matheny.
Read more >
Tracking Jupyter Notebooks - Documentation - Weights & Biases
On the overview tab of your run page, you'll see a link to the Colab. 2. Jupyter Magic: ...
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