Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix import error when running examples in fresh environment #19431

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Feb 8, 2024

What does this PR do?

Fixes a requests import error when running the PyTorch Lightning basic examples from a freshly installed environment.

To reproduce:

conda create -n lightning-fresh python=3.11
conda activate lightning-fresh
pip install lightning
python examples/pytorch/basics/autoencoder.py

Error:

Traceback (most recent call last):
  File "/Users/adrian/repositories/lightning/examples/pytorch/basics/autoencoder.py", line 26, in <module>
    from lightning.pytorch.demos.mnist_datamodule import MNIST
  File "/Users/adrian/repositories/lightning/src/lightning/pytorch/demos/__init__.py", line 1, in <module>
    from lightning.pytorch.demos.transformer import LightningTransformer, Transformer, WikiText2  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/adrian/repositories/lightning/src/lightning/pytorch/demos/transformer.py", line 12, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'


📚 Documentation preview 📚: https://pytorch-lightning--19431.org.readthedocs.build/en/19431/

cc @Borda

@github-actions github-actions bot added pl Generic label for PyTorch Lightning package dependencies Pull requests that update a dependency file labels Feb 8, 2024
@awaelchli awaelchli added bug Something isn't working example labels Feb 8, 2024
Copy link
Contributor

github-actions bot commented Feb 8, 2024

⚡ Required checks status: All passing 🟢

Groups summary

🟢 pytorch_lightning: Tests workflow
Check ID Status
pl-cpu (macOS-11, lightning, 3.8, 1.13, oldest) success
pl-cpu (macOS-11, lightning, 3.10, 1.13) success
pl-cpu (macOS-11, lightning, 3.10, 2.1) success
pl-cpu (ubuntu-20.04, lightning, 3.8, 1.13, oldest) success
pl-cpu (ubuntu-20.04, lightning, 3.10, 1.13) success
pl-cpu (ubuntu-20.04, lightning, 3.10, 2.1) success
pl-cpu (windows-2022, lightning, 3.8, 1.13, oldest) success
pl-cpu (windows-2022, lightning, 3.10, 1.13) success
pl-cpu (windows-2022, lightning, 3.10, 2.1) success
pl-cpu (macOS-11, pytorch, 3.8, 1.13) success
pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.13) success
pl-cpu (windows-2022, pytorch, 3.8, 1.13) success
pl-cpu (macOS-12, pytorch, 3.11, 2.0) success
pl-cpu (macOS-12, pytorch, 3.11, 2.1) success
pl-cpu (ubuntu-22.04, pytorch, 3.11, 2.0) success
pl-cpu (ubuntu-22.04, pytorch, 3.11, 2.1) success
pl-cpu (windows-2022, pytorch, 3.11, 2.0) success
pl-cpu (windows-2022, pytorch, 3.11, 2.1) success

These checks are required after the changes to requirements/pytorch/examples.txt, src/lightning/pytorch/demos/transformer.py.

🟢 pytorch_lightning: Azure GPU
Check ID Status
pytorch-lightning (GPUs) (testing Lightning | latest) success
pytorch-lightning (GPUs) (testing PyTorch | latest) success

These checks are required after the changes to requirements/pytorch/examples.txt, src/lightning/pytorch/demos/transformer.py.

🟢 pytorch_lightning: Benchmarks
Check ID Status
lightning.Benchmarks success

These checks are required after the changes to requirements/pytorch/examples.txt, src/lightning/pytorch/demos/transformer.py.

🟢 pytorch_lightning: Docs
Check ID Status
docs-make (pytorch, doctest) success
docs-make (pytorch, html) success

These checks are required after the changes to src/lightning/pytorch/demos/transformer.py, requirements/pytorch/examples.txt.

🟢 pytorch_lightning: Docker
Check ID Status
build-cuda (3.9, 1.13, 11.8.0) success
build-cuda (3.9, 1.13, 12.0.1) success
build-cuda (3.10, 2.0, 11.8.0) success
build-cuda (3.10, 2.1, 12.1.0) success
build-pl (3.9, 1.13, 11.8.0) success
build-pl (3.9, 1.13, 12.0.1) success
build-pl (3.10, 2.0, 11.8.0) success
build-pl (3.10, 2.1, 12.1.0) success

These checks are required after the changes to requirements/pytorch/examples.txt.

🟢 mypy
Check ID Status
mypy success

These checks are required after the changes to requirements/pytorch/examples.txt, src/lightning/pytorch/demos/transformer.py.

🟢 install
Check ID Status
install-pkg (ubuntu-22.04, app, 3.8) success
install-pkg (ubuntu-22.04, app, 3.11) success
install-pkg (ubuntu-22.04, fabric, 3.8) success
install-pkg (ubuntu-22.04, fabric, 3.11) success
install-pkg (ubuntu-22.04, pytorch, 3.8) success
install-pkg (ubuntu-22.04, pytorch, 3.11) success
install-pkg (ubuntu-22.04, lightning, 3.8) success
install-pkg (ubuntu-22.04, lightning, 3.11) success
install-pkg (ubuntu-22.04, notset, 3.8) success
install-pkg (ubuntu-22.04, notset, 3.11) success
install-pkg (macOS-12, app, 3.8) success
install-pkg (macOS-12, app, 3.11) success
install-pkg (macOS-12, fabric, 3.8) success
install-pkg (macOS-12, fabric, 3.11) success
install-pkg (macOS-12, pytorch, 3.8) success
install-pkg (macOS-12, pytorch, 3.11) success
install-pkg (macOS-12, lightning, 3.8) success
install-pkg (macOS-12, lightning, 3.11) success
install-pkg (macOS-12, notset, 3.8) success
install-pkg (macOS-12, notset, 3.11) success
install-pkg (windows-2022, app, 3.8) success
install-pkg (windows-2022, app, 3.11) success
install-pkg (windows-2022, fabric, 3.8) success
install-pkg (windows-2022, fabric, 3.11) success
install-pkg (windows-2022, pytorch, 3.8) success
install-pkg (windows-2022, pytorch, 3.11) success
install-pkg (windows-2022, lightning, 3.8) success
install-pkg (windows-2022, lightning, 3.11) success
install-pkg (windows-2022, notset, 3.8) success
install-pkg (windows-2022, notset, 3.11) success

These checks are required after the changes to src/lightning/pytorch/demos/transformer.py, requirements/pytorch/examples.txt.


Thank you for your contribution! 💜

Note
This comment is automatically generated and updates for 60 minutes every 180 seconds. If you have any other questions, contact carmocca for help.

@awaelchli awaelchli added the fun Staff contributions outside working hours - to differentiate from the "community" label label Feb 8, 2024
@awaelchli awaelchli modified the milestones: 2.1.x, 2.2.x Feb 8, 2024
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Merging #19431 (01a61f1) into master (bc56630) will decrease coverage by 28%.
The diff coverage is 40%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #19431      +/-   ##
==========================================
- Coverage      77%      48%     -28%     
==========================================
  Files         450      442       -8     
  Lines       38072    37923     -149     
==========================================
- Hits        29195    18389   -10806     
- Misses       8877    19534   +10657     

@mergify mergify bot added the ready PRs ready to be merged label Feb 8, 2024
@awaelchli awaelchli merged commit 5aea3b1 into master Feb 8, 2024
104 of 105 checks passed
@awaelchli awaelchli deleted the bugfix/examples-import branch February 8, 2024 11:31
Borda pushed a commit that referenced this pull request Feb 12, 2024
lexierule pushed a commit that referenced this pull request Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file example fun Staff contributions outside working hours - to differentiate from the "community" label pl Generic label for PyTorch Lightning package ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants