Trusted-AI / adversarial-robustness-toolbox

Adversarial Robustness Toolbox (ART) - Python Library for Machine Learning Security - Evasion, Poisoning, Extraction, Inference - Red and Blue Teams
https://adversarial-robustness-toolbox.readthedocs.io/en/latest/
MIT License
4.91k stars 1.17k forks source link

Semantic version checking in some modules/tests do not account for epoch, pre/post-release, or development release segments #2473

Closed lockwoodar closed 1 month ago

lockwoodar commented 4 months ago

Describe the bug

Example code in art/estimators/object_detection/pytorch_object_detector.py

Parsed versions make an assumption that there will be no epoch, pre-release, post-release, or development release segments. (e.g. torchvision==0.18.1a0+405940f would assert with an error of ValueError: invalid literal for int() with base 10: '1a0')

This failure mode was detected when testing within a conda environment with installed downstream heart-library (local test build for publication to conda-forge) and the latest version of torchvision via conda-forge.

To Reproduce Steps to reproduce the behavior:

  1. Build a conda venv for adversarial-robustness-toolbox
  2. Install pytorch and torchvision via conda-forge a. conda install conda-forge::pytorch b. conda install conda-forge::torchvision
  3. Confirm installed torchvision version
python -c "import torchvision; from importlib.metadata import version; print(version('torchvision'))"
# Currently, this should output:  0.18.1a0+405940f
  1. Test semantic version parse line from pytorch_object_detector.py
python -c 'import torchvision; print(list(map(int, torchvision.__version__.lower().split("+", maxsplit=1)[0].split("."))))'

# This will fail with:
# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
# ValueError: invalid literal for int() with base 10: '1a0'

All code that leverages modules that utilize this form of semantic version testing will either fail on assert statements that expect int, or are checking for a specific value (potentially directing code execution into an else pathway unintentionally).

Expected behavior These semantic version checks should consistently return a valid version identifier and not fail asserts when other identifying segments are present based on PyPA specs

Potential solution:

Screenshots n/a

System information (please complete the following information):

beat-buesser commented 4 months ago

Hi @lockwoodar Thank you very much! We will include this issue in the next patch release ART 1.18.2