In my config file, test_config.yaml I have:
DATA:
BGR: true
COCO_ANNOTATIONS: null
CROP_HEIGHT: 64
CROP_WIDTH: 256
DATA_DIR: ../datasets/train
* Minimal Code/Config snippet to reproduce *
import hydra
@hydra.main(config_name="test_config.yaml")
def run(cfg):
print(os.getcwd())
* Stack trace/error message *
normal_work_dir/outputs/2020-08-26/12-40-31
The normal working directory should not change.
/
This is the default Hydra behavior. More info can be found on this doc https://hydra.cc/docs/next/tutorials/basic/running_your_app/working_directory
If you want the path to work in the you original working dir, you can do
hydra.utils.get_original_cwd()
We do have an open issue to support disabling this behavior :) https://github.com/facebookresearch/hydra/issues/910
@jieru-hu : Thanks for linking to the docs. I tried searching for it, but I didn't find it. My bad!
To me, it's a bit counter-intuitive that the whole cwd changes inside the decorated function.
Anyway, nice to hear we might be able to disable it in the future.
Hi, how exactly should one use hydra.utils.get_original_cwd() ? I tried adding os.chdir(the_correct_dir) before my function call in hydra, however the relative imports are still not working.
hydra.utils.get_original_cwd()
Did you try ?
os.chdir(hydra.utils.get_original_cwd())
Pls provide a mini repro so its easier for us to help you.
Relative imports (Python imports) has nothing to do with the cwd.
Please file a different issue with a minimal repro.
Most helpful comment
This is the default Hydra behavior. More info can be found on this doc https://hydra.cc/docs/next/tutorials/basic/running_your_app/working_directory
If you want the path to work in the you original working dir, you can do
hydra.utils.get_original_cwd()