Open weiyaw opened 1 year ago
Thanks for the bug report, @weiyaw. I am able to reproduce the failure on my own machine.
A workaround is to put Dummy
into another python module (any module except for the __main__
module):
# lib.py
class Dummy:
def __init__(self, x):
print(x)
# script.py
import hydra
from omegaconf import DictConfig, OmegaConf
from lib import Dummy
@hydra.main(version_base=None)
def main(conf: DictConfig):
dummy_int = hydra.utils.instantiate(conf, _target_=Dummy)
if __name__ == "__main__":
main()
$ python script.py -m hydra/launcher=joblib +x=1,2
[2022-12-05 19:44:28,572][HYDRA] Joblib.Parallel(n_jobs=-1,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 2 jobs
[2022-12-05 19:44:28,572][HYDRA] Launching jobs, sweep output dir : multirun/2022-12-05/19-44-28
[2022-12-05 19:44:28,572][HYDRA] #0 : +x=1
[2022-12-05 19:44:28,572][HYDRA] #1 : +x=2
1
2
Thanks for the workaround @Jasha10
🐛 Bug
Description
hydra.utils.instantiate
fails to instantiate an object when usingjoblib
. For example,python main.py --multirun +x=1,2
works, but notpython main.py --multirun hydra/launcher=basic +x=1,2
.Checklist
To reproduce
Minimal Code/Config snippet to reproduce
then run
python main.py --multirun hydra/launcher=joblib +x=1,2
Stack trace/error message
Expected Behavior
Run without complaining, and printing
1
and2
.System information
conda
22.11.0macOS 12.6.1
Additional context
None