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

Replaced deprecated pkg_resources.packaging with packaging module #113023

Closed
wants to merge 6 commits into from

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Nov 6, 2023

Usage of from pkg_resources import packaging leads to a deprecation warning:

DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html

and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing pkg_resources.package with package as it is now a pytorch dependency:

packaging

Copy link

pytorch-bot bot commented Nov 6, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/113023

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit c7f71ce with merge base fa9045a (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 6, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 6, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
…torch#113023)

Usage of `from pkg_resources import packaging` leads to a deprecation warning:
```
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
```
and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing `pkg_resources.package` with `package` as it is now a pytorch dependency:
https://github.com/pytorch/pytorch/blob/fa9045a8725214c05ae4dcec5a855820b861155e/requirements.txt#L19
Pull Request resolved: pytorch#113023
Approved by: https://github.com/Skylion007
@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 7, 2023

This PR leads to a break as installing nightly pytorch does not install somehow packaging:
https://github.com/pytorch/vision/actions/runs/6783326793/job/18437544348?pr=8092

pip install --progress-bar=off --pre torch --index-url=https://download.pytorch.org/whl/nightly/cpu
...
Installing collected packages: mpmath, typing-extensions, sympy, networkx, MarkupSafe, fsspec, filelock, jinja2, torch
  Successfully installed MarkupSafe-2.1.2 filelock-3.9.0 fsspec-2023.4.0 jinja2-3.1.2 mpmath-1.2.1 networkx-3.0rc1 sympy-1.11.1 torch-2.2.0.dev20231107+cpu typing-extensions-4.4.0

...
Install third party dependencies prior to TorchVision install
  + python setup.py egg_info
  /opt/conda/envs/ci/lib/python3.8/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.)
    device: torch.device = torch.device(torch._C._get_default_device()),  # torch.device('cpu'),
  Traceback (most recent call last):
  setup.py:10: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import DistributionNotFound, get_distribution, parse_version
  Traceback (most recent call last):
    File "setup.py", line 12, in <module>
      from torch.utils.cpp_extension import BuildExtension, CppExtension, CUDA_HOME, CUDAExtension
    File "/opt/conda/envs/ci/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 28, in <module>
      import packaging.version
  ModuleNotFoundError: No module named 'packaging.version'

@pmeier
Copy link
Collaborator

pmeier commented Nov 7, 2023

packaging is not installed, since it is not a dependency of torch.

@pmeier
Copy link
Collaborator

pmeier commented Nov 7, 2023

Forward fix in #113154.

@mthrok
Copy link
Contributor

mthrok commented Nov 8, 2023

@vfdev-5 Can we fallback to the old import with try expcet ?

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 8, 2023

@mthrok OK, let's try that as another workaround

@atalman
Copy link
Contributor

atalman commented Nov 8, 2023

@vfdev-5 should we revert the PR and land it with all forward fixes when there is a workaround ?

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 8, 2023

@atalman how about #113154 ? If this is a way to go, then yes, let's revert this PR and reland with suggested workarounds

@atalman
Copy link
Contributor

atalman commented Nov 8, 2023

@vfdev-5 Nightlies have been broken already for 2 days. The forward fix is not landed yet, it may or may not fix the nightly issue. I suggest we revert this PR and then land it together with forward fixes and some domain build log demonstrating that it does not breaks the domains.

@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 8, 2023

OK, sounds good

@atalman
Copy link
Contributor

atalman commented Nov 8, 2023

@pytorchbot revert -m "breaks nightlies" -c nosignal

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot
Copy link
Collaborator

@vfdev-5 your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Nov 8, 2023
…dule (#113023)"

This reverts commit 81ea7a4.

Reverted #113023 on behalf of https://github.com/atalman due to breaks nightlies ([comment](#113023 (comment)))
extra_cflags_str = listToString(extra_cflags)
extra_include_paths_str = " ".join([f'-I{include}' for include in extra_include_paths])
extra_cflags_str = listToString(extra_cflags)
extra_include_paths_str = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a drive-by fix of the failing test:

test/test_cpp_extensions_jit.py::TestCppExtensionJIT::test_gen_extension_h_pch

when extra_include_paths = None. Error message:

  File "/pytorch/torch/utils/cpp_extension.py", line 1595, in load_inline
    _check_and_build_extension_h_precompiler_headers(extra_cflags, extra_include_paths)
  File "/pytorch/torch/utils/cpp_extension.py", line 1452, in _check_and_build_extension_h_precompiler_headers
    extra_include_paths_str = " ".join([f'-I{include}' for include in extra_include_paths])
TypeError: 'NoneType' object is not iterable

Comment on lines +1453 to +1455
extra_include_paths_str = (
"" if extra_include_paths is None else " ".join([f"-I{include}" for include in extra_include_paths])
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (this looks more compact, as " ".join([]) returns an empty string)

Suggested change
extra_include_paths_str = (
"" if extra_include_paths is None else " ".join([f"-I{include}" for include in extra_include_paths])
)
extra_include_paths_str = " ".join(
[f"-I{include}" for include in extra_include_paths] if extra_include_paths else []
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, as CI is green, let's land it as is, will submit tiny BE fixes later

Comment on lines +2350 to +2351
required_cuda_version = '11.0'
if torch.version.cuda is not None and TorchVersion(torch.version.cuda) >= required_cuda_version:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO (just remove this one, perhaps in followup PR)

@malfet
Copy link
Contributor

malfet commented Nov 10, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit to zabboud/pytorch that referenced this pull request Nov 10, 2023
…torch#113023)

Usage of `from pkg_resources import packaging` leads to a deprecation warning:
```
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
```
and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing `pkg_resources.package` with `package` as it is now a pytorch dependency:
https://github.com/pytorch/pytorch/blob/fa9045a8725214c05ae4dcec5a855820b861155e/requirements.txt#L19
Pull Request resolved: pytorch#113023
Approved by: https://github.com/Skylion007, https://github.com/malfet
@vfdev-5
Copy link
Collaborator Author

vfdev-5 commented Nov 13, 2023

@pytorchbot revert -m "breaks cuda ext build" -c nosignal

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot
Copy link
Collaborator

Reverting PR 113023 failed

Reason: Command git -C /home/runner/work/pytorch/pytorch revert --no-edit 71ca42787f8a18e0e49714d45cab45e961700b8e returned non-zero exit code 1

Auto-merging torch/utils/cpp_extension.py
CONFLICT (content): Merge conflict in torch/utils/cpp_extension.py
error: could not revert 71ca42787f8... Replaced deprecated pkg_resources.packaging with packaging module (#113023)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git revert --continue".
hint: You can instead skip this commit with "git revert --skip".
hint: To abort and get back to the state before "git revert",
hint: run "git revert --abort".
Details for Dev Infra team Raised by workflow job

@vfdev-5 vfdev-5 deleted the replace_pkg_resources branch November 13, 2023 12:26
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
…torch#113023)

Usage of `from pkg_resources import packaging` leads to a deprecation warning:
```
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
```
and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing `pkg_resources.package` with `package` as it is now a pytorch dependency:
https://github.com/pytorch/pytorch/blob/fa9045a8725214c05ae4dcec5a855820b861155e/requirements.txt#L19
Pull Request resolved: pytorch#113023
Approved by: https://github.com/Skylion007
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
…torch#113023)

Usage of `from pkg_resources import packaging` leads to a deprecation warning:
```
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
```
and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing `pkg_resources.package` with `package` as it is now a pytorch dependency:
https://github.com/pytorch/pytorch/blob/fa9045a8725214c05ae4dcec5a855820b861155e/requirements.txt#L19
Pull Request resolved: pytorch#113023
Approved by: https://github.com/Skylion007, https://github.com/malfet
jeffdaily pushed a commit to ROCm/pytorch that referenced this pull request May 29, 2024
…torch#113023)

Usage of `from pkg_resources import packaging` leads to a deprecation warning:
```
DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
```
and in strict tests where warnings are errors, this leads to CI breaks, e.g.: pytorch/vision#8092

Replacing `pkg_resources.package` with `package` as it is now a pytorch dependency:
https://github.com/pytorch/pytorch/blob/fa9045a8725214c05ae4dcec5a855820b861155e/requirements.txt#L19
Pull Request resolved: pytorch#113023
Approved by: https://github.com/Skylion007, https://github.com/malfet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged open source Reverted topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants