Skip to content

Commit 5421cdb

Browse files
authored
Merge pull request #961 from Trusted-AI/feature/rename-skip-framework-marker
Feature/rename skip framework marker
2 parents 7032c5d + 1ba19c1 commit 5421cdb

31 files changed

+120
-128
lines changed

conftest.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ def get_default_framework():
7474

7575
def pytest_addoption(parser):
7676
parser.addoption(
77-
"--mlFramework",
77+
"--framework",
7878
action="store",
7979
default=get_default_framework(),
80-
help="ART tests allow you to specify which mlFramework to use. The default mlFramework used is `tensorflow`. "
80+
help="ART tests allow you to specify which framework to use. The default framework used is `tensorflow`. "
8181
"Other options available are {0}".format(art_supported_frameworks),
8282
)
8383
parser.addoption(
@@ -643,7 +643,7 @@ def create_test_image(create_test_dir):
643643

644644
@pytest.fixture(scope="session")
645645
def framework(request):
646-
ml_framework = request.config.getoption("--mlFramework")
646+
ml_framework = request.config.getoption("--framework")
647647
if ml_framework == "tensorflow":
648648
import tensorflow as tf
649649

@@ -654,12 +654,12 @@ def framework(request):
654654

655655
if ml_framework not in art_supported_frameworks:
656656
raise Exception(
657-
"mlFramework value {0} is unsupported. Please use one of these valid values: {1}".format(
657+
"framework value {0} is unsupported. Please use one of these valid values: {1}".format(
658658
ml_framework, " ".join(art_supported_frameworks)
659659
)
660660
)
661-
# if utils_test.is_valid_framework(mlFramework):
662-
# raise Exception("The mlFramework specified was incorrect. Valid options available
661+
# if utils_test.is_valid_framework(framework):
662+
# raise Exception("The framework specified was incorrect. Valid options available
663663
# are {0}".format(art_supported_frameworks))
664664
return ml_framework
665665

@@ -755,7 +755,7 @@ def get_mnist_dataset(load_mnist_dataset, mnist_shape):
755755
np.testing.assert_array_almost_equal(y_test_mnist_original, y_test_mnist, decimal=3)
756756

757757

758-
# ART test fixture to skip test for specific mlFramework values
758+
# ART test fixture to skip test for specific framework values
759759
# eg: @pytest.mark.only_with_platform("tensorflow")
760760
@pytest.fixture(autouse=True)
761761
def only_with_platform(request, framework):
@@ -764,13 +764,13 @@ def only_with_platform(request, framework):
764764
pytest.skip("skipped on this platform: {}".format(framework))
765765

766766

767-
# ART test fixture to skip test for specific mlFramework values
768-
# eg: @pytest.mark.skipMlFramework("tensorflow", "keras", "pytorch", "scikitlearn",
767+
# ART test fixture to skip test for specific framework values
768+
# eg: @pytest.mark.skip_framework("tensorflow", "keras", "pytorch", "scikitlearn",
769769
# "mxnet", "kerastf", "non_dl_frameworks", "dl_frameworks")
770770
@pytest.fixture(autouse=True)
771771
def skip_by_framework(request, framework):
772-
if request.node.get_closest_marker("skipMlFramework"):
773-
framework_to_skip_list = list(request.node.get_closest_marker("skipMlFramework").args)
772+
if request.node.get_closest_marker("skip_framework"):
773+
framework_to_skip_list = list(request.node.get_closest_marker("skip_framework").args)
774774
if "dl_frameworks" in framework_to_skip_list:
775775
framework_to_skip_list.extend(deep_learning_frameworks)
776776

run_tests.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,61 @@ export TF_CPP_MIN_LOG_LEVEL="3"
88

99
#NOTE: All the tests should be ran within this loop. All other tests are legacy tests that must be
1010
# made framework independent to be incorporated within this loop
11-
mlFrameworkList=("tensorflow" "keras" "pytorch" "scikitlearn" "mxnet" "kerastf")
12-
mlFramework=$1
11+
frameworkList=("tensorflow" "keras" "pytorch" "scikitlearn" "mxnet" "kerastf")
12+
framework=$1
1313

14-
if [[ ${mlFramework} != "legacy" ]]
14+
if [[ ${framework} != "legacy" ]]
1515
then
1616
echo "#######################################################################"
17-
echo "############## Running tests with framework $mlFramework ##############"
17+
echo "############### Running tests with framework $framework ###############"
1818
echo "#######################################################################"
1919

20-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/detector/poison/test_spectral_signature_defense.py --mlFramework=$mlFramework --skip_travis=True --durations=0
20+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/detector/poison/test_spectral_signature_defense.py --framework=$framework --skip_travis=True --durations=0
2121
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed defences/detector/poison/test_spectral_signature_defense.py tests"; fi
2222

23-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/preprocessor --mlFramework=$mlFramework --skip_travis=True --durations=0
23+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/preprocessor --framework=$framework --skip_travis=True --durations=0
2424
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed defences/preprocessor tests"; fi
2525

26-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/transformer --mlFramework=$mlFramework --skip_travis=True --durations=0
26+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/transformer --framework=$framework --skip_travis=True --durations=0
2727
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed defences/transformer tests"; fi
2828

29-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/preprocessing/audio --mlFramework=$mlFramework --skip_travis=True --durations=0
29+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/preprocessing/audio --framework=$framework --skip_travis=True --durations=0
3030
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed preprocessing/audio tests"; fi
3131

32-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/preprocessing/expectation_over_transformation --mlFramework=$mlFramework --skip_travis=True --durations=0
32+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/preprocessing/expectation_over_transformation --framework=$framework --skip_travis=True --durations=0
3333
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed preprocessing/expectation_over_transformation tests"; fi
3434

35-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/utils --mlFramework=$mlFramework --skip_travis=True --durations=0
35+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/utils --framework=$framework --skip_travis=True --durations=0
3636
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed utils tests"; fi
3737

38-
pytest --cov-report=xml --cov=art --cov-append -q -vv -s tests/attacks/poison/ --mlFramework=$mlFramework --skip_travis=True --durations=0
38+
pytest --cov-report=xml --cov=art --cov-append -q -vv -s tests/attacks/poison/ --framework=$framework --skip_travis=True --durations=0
3939
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/poison tests"; fi
4040

41-
pytest --cov-report=xml --cov=art --cov-append -q -vv -s tests/attacks/evasion/ --mlFramework=$mlFramework --skip_travis=True --durations=0
41+
pytest --cov-report=xml --cov=art --cov-append -q -vv -s tests/attacks/evasion/ --framework=$framework --skip_travis=True --durations=0
4242
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/evasion/test_shadow_attack.py"; fi
4343

44-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/speech_recognition/ --mlFramework=$mlFramework --skip_travis=True --durations=0
44+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/speech_recognition/ --framework=$framework --skip_travis=True --durations=0
4545
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/speech_recognition tests"; fi
4646

47-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/attacks/inference/ --mlFramework=$mlFramework --skip_travis=True --durations=0
47+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/attacks/inference/ --framework=$framework --skip_travis=True --durations=0
4848
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/inference"; fi
4949

50-
pytest -q -s tests/attacks/evasion/test_brendel_and_bethge.py --mlFramework=$mlFramework --durations=0
50+
pytest -q -s tests/attacks/evasion/test_brendel_and_bethge.py --framework=$framework --durations=0
5151
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/evasion/test_brendel_and_bethge.py"; fi
5252

53-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/classifiersFrameworks/ --mlFramework=$mlFramework --skip_travis=True --durations=0
53+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/classifiersFrameworks/ --framework=$framework --skip_travis=True --durations=0
5454
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed classifiersFrameworks tests"; fi
5555

56-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/preprocessor/test_spatial_smoothing_pytorch.py --mlFramework=$mlFramework --skip_travis=True --durations=0
56+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/defences/preprocessor/test_spatial_smoothing_pytorch.py --framework=$framework --skip_travis=True --durations=0
5757
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed defences/preprocessor/test_spatial_smoothing_pytorch.py tests"; fi
5858

59-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/classification/test_deeplearning_common.py --mlFramework=$mlFramework --skip_travis=True --durations=0
60-
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/classification/test_deeplearning_common.py $mlFramework"; fi
59+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/classification/test_deeplearning_common.py --framework=$framework --skip_travis=True --durations=0
60+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/classification/test_deeplearning_common.py $framework"; fi
6161

62-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/classification/test_deeplearning_specific.py --mlFramework=$mlFramework --skip_travis=True --durations=0
63-
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/classification tests for framework $mlFramework"; fi
62+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/classification/test_deeplearning_specific.py --framework=$framework --skip_travis=True --durations=0
63+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/classification tests for framework $framework"; fi
6464

65-
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/metrics/privacy --mlFramework=$mlFramework --skip_travis=True --durations=0
65+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/metrics/privacy --framework=$framework --skip_travis=True --durations=0
6666
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed metrics/privacy tests"; fi
6767
else
6868
declare -a attacks=("tests/attacks/test_adversarial_patch.py" \

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ description-file = README.md
55
pep8maxlinelength = 120
66
pep8ignore = *.py E402 W503 E203 E231 E251 E701
77
markers =
8-
skipMlFramework: marks a test to be skipped for specific mlFramework values. Valid values are ("tensorflow" "keras" "pytorch" "scikitlearn")
9-
only_with_platform: DEPRECATED only used for legacy tests. Use skipMlFramework instead. marks a test to be performed only for a specific mlFramework values
8+
skip_framework: marks a test to be skipped for specific framework values. Valid values are ("tensorflow" "keras" "mxnet" "pytorch" "scikitlearn")
9+
only_with_platform: DEPRECATED only used for legacy tests. Use skip_framework instead. marks a test to be performed only for a specific framework value
1010
framework_agnostic: marks a test to be agnostic to frameworks and run only for one default framework
1111
skip_travis: Skips a test marked with this decorator if the command line argument skip_travis is set to true
1212
skip_module: Skip the test if a module is not available in the current environment

tests/attacks/evasion/test_adversarial_asr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_is_subclass(self, art_warning):
4545
except ARTTestException as e:
4646
art_warning(e)
4747

48-
@pytest.mark.skipMlFramework("tensorflow1", "mxnet", "kerastf", "non_dl_frameworks")
48+
@pytest.mark.skip_framework("tensorflow1", "mxnet", "kerastf", "non_dl_frameworks")
4949
def test_implements_abstract_methods(self, art_warning, asr_dummy_estimator):
5050
try:
5151
CarliniWagnerASR(estimator=asr_dummy_estimator())
@@ -61,7 +61,7 @@ def test_classifier_type_check_fail(self, art_warning):
6161
except ARTTestException as e:
6262
art_warning(e)
6363

64-
@pytest.mark.skipMlFramework("tensorflow1", "mxnet", "kerastf", "non_dl_frameworks")
64+
@pytest.mark.skip_framework("tensorflow1", "mxnet", "kerastf", "non_dl_frameworks")
6565
def test_generate_batch(self, art_warning, mocker, asr_dummy_estimator, audio_data):
6666
try:
6767
test_input, test_target = audio_data

tests/attacks/evasion/test_auto_attack.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def fix_get_mnist_subset(get_mnist_dataset):
4141
yield x_train_mnist[:n_train], y_train_mnist[:n_train], x_test_mnist[:n_test], y_test_mnist[:n_test]
4242

4343

44-
@pytest.mark.skipMlFramework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
44+
@pytest.mark.skip_framework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
4545
def test_generate_default(art_warning, fix_get_mnist_subset, image_dl_estimator):
4646
try:
4747
classifier, _ = image_dl_estimator(from_logits=True)
@@ -60,7 +60,7 @@ def test_generate_default(art_warning, fix_get_mnist_subset, image_dl_estimator)
6060
art_warning(e)
6161

6262

63-
@pytest.mark.skipMlFramework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
63+
@pytest.mark.skip_framework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
6464
def test_generate_attacks_and_targeted(art_warning, fix_get_mnist_subset, image_dl_estimator):
6565
try:
6666
classifier, _ = image_dl_estimator(from_logits=True)

tests/attacks/evasion/test_auto_projected_gradient_descent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def fix_get_mnist_subset(get_mnist_dataset):
3838
yield x_train_mnist[:n_train], y_train_mnist[:n_train], x_test_mnist[:n_test], y_test_mnist[:n_test]
3939

4040

41-
@pytest.mark.skipMlFramework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
41+
@pytest.mark.skip_framework("tensorflow1", "keras", "pytorch", "non_dl_frameworks", "mxnet", "kerastf")
4242
def test_generate(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack):
4343
try:
4444
classifier = image_dl_estimator_for_attack(AutoProjectedGradientDescent)

tests/attacks/evasion/test_brendel_and_bethge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
logger = logging.getLogger(__name__)
3131

3232

33-
@pytest.mark.skipMlFramework("tensorflow1", "keras", "kerastf", "mxnet", "non_dl_frameworks")
33+
@pytest.mark.skip_framework("tensorflow1", "keras", "kerastf", "mxnet", "non_dl_frameworks")
3434
@pytest.mark.parametrize("targeted", [True, False])
3535
@pytest.mark.parametrize("norm", [1, 2, np.inf, "inf"])
3636
def test_generate(art_warning, get_default_mnist_subset, image_dl_estimator_for_attack, targeted, norm):

tests/attacks/evasion/test_fast_gradient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_minimal_perturbations_images(art_warning, fix_get_mnist_subset, image_d
147147

148148

149149
@pytest.mark.parametrize("norm", [np.inf, 1, 2])
150-
@pytest.mark.skipMlFramework("pytorch") # temporarily skipping for pytorch until find bug fix in bounded test
150+
@pytest.mark.skip_framework("pytorch") # temporarily skipping for pytorch until find bug fix in bounded test
151151
@pytest.mark.framework_agnostic
152152
def test_norm_images(art_warning, norm, fix_get_mnist_subset, image_dl_estimator_for_attack):
153153
try:
@@ -183,7 +183,7 @@ def test_norm_images(art_warning, norm, fix_get_mnist_subset, image_dl_estimator
183183
art_warning(e)
184184

185185

186-
@pytest.mark.skipMlFramework("scikitlearn") # temporarily skipping for scikitlearn until find bug fix in bounded test
186+
@pytest.mark.skip_framework("scikitlearn") # temporarily skipping for scikitlearn until find bug fix in bounded test
187187
@pytest.mark.parametrize("targeted, clipped", [(True, True), (True, False), (False, True), (False, False)])
188188
@pytest.mark.framework_agnostic
189189
def test_tabular(art_warning, tabular_dl_estimator, framework, get_iris_dataset, targeted, clipped):

tests/attacks/evasion/test_feature_adversaries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def fix_get_mnist_subset(get_mnist_dataset):
3636
yield x_train_mnist[:n_train], y_train_mnist[:n_train], x_test_mnist[:n_test], y_test_mnist[:n_test]
3737

3838

39-
@pytest.mark.skipMlFramework("pytorch")
39+
@pytest.mark.skip_framework("pytorch")
4040
@pytest.mark.framework_agnostic
4141
def test_images(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack):
4242
try:

tests/attacks/evasion/test_frame_saliency.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def fix_get_mnist_subset(get_mnist_dataset):
4040
yield x_train_mnist[:n_train], y_train_mnist[:n_train], x_test_mnist[:n_test], y_test_mnist[:n_test]
4141

4242

43-
@pytest.mark.skipMlFramework("pytorch")
43+
@pytest.mark.skip_framework("pytorch")
4444
@pytest.mark.framework_agnostic
4545
def test_one_shot(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack):
4646
try:
@@ -61,7 +61,7 @@ def test_one_shot(art_warning, fix_get_mnist_subset, image_dl_estimator_for_atta
6161
art_warning(e)
6262

6363

64-
@pytest.mark.skipMlFramework("pytorch")
64+
@pytest.mark.skip_framework("pytorch")
6565
@pytest.mark.framework_agnostic
6666
def test_iterative_saliency(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack):
6767
try:
@@ -86,7 +86,7 @@ def test_iterative_saliency(art_warning, fix_get_mnist_subset, image_dl_estimato
8686
art_warning(e)
8787

8888

89-
@pytest.mark.skipMlFramework("pytorch")
89+
@pytest.mark.skip_framework("pytorch")
9090
@pytest.mark.framework_agnostic
9191
def test_iterative_saliency_refresh(art_warning, fix_get_mnist_subset, image_dl_estimator_for_attack):
9292
try:

0 commit comments

Comments
 (0)