.to_absolute_path() works but not inside a multirun with the joblib launcher plugin
If main.py contains something like
hydra.utils.to_absolute_path('./some_file.txt')
This will work when running
python main.py foo=bar
but not
python main.py -m foo=bar
In the second case, the expanded version of some_file.txt is not in the same directory as main.py but is in the multirun output directory instead.
This problem only seems to occur when using the joblib launcher with
defaults:
- hydra/launcher: joblib
hydra-core==1.0.0rc1 and hydra-joblib-launcher==1.0.2Thanks for reporting, feel free to dig a bit and send a PR if it's urgent.
Thanks, it's not urgent as it seems the bug only applies to relative paths.
I tested it directly on the example application and it seems good.
Closing, feel free to reopen if you are still seeing it and can help reproduce.
(hydra38) omry@Coronadev:~/dev/hydra/plugins/hydra_joblib_launcher/example$ git diff
diff --git a/plugins/hydra_joblib_launcher/example/my_app.py b/plugins/hydra_joblib_launcher/example/my_app.py
index 3f9e2c5a..0e1ac575 100644
--- a/plugins/hydra_joblib_launcher/example/my_app.py
+++ b/plugins/hydra_joblib_launcher/example/my_app.py
@@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
@hydra.main(config_path="config.yaml")
def my_app(cfg):
log.info(f"Process ID {os.getpid()} executing task {cfg.task} ...")
-
+ log.info(hydra.utils.to_absolute_path('./some_file.txt'))
time.sleep(1)
Regular run:
(hydra38) omry@Coronadev:~/dev/hydra/plugins/hydra_joblib_launcher/example$ python my_app.py
[2020-04-16 17:33:09,637][__main__][INFO] - Process ID 5848 executing task 1 ...
[2020-04-16 17:33:09,638][__main__][INFO] - /home/omry/dev/hydra/plugins/hydra_joblib_launcher/example/some_file.txt
Multirun the Joblib launcher:
(hydra38) omry@Coronadev:~/dev/hydra/plugins/hydra_joblib_launcher/example$ python my_app.py -m
[2020-04-16 17:33:19,168][HYDRA] Joblib.Parallel(n_jobs=10,backend=loky,prefer=processes,require=None,verbose=0,timeout=None,pre_dispatch=2*n_jobs,batch_size=auto,temp_folder=None,max_nbytes=None,mmap_mode=r) is launching 1 jobs
[2020-04-16 17:33:19,169][HYDRA] Launching jobs, sweep output dir : multirun/2020-04-16/17-33-19
[2020-04-16 17:33:19,169][HYDRA] #0 :
[2020-04-16 17:33:19,538][__main__][INFO] - Process ID 6023 executing task 1 ...
[2020-04-16 17:33:19,538][__main__][INFO] - /home/omry/dev/hydra/plugins/hydra_joblib_launcher/example/some_file.txt
Hi @omry apologies for this. For some unknown reason I'm also currently unable to reproduce this bug.
Thanks so much for looking into it and adding the test in any case.