Meta package issues with imports
🐛 Bug
To Reproduce
In a fresh environment (Python version does not matter):
pip install --upgrade lightning
(version 0.6.0 is the latest at the time of writing)
import lightning as L
L.app.frontend
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'lightning.app' has no attribute 'frontend'
On master, this gives no error!
Expected behavior
No error. These are the imports shown in our docs.
Additional context
Reported by @krishnakalyan3
Environment
Details
- CUDA:
- GPU: None
- available: False
- version: None
- Lightning:
- lightning: 2022.9.8
- lightning-app: 0.6.0
- lightning-cloud: 0.5.3
- lightning-utilities: 0.3.0
- pytorch-lightning: 1.7.5
- torch: 1.12.1
- torchmetrics: 0.9.3
- Packages:
- absl-py: 1.2.0
- aiobotocore: 2.4.0
- aiohttp: 3.8.1
- aioitertools: 0.10.0
- aiosignal: 1.2.0
- anyio: 3.6.1
- arrow: 1.2.3
- asgiref: 3.5.2
- async-timeout: 4.0.2
- attrs: 22.1.0
- botocore: 1.27.59
- cachetools: 5.2.0
- certifi: 2022.6.15
- charset-normalizer: 2.1.1
- click: 8.1.3
- commonmark: 0.9.1
- croniter: 1.3.7
- deepdiff: 5.8.1
- dnspython: 2.2.1
- email-validator: 1.2.1
- fastapi: 0.82.0
- fire: 0.4.0
- frozenlist: 1.3.1
- fsspec: 2022.8.2
- google-auth: 2.11.0
- google-auth-oauthlib: 0.4.6
- grpcio: 1.48.1
- h11: 0.13.0
- httptools: 0.4.0
- idna: 3.3
- importlib-metadata: 4.12.0
- itsdangerous: 2.1.2
- jinja2: 3.0.3
- jmespath: 0.10.0
- lightning: 2022.9.8
- lightning-app: 0.6.0
- lightning-cloud: 0.5.3
- lightning-utilities: 0.3.0
- markdown: 3.4.1
- markupsafe: 2.1.1
- multidict: 6.0.2
- numpy: 1.23.2
- oauthlib: 3.2.0
- ordered-set: 4.1.0
- orjson: 3.8.0
- packaging: 21.3
- pip: 22.1.2
- protobuf: 3.19.4
- py: 1.11.0
- pyasn1: 0.4.8
- pyasn1-modules: 0.2.8
- pydantic: 1.10.2
- pydeprecate: 0.3.2
- pygments: 2.13.0
- pyjwt: 2.4.0
- pyparsing: 3.0.9
- python-dateutil: 2.8.2
- python-dotenv: 0.21.0
- python-multipart: 0.0.5
- pytorch-lightning: 1.7.5
- pyyaml: 6.0
- requests: 2.28.1
- requests-oauthlib: 1.3.1
- rich: 12.5.1
- rsa: 4.9
- s3fs: 2022.8.2
- setuptools: 63.4.1
- six: 1.16.0
- sniffio: 1.3.0
- starlette: 0.19.1
- starsessions: 1.3.0
- tensorboard: 2.10.0
- tensorboard-data-server: 0.6.1
- tensorboard-plugin-wit: 1.8.1
- termcolor: 2.0.1
- torch: 1.12.1
- torchmetrics: 0.9.3
- tqdm: 4.64.1
- traitlets: 5.3.0
- typing-extensions: 4.3.0
- ujson: 5.4.0
- urllib3: 1.26.12
- uvicorn: 0.17.6
- uvloop: 0.16.0
- watchgod: 0.8.2
- websocket-client: 1.4.1
- websockets: 10.3
- werkzeug: 2.2.2
- wheel: 0.37.1
- wrapt: 1.14.1
- yarl: 1.8.1
- zipp: 3.8.1
- System:
- OS: Darwin
- architecture:
- 64bit
- processor: arm
- python: 3.9.13
- version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
cc @tchaton @rohitgr7
well it is about how the package is built - as a cross-import package, so this won't work
import lightning as L
L.app.frontend
but you can
from lightning.app import frontend
or
import lightning as L
L.app.frontend.Frontend
so if lightning_app.__init__ would have __all__ = [..., "frontend"] your mentioned import also works...
Dos that mean we should update the documentation with different imports? Or we need to add all submodules to __all__?
Since we are swapping meta-package for a copy-on-build, this shouldn't apply anymore. Closing