Skip to content
13 changes: 7 additions & 6 deletions openml/runs/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,14 @@ def run_model_on_task( # noqa: PLR0913,PLR0917
"""
if avoid_duplicate_runs is None:
avoid_duplicate_runs = openml.config.avoid_duplicate_runs
if avoid_duplicate_runs and not openml.config.apikey:
if avoid_duplicate_runs and openml.config.apikey is None:
warnings.warn(
"avoid_duplicate_runs is set to True, but no API key is set. "
"Please set your API key in the OpenML configuration file, see"
"https://openml.github.io/openml-python/main/examples/20_basic/introduction_tutorial"
".html#authentication for more information on authentication.",
RuntimeWarning,
"The 'avoid_duplicate_runs' parameter is set to True, but no API key is configured. "
"Duplicate runs cannot be checked server-side without authentication. "
"Please set your API key (for instructions, see "
"http://openml.github.io/openml-python/latest/examples/Basics/introduction_tutorial/)."
"The run will proceed, but duplicates may be created.",
UserWarning,
stacklevel=2,
)

Expand Down
Loading