Repository: microsoft/nni

Issue:
Unclear what extras to install: `import nni.retiarii.execution.api` fails due to missing `pytorch_lightning`
**Describe the issue**:
I want to use `nni.retiarii.execution.api` module. I've installed it as below:
```
Collecting nni>=2.3
  Downloading nni-2.9-py3-none-manylinux1_x86_64.whl (56.0 MB)
```

**Environment**:
- NNI version: 2.9
- Python version: 3.8

**Log message**:
```
_________________ ERROR collecting test/3rd_party/test_nni.py __________________
ImportError while importing test module '/__w/ai4cl-tianshou/ai4cl-tianshou/test/3rd_party/test_nni.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test/3rd_party/test_nni.py:8: in <module>
    import nni.retiarii.execution.api
/usr/local/lib/python3.8/site-packages/nni/retiarii/__init__.py:4: in <module>
    from .operation import Operation
/usr/local/lib/python3.8/site-packages/nni/retiarii/operation.py:6: in <module>
    from nni.nas.execution.common.graph_op import *
/usr/local/lib/python3.8/site-packages/nni/nas/__init__.py:4: in <module>
    from .execution import *
/usr/local/lib/python3.8/site-packages/nni/nas/execution/__init__.py:4: in <module>
    from .api import *
/usr/local/lib/python3.8/site-packages/nni/nas/execution/api.py:9: in <module>
    from nni.nas.execution.common import (
/usr/local/lib/python3.8/site-packages/nni/nas/execution/common/__init__.py:4: in <module>
    from .engine import *
/usr/local/lib/python3.8/site-packages/nni/nas/execution/common/engine.py:7: in <module>
    from .graph import Model, MetricData
/usr/local/lib/python3.8/site-packages/nni/nas/execution/common/graph.py:18: in <module>
    from nni.nas.evaluator import Evaluator
/usr/local/lib/python3.8/site-packages/nni/nas/evaluator/__init__.py:9: in <module>
    shortcut_framework(__name__)
/usr/local/lib/python3.8/site-packages/nni/common/framework.py:93: in shortcut_framework
    shortcut_module(current, '.' + get_default_framework(), current)
/usr/local/lib/python3.8/site-packages/nni/common/framework.py:83: in shortcut_module
    mod = importlib.import_module(target, package)
/usr/local/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
/usr/local/lib/python3.8/site-packages/nni/nas/evaluator/pytorch/__init__.py:4: in <module>
    from .lightning import *
/usr/local/lib/python3.8/site-packages/nni/nas/evaluator/pytorch/lightning.py:10: in <module>
    import pytorch_lightning as pl
E   ModuleNotFoundError: No module named 'pytorch_lightning'
```

**How to reproduce it?**:
```
pip install nni==2.9
python -c "import nni.retiarii.execution.api"
```


Discussion:
Try this:

```python
import nni
nni.set_default_framework('none')
```

This will remove the default behavior to import pytorch-related dependencies.
this would already help, but how to install pytorch dependencies? I work with pytorch (but not pytorch lightning). Also maybe this should be default, it was confusing to me as a new user.
That's a good suggestion. Will try to improve that in next iteration.

Resolving patch:
diff --git a/nni/nas/evaluator/pytorch/__init__.py b/nni/nas/evaluator/pytorch/__init__.py
--- a/nni/nas/evaluator/pytorch/__init__.py
+++ b/nni/nas/evaluator/pytorch/__init__.py
@@ -1,4 +1,11 @@
 # Copyright (c) Microsoft Corporation.
 # Licensed under the MIT license.
 
-from .lightning import *
+import warnings
+
+try:
+    from .lightning import *
+except ImportError:
+    warnings.warn("PyTorch-Lightning must be installed to use PyTorch in NAS. "
+                  "If you are not using PyTorch, please `nni.set_default_framework('none')`")
+    raise


Test patch: