IntelLabs / MART

Modular Adversarial Robustness Toolkit
BSD 3-Clause "New" or "Revised" License
16 stars 0 forks source link

Make mart importable with the core dependency group alone #255

Closed mzweilin closed 2 months ago

mzweilin commented 2 months ago

What does this PR do?

This PR allows import mart with the "core" dependency group alone. In this way, a non-image domain user does not need to install torchvision etc.

$ pip install -e .[core,developer]
$ python
Python 3.9.19 (main, May  9 2024, 16:03:05) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mart
fiftyone is not installed, so some features in MART are unavailable.
torchvision is not installed, so some features in MART are unavailable.
timm is not installed, so some features in MART are unavailable.
pycocotools is not installed, so some features in MART are unavailable.
>>> 

pytest automatically skips related tests if dependency is not available locally.

$ pytest
...
tests/test_utils.py::test_flatten_dict_key_collision PASSED                 [100%]

================================ slowest durations ================================
0.23s call     tests/test_adversary.py::test_forward_with_model
0.03s call     tests/test_adversary_connector.py::test_adversary_connector_callback
0.03s setup    tests/test_adversary.py::test_with_model
0.01s call     tests/test_adversary.py::test_with_model

(351 durations < 0.005s hidden.  Use -vv to show these durations.)
========================= 113 passed, 10 skipped in 0.71s =========================

Type of change

Please check all relevant options.

Testing

Please describe the tests that you ran to verify your changes. Consider listing any relevant details of your test configuration.

Before submitting

Did you have fun?

Make sure you had fun coding 🙃