Hydra: [Bug] Joblib launcher plugin doesn't properly convert some joblib arguments to integers

Created on 27 Oct 2020  路  8Comments  路  Source: facebookresearch/hydra

馃悰 Bug

Description

The following joblib.Parallel arguments are currently provided as strings to joblib when they should be integers:

  • pre_dispatch
  • batch_size
  • max_nbytes

Checklist

  • [X] I checked on the latest version of Hydra
  • [X] I created a minimal repro

To reproduce

* Minimal Code/Config snippet to reproduce *

wget https://raw.githubusercontent.com/facebookresearch/hydra/master/examples/tutorials/basic/your_first_hydra_app/1_simple_cli/my_app.py
python my_app.py hydra.launcher.batch_size=1 hydra/launcher=joblib -m

* Stack trace/error message *

[2020-10-27 18:20:48,363][HYDRA] Joblib.Parallel(n_jobs=-1,backend=loky,prefer=processes,require=None,verbose=0,timeout=None,pre_dispatch=2*n_jobs,batch_size=1,temp_folder=None,max_nbytes=None,mmap_mode=r) is launching 1 jobs
[2020-10-27 18:20:48,363][HYDRA] Launching jobs, sweep output dir : multirun/2020-10-27/18-20-48
[2020-10-27 18:20:48,363][HYDRA]        #0 :
Traceback (most recent call last):
  File "/Users/odelalleau/src/hydra/hydra/_internal/utils.py", line 207, in run_and_report
    return func()
  File "/Users/odelalleau/src/hydra/hydra/_internal/utils.py", line 364, in <lambda>
    lambda: hydra.multirun(
  File "/Users/odelalleau/src/hydra/hydra/_internal/hydra.py", line 136, in multirun
    return sweeper.sweep(arguments=task_overrides)
  File "/Users/odelalleau/src/hydra/hydra/_internal/core_plugins/basic_sweeper.py", line 154, in sweep
    results = self.launcher.launch(batch, initial_job_idx=initial_job_idx)
  File "/Users/odelalleau/src/hydra/plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/joblib_launcher.py", line 45, in launch
    return _core.launch(
  File "/Users/odelalleau/src/hydra/plugins/hydra_joblib_launcher/hydra_plugins/hydra_joblib_launcher/_core.py", line 89, in launch
    runs = Parallel(**joblib_cfg)(
  File "/Users/odelalleau/.local/lib/python3.8/site-packages/joblib/parallel.py", line 715, in __init__
    raise ValueError(
ValueError: batch_size must be 'auto' or a positive integer, got: '1'

(with max_nbytes it also crashes due to the string issue, pre_dispatch actually runs but not sure what happens exactly since it's given as a string)

Expected Behavior

Running without error, providing appropriate integer arguments to joblib.Parallel when they should be integers (obviously there are situations where they should remain strings).

System information

  • Hydra Version : master
  • Python version : 3.8.5
  • Virtual environment type and version : conda 4.8.5
  • Operating system : MacOS
bug

Most helpful comment

I think string and manually convert to integer if it's a number before passing to joblib.

All 8 comments

Thx for reporting @odelalleau. will take a look at this today or tomorrow.

@omry
Since struct config is not supporting Union types for now, and for several of the fields we need Union[str, int], is there any better alternative to just do Any for the fields?

I think string and manually convert to integer if it's a number before passing to joblib.

I think string and manually convert to integer if it's a number before passing to joblib.

sounds good. I will also update the documentation to make it more clear.

reopen, (it was auto-closed)

still need to

  • [x] check existing plugin version, bump if needed.
  • [x] cherry-pick to 1.0_branch
  • [x] release
  • [x] bump plugin version if needed.

check plugin version before you bump it. I usually bump AFTER release.

check plugin version before you bump it. I usually bump AFTER release.

Thx!
Could you grant me permission to release joblib_launcher as well when you get a chance? (I don't think I have it)

fixed and released. Closing...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ImMrMa picture ImMrMa  路  4Comments

omry picture omry  路  5Comments

moskomule picture moskomule  路  5Comments

jan-matthis picture jan-matthis  路  3Comments

lkhphuc picture lkhphuc  路  3Comments