Repository: facebookincubator/submitit

Issue:
NotImplementedError when getting a job result for version 1.1.4
Hi,

I have been using `submitit` a lot recently to submit my jobs on a SLURM-based HPC. It has been very good to me, allowing me to get rid of an extra API writing, so thanks for this project.

When I installed version 1.1.4, I got an error whose stacktrace is as follows:

```python
Traceback (most recent call last):
  File "three_d.py", line 19, in <module>
    train_eval_grid(
  File "/gpfsdswork/projects/rech/hih/uap69lx/submission-scripts/jean_zay/submitit/general_submissions.py", line 63, in train_eval_grid
    run_ids = [job.result() for job in jobs]
  File "/gpfsdswork/projects/rech/hih/uap69lx/submission-scripts/jean_zay/submitit/general_submissions.py", line 63, in <listcomp>
    run_ids = [job.result() for job in jobs]
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 266, in result
    r = self.results()
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 284, in results
    self.wait()
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 387, in wait
    while not self.done():
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 424, in done
    if self.watcher.is_done(self.job_id, mode="force" if force_check else "standard"):
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 100, in is_done
    state = self.get_state(job_id, mode=mode)
  File "/linkhome/rech/gencea10/uap69lx/.conda/envs/dis-mri-recon/lib/python3.8/site-packages/submitit/core/core.py", line 53, in get_state
    raise NotImplementedError
NotImplementedError
```

I didn't get the chance to work on a minimal reproducible example yet, but I can tell you that this happens in 1.1.4 and doesn't happen in 1.1.3.
I can point you in the meantime to the failing line in my public code: [here](https://github.com/zaccharieramzi/submission-scripts/blob/master/jean_zay/submitit/general_submissions.py#L63).

Comments:

Patch:
diff --git a/submitit/__init__.py b/submitit/__init__.py
index 42fd4b8..f73808b 100644
--- a/submitit/__init__.py
+++ b/submitit/__init__.py
@@ -17,4 +17,4 @@ from .local.local import LocalJob as LocalJob
 from .slurm.slurm import SlurmExecutor as SlurmExecutor
 from .slurm.slurm import SlurmJob as SlurmJob
 
-__version__ = "1.1.4"
+__version__ = "1.1.5"
diff --git a/submitit/auto/auto.py b/submitit/auto/auto.py
index e86daf7..1c21369 100644
--- a/submitit/auto/auto.py
+++ b/submitit/auto/auto.py
@@ -171,7 +171,12 @@ class AutoExecutor(Executor):
                 )
                 continue
         if invalid:
-            invalid.append(f"Known executors: {', '.join(executors.keys())}")
+            invalid.extend(
+                [
+                    f"Known executors: {', '.join(executors.keys())}",
+                    f"As a reminder, shared/generic (non-prefixed) parameters are: {generics}.",
+                ]
+            )
             raise NameError("\n".join(invalid))
 
         # add cluster specific generic overrides
diff --git a/submitit/core/core.py b/submitit/core/core.py
index 9538d43..5fee468 100644
--- a/submitit/core/core.py
+++ b/submitit/core/core.py
@@ -585,11 +585,15 @@ class Executor(abc.ABC):
     def submit(self, fn: tp.Callable[..., R], *args: tp.Any, **kwargs: tp.Any) -> Job[R]:
         ds = utils.DelayedSubmission(fn, *args, **kwargs)
         if self._delayed_batch is not None:
-            job: Job[R] = self.job_class.__new__(self.job_class)  # empty shell
+            # ugly hack for AutoExecutor class which is known at runtime
+            cls = self.job_class if self.job_class is not Job else self._executor.job_class  # type: ignore
+            job: Job[R] = cls.__new__(cls)  # empty shell
             self._delayed_batch.append((job, ds))
-            return job
         else:
-            return self._internal_process_submissions([ds])[0]
+            job = self._internal_process_submissions([ds])[0]
+        if type(job) is Job:  # pylint: disable=unidiomatic-typecheck
+            raise RuntimeError("Executors should never return a base Job class (implementation issue)")
+        return job
 
     @abc.abstractmethod
     def _internal_process_submissions(


Test patch:
diff --git a/submitit/auto/test_auto.py b/submitit/auto/test_auto.py
index defb232..1e04abd 100644
--- a/submitit/auto/test_auto.py
+++ b/submitit/auto/test_auto.py
@@ -90,3 +90,11 @@ def test_overriden_arguments() -> None:
     # others use timeout_min
     local_ex = auto.AutoExecutor(folder=".", cluster="local")
     local_ex.update_parameters(timeout_min=60, slurm_time=120)
+
+
+def test_auto_batch_watcher() -> None:
+    with test_slurm.mocked_slurm() as tmp:
+        executor = auto.AutoExecutor(folder=tmp)
+        with executor.batch():
+            job = executor.submit(print, "hi")
+        assert not job.done()