Repository: facebookresearch/hydra

Issue:
Error when using strict mode and multirun
Modifying the `6_sweep` example to have `@hydra.main(config_path="conf/config.yaml", strict=True)` causes this error:

```python3
6_sweep(master*)$ python3 experiment.py -m
Traceback (most recent call last):
  File "experiment.py", line 15, in <module>
    experiment()
  File "/private/home/bda/repos/hydra/hydra/main.py", line 62, in decorated_main
    run_hydra(get_args(), task_function, config_path, strict)
  File "/private/home/bda/repos/hydra/hydra/_internal/utils.py", line 57, in run_hydra
    hydra.multirun(overrides=args.overrides)
  File "/private/home/bda/repos/hydra/hydra/_internal/hydra.py", line 124, in multirun
    return sweeper.sweep(arguments=task_overrides)
  File "/private/home/bda/repos/hydra/hydra/plugins/step_sweeper.py", line 63, in sweep
    results = self.launcher.launch(batch)
  File "/private/home/bda/repos/hydra/plugins/submitit/hydra_plugins/submitit/submitit_launcher.py", line 67, in launch
    self.config.hydra.job.num_jobs = num_jobs
  File "/private/home/bda/anaconda3/lib/python3.7/site-packages/omegaconf-1.3.0-py3.7.egg/omegaconf/dictconfig.py", line 59, in __setattr__
    self.__setitem__(key, value)
  File "/private/home/bda/anaconda3/lib/python3.7/site-packages/omegaconf-1.3.0-py3.7.egg/omegaconf/dictconfig.py", line 28, in __setitem__
    raise KeyError("Accessing unknown key in a struct : {}".format(self.get_full_key(key)))
KeyError: 'Accessing unknown key in a struct : hydra.job.num_jobs'
```

---

Perhaps hydra needs to add the right placeholders in the config here for the plugins to modify/write into, or the plugin needs to have a temporarily config that's not locked?


Discussion:
(My temporary hack to fix this is to add `OmegaConf.set_struct(self.config.hydra, False)` in the line before the crash in `submitit_launcher.py`)
Thanks for reporting. your workaround will do until I fix it.
strict mode + plugins is not currently covered in the unit tests, which is why I missed it.

Resolving patch:
diff --git a/plugins/submitit/hydra_plugins/submitit/submitit_launcher.py b/plugins/submitit/hydra_plugins/submitit/submitit_launcher.py
--- a/plugins/submitit/hydra_plugins/submitit/submitit_launcher.py
+++ b/plugins/submitit/hydra_plugins/submitit/submitit_launcher.py
@@ -60,11 +60,14 @@ def launch_job(self, sweep_overrides, job_dir_key, job_num):
         )
 
     def launch(self, job_overrides):
+        # lazy import to ensurue plugin discovery remains fast
         import submitit
 
         num_jobs = len(job_overrides)
         assert num_jobs > 0
-        self.config.hydra.job.num_jobs = num_jobs
+        with open_dict(self.config):
+            self.config.hydra.job.num_jobs = num_jobs
+
         if self.queue == "auto":
             executor = submitit.AutoExecutor(
                 folder=self.folder, conda_file=self.conda_file, par_file=self.par_file
@@ -85,7 +88,7 @@ def launch(self, job_overrides):
         log.info("Sweep output dir : {}".format(self.config.hydra.sweep.dir))
         path_str = str(self.config.hydra.sweep.dir)
         os.makedirs(path_str, exist_ok=True)
-        if self.config.hydra.sweep.mode is not None:
+        if "mode" in self.config.hydra.sweep:
             mode = int(str(self.config.hydra.sweep.mode), 8)
             os.chmod(path_str, mode=mode)
 


Test patch: