Question: expected behavior when running on the same hydra.run.dir #2108
Unanswered
yuvalkirstain
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The current behavior is not to trigger an exception. On the second run:
If you want to check whether # my_app.py
import os.path
from typing import Any
from omegaconf import DictConfig
import hydra
from hydra.experimental.callback import Callback
class MyCallback(Callback):
def on_run_start(self, config: DictConfig, **kwargs: Any) -> None:
if os.path.exists(config.hydra.run.dir):
raise BaseException("Output dir already exists!")
def on_multirun_start(self, config: DictConfig, **kwargs: Any) -> None:
if os.path.exists(config.hydra.sweep.dir):
raise BaseException("Output dir already exists!")
@hydra.main(config_path=".", config_name="config")
def my_app(cfg: DictConfig) -> None:
print("app ran")
if __name__ == "__main__":
my_app() # config.yaml
hydra:
callbacks:
my_callback:
_target_: my_app.MyCallback
run:
dir: ./outputs/my_experiment
sweep:
dir: ./outputs/my_multirun_experiment Note that this implementation raises a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
If I change the config with:
and then I run more than once the experiment (either one after the other or concurrently), what will happen inside
./outputs/my_experiment
?I would expect it to end with an exception because this dir should be unique, but want to make sure.
Beta Was this translation helpful? Give feedback.
All reactions