Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openml/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
from typing import Callable
from urllib.parse import urlparse

from tests.config import TEST_SERVER

from openml import config


Expand Down Expand Up @@ -108,7 +110,7 @@ def check_server(server: str) -> str:

def replace_shorthand(server: str) -> str:
if server == "test":
return "https://test.openml.org/api/v1/xml"
return TEST_SERVER
if server == "production":
return "https://www.openml.org/api/v1/xml"
return server
Expand Down
8 changes: 5 additions & 3 deletions openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from typing_extensions import Literal, TypedDict
from urllib.parse import urlparse

from tests.config import TEST_SERVER, TEST_SERVER_API_KEY

logger = logging.getLogger(__name__)
openml_logger = logging.getLogger("openml")
console_handler: logging.StreamHandler | None = None
Expand Down Expand Up @@ -165,7 +167,7 @@ def get_server_base_url() -> str:
"""Return the base URL of the currently configured server.

Turns ``"https://api.openml.org/api/v1/xml"`` in ``"https://www.openml.org/"``
and ``"https://test.openml.org/api/v1/xml"`` in ``"https://test.openml.org/"``
and ``f"{TEST_SERVER}"`` in ``"https://test.openml.org/"``

Returns
-------
Expand Down Expand Up @@ -211,8 +213,8 @@ class ConfigurationForExamples:
_last_used_server = None
_last_used_key = None
_start_last_called = False
_test_server = "https://test.openml.org/api/v1/xml"
_test_apikey = "c0c42819af31e706efe1f4b88c23c6c1"
_test_server = TEST_SERVER
_test_apikey = TEST_SERVER_API_KEY

@classmethod
def start_using_configuration_for_example(cls) -> None:
Expand Down
6 changes: 3 additions & 3 deletions openml/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from typing import ClassVar

import requests
from tests.config import TEST_SERVER, TEST_SERVER_API_KEY

import openml
from openml.exceptions import OpenMLServerException
Expand Down Expand Up @@ -47,9 +48,8 @@ class TestBase(unittest.TestCase):
"user": [],
}
flow_name_tracker: ClassVar[list[str]] = []
test_server = "https://test.openml.org/api/v1/xml"
# amueller's read/write key that he will throw away later
apikey = "610344db6388d9ba34f6db45a3cf71de"
test_server = TEST_SERVER
apikey = TEST_SERVER_API_KEY

# creating logger for tracking files uploaded to test server
logger = logging.getLogger("unit_tests_published_entities")
Expand Down
13 changes: 13 additions & 0 deletions tests/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
USE_STAGING = False

if not USE_STAGING:
TEST_SUBDOMAIN = "test"
TEST_SERVER = "https://test.openml.org/api/v1/xml"
TEST_SERVER_API_KEY = "c0c42819af31e706efe1f4b88c23c6c1"
TEST_SERVER_API_KEY_ADMIN = "610344db6388d9ba34f6db45a3cf71de"
# amueller's read/write key that he will throw away "later"
else:
TEST_SUBDOMAIN = "staging"
TEST_SERVER = "https://staging.openml.org/api/v1/xml"
TEST_SERVER_API_KEY = "normaluser"
TEST_SERVER_API_KEY_ADMIN = "abc"
9 changes: 5 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import multiprocessing

from tests.config import TEST_SERVER_API_KEY, TEST_SERVER_API_KEY_ADMIN, TEST_SERVER

multiprocessing.set_start_method("spawn", force=True)

from collections.abc import Iterator
Expand All @@ -38,7 +40,6 @@
import openml
from openml.testing import TestBase

import inspect

# creating logger for unit test file deletion status
logger = logging.getLogger("unit_tests")
Expand Down Expand Up @@ -251,7 +252,7 @@ def test_files_directory() -> Path:

@pytest.fixture(scope="session")
def test_api_key() -> str:
return "c0c42819af31e706efe1f4b88c23c6c1"
return TEST_SERVER_API_KEY


@pytest.fixture(autouse=True, scope="function")
Expand All @@ -276,8 +277,8 @@ def with_server(request):
openml.config.server = "https://www.openml.org/api/v1/xml"
yield
return
openml.config.server = "https://test.openml.org/api/v1/xml"
openml.config.apikey = "c0c42819af31e706efe1f4b88c23c6c1"
openml.config.server = TEST_SERVER
openml.config.apikey = TEST_SERVER_API_KEY_ADMIN
yield


Expand Down
Loading
Loading