Hydra: [Bug] hydra.utils.to_absolute_path() does not work properly with the joblib launcher plugin

Created on 15 Apr 2020  路  5Comments  路  Source: facebookresearch/hydra

馃悰 Bug

.to_absolute_path() works but not inside a multirun with the joblib launcher plugin

To reproduce

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

System information

  • Hydra Version : hydra-core==1.0.0rc1 and hydra-joblib-launcher==1.0.2
  • Python version : 3.7.7
  • Virtual environment type and version : Miniconda
  • Operating system : Mac OS X
bug

All 5 comments

Thanks 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.

541 is adding an explicit test for this and as far as I can tell to_absolute_path works as expected in all launchers, including the joblib launcher.

  1. please be sure that both your Hydra and joblib plugin are installed from master.
  2. Please try to reproduce again, if you are still able to reproduce please provide a runnable minimal example:
    something like a zip with a python file printing the output of the function, with the config you are using, as well as the command you are using to reproduce.

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.

Was this page helpful?
0 / 5 - 0 ratings