-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
[Bug] %run magic with jupyter notebook #481
Comments
Please edit your bug report to a minimal example to reproduce the problem, will full source code of the runner code and the cell itself. Also, explain what is it you are trying to do. |
jupyter/notebook#4048 (This issue shows why I want to use %run because I need to get realtime terminal output) For the first image (expected output), I want the progress bar can be print realtime in notebook. (This example without using hydra yet) The problem is when I try to use %run, it does not play well with hydra. with tqdm/tqdm_notebook, it does not matter much, the point is, I need to use %run to get the correct output from terminal. If I use !python, the output does not return until the entire program is finished |
I will take a look at this, but this is really not a supported mode now. |
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. |
Thanks for updating your example and for providing additional context. Take a look at the compose API I linked above. with some slight refactoring you can use it to compose the config in the Notebook instead of relying on @hydra.main() in the notebook. |
Sure, I will try using the notebook API instead, thanks! I like to use a notebook even just for running terminal commands because it cache output and I can log some high-level information for my experiment naturally inside just one notebook. If I need to use the notebook API, all logical code with stay with the config, and I may need 1 notebook for 1 experiment What I would like to do is something like Experiment 1%run runner exp_name=1 Experiment 2%run runner exp_name=2 |
I understand, but Hydra was never tested using %run, and clearly it does not work. If you really want to run Hydra as a process, use the Python
def train(cfg):
...
@hydra.main(config_path="config.yaml")
def my_app(_: DictConfig) -> None:
train(cfg)
if __name__ == "__main__":
my_app()
import hydra.experimental
from train import train
hydra.experimental.initialize()
cfg = hydra.experimental.compose("config.yaml", overrides=["model=resnet50", "lr=0.1"])
train(cfg) # call your train function with the composed cfg |
🐛 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
** Stack trace/error message **
Expected Behavior
The only difference between
test_hydra_tqdm_notebook.py
andtest_tqdm_notebook.py
is I wrapped it inside the Hydra runner. I expect the output to be the same.System information
Additional context
test_tqdm_notebook.py
The text was updated successfully, but these errors were encountered: