From 808ab63ac63d06d9b7adfceb372ac18891cbf81c Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Sat, 27 Dec 2025 16:23:16 +0530 Subject: [PATCH 1/4] feat: implemented env var based admin key loading Signed-off-by: rohansen856 --- openml/config.py | 1 + openml/testing.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 From f183d11fba4525398a3cd34dbd8c969ccd76e215 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Sat, 27 Dec 2025 16:24:28 +0530 Subject: [PATCH 2/4] tests: updated tests to use the env var for key instead of hardcoding it Signed-off-by: rohansen856 --- tests/test_datasets/test_dataset_functions.py | 4 ++++ tests/test_openml/test_config.py | 4 ++++ 2 files changed, 8 insertions(+) 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.""" From 7a94293ce4e2536e10feb436700beaddde43933c Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Sat, 27 Dec 2025 16:25:31 +0530 Subject: [PATCH 3/4] refactor: updated github action to use secrets Signed-off-by: rohansen856 --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 4ad4498010fa532ae3be96e1741348fd935bcfd5 Mon Sep 17 00:00:00 2001 From: rohansen856 Date: Thu, 22 Jan 2026 15:55:39 +0530 Subject: [PATCH 4/4] docs: updated contributing doc with instructions for admin key export Signed-off-by: rohansen856 --- CONTRIBUTING.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 35ab30b4a..0b581ff30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -96,6 +96,20 @@ To test your new contribution, add [unit tests](https://github.com/openml/openml * Please ensure that the example is run on the test server by beginning with the call to `openml.config.start_using_configuration_for_example()`, which is done by default for tests derived from `TestBase`. * Add the `@pytest.mark.sklearn` marker to your unit tests if they have a dependency on scikit-learn. +#### Running Tests That Require Admin Privileges + +Some tests require admin privileges on the test server and will be automatically skipped unless you provide an admin API key. For regular contributors, the tests will skip gracefully. For core contributors who need to run these tests locally: + +**Set up the key** by exporting the variable: +run this in the terminal before running the tests: + +```bash +# For windows +$env:OPENML_TEST_SERVER_ADMIN_KEY = "admin-key" +# For linux/mac +export OPENML_TEST_SERVER_ADMIN_KEY="admin-key" +``` + ### Pull Request Checklist You can go to the `openml-python` GitHub repository to create the pull request by [comparing the branch](https://github.com/openml/openml-python/compare) from your fork with the `develop` branch of the `openml-python` repository. When creating a pull request, make sure to follow the comments and structured provided by the template on GitHub.