diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31cdff602..1f5b8fe3c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -98,6 +98,8 @@ jobs: run: python -m pip list - name: Run tests on Ubuntu Test if: matrix.os == 'ubuntu-latest' + env: + OPENML_TEST_SERVER_ADMIN_KEY: ${{ secrets.OPENML_TEST_SERVER_ADMIN_KEY }} run: | if [ ${{ matrix.code-cov }} ]; then codecov='--cov=openml --long --cov-report=xml'; fi # Most of the time, running only the scikit-learn tests is sufficient @@ -106,6 +108,8 @@ jobs: pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks" - name: Run tests on Ubuntu Production if: matrix.os == 'ubuntu-latest' + env: + OPENML_TEST_SERVER_ADMIN_KEY: ${{ secrets.OPENML_TEST_SERVER_ADMIN_KEY }} run: | if [ ${{ matrix.code-cov }} ]; then codecov='--cov=openml --long --cov-report=xml'; fi # Most of the time, running only the scikit-learn tests is sufficient @@ -114,6 +118,8 @@ jobs: pytest -n 4 --durations=20 --dist load -sv $codecov -o log_cli=true -m "$marks" - name: Run tests on Windows if: matrix.os == 'windows-latest' + env: + OPENML_TEST_SERVER_ADMIN_KEY: ${{ secrets.OPENML_TEST_SERVER_ADMIN_KEY }} run: | # we need a separate step because of the bash-specific if-statement in the previous one. pytest -n 4 --durations=20 --dist load -sv --reruns 5 --reruns-delay 1 - name: Check for files left behind by test diff --git a/openml/config.py b/openml/config.py index cf66a6346..e90f03b1d 100644 --- a/openml/config.py +++ b/openml/config.py @@ -24,6 +24,7 @@ OPENML_CACHE_DIR_ENV_VAR = "OPENML_CACHE_DIR" OPENML_SKIP_PARQUET_ENV_VAR = "OPENML_SKIP_PARQUET" +OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR = "OPENML_TEST_SERVER_ADMIN_KEY" _TEST_SERVER_NORMAL_USER_KEY = "normaluser" diff --git a/openml/testing.py b/openml/testing.py index d1da16876..ca6a1e478 100644 --- a/openml/testing.py +++ b/openml/testing.py @@ -48,7 +48,7 @@ class TestBase(unittest.TestCase): } flow_name_tracker: ClassVar[list[str]] = [] test_server = "https://test.openml.org/api/v1/xml" - admin_key = "abc" + admin_key = os.environ.get(openml.config.OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR) user_key = openml.config._TEST_SERVER_NORMAL_USER_KEY # creating logger for tracking files uploaded to test server diff --git a/tests/test_datasets/test_dataset_functions.py b/tests/test_datasets/test_dataset_functions.py index 266a6f6f7..b9e642c71 100644 --- a/tests/test_datasets/test_dataset_functions.py +++ b/tests/test_datasets/test_dataset_functions.py @@ -572,6 +572,10 @@ def _assert_status_of_dataset(self, *, did: int, status: str): assert len(result) == 1 assert result[did]["status"] == status + @pytest.mark.skipif( + not os.environ.get(openml.config.OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR), + reason="Test requires admin key. Set OPENML_TEST_SERVER_ADMIN_KEY environment variable.", + ) @pytest.mark.flaky() def test_data_status(self): dataset = OpenMLDataset( diff --git a/tests/test_openml/test_config.py b/tests/test_openml/test_config.py index 7ef223504..cd3dd42dd 100644 --- a/tests/test_openml/test_config.py +++ b/tests/test_openml/test_config.py @@ -106,6 +106,10 @@ def test_setup_with_config(self): class TestConfigurationForExamples(openml.testing.TestBase): + @pytest.mark.skipif( + not os.environ.get(openml.config.OPENML_TEST_SERVER_ADMIN_KEY_ENV_VAR), + reason="Test requires admin key. Set OPENML_TEST_SERVER_ADMIN_KEY environment variable.", + ) @pytest.mark.production() def test_switch_to_example_configuration(self): """Verifies the test configuration is loaded properly."""