Skip to content

Commit c559d11

Browse files
committed
Added notice to all examples for using the test server. Use test server in new way.
1 parent c7db122 commit c559d11

7 files changed

Lines changed: 62 additions & 11 deletions

File tree

doc/conf.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
import sphinx_bootstrap_theme
1818
import openml
1919

20-
21-
# amueller's read/write key
22-
openml.config.server = "https://test.openml.org/api/v1/xml"
23-
openml.config.apikey = "610344db6388d9ba34f6db45a3cf71de"
24-
25-
2620
# If extensions (or modules to document with autodoc) are in another directory,
2721
# add these directories to sys.path here. If the directory is relative to the
2822
# documentation root, use os.path.abspath to make it absolute, like shown here.

examples/create_upload_tutorial.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
from openml.datasets.functions import create_dataset
1414

1515
############################################################################
16-
# For this tutorial we will upload to the test server to not pollute the live
17-
# server with countless copies of the same dataset.
18-
openml.config.server = 'https://test.openml.org/api/v1/xml'
16+
# .. warning:: This example uploads data. For that reason, this example
17+
# connects to the test server instead. This prevents the live server from
18+
# crowding with example datasets, tasks, studies, and so on.
19+
20+
openml.config.start_use_example_configuration()
21+
############################################################################
1922

2023
############################################################################
2124
# Below we will cover the following cases of the dataset object:
@@ -309,3 +312,7 @@
309312

310313
upload_did = xor_dataset.publish()
311314
print('URL for dataset: %s/data/%d' % (openml.config.server, upload_did))
315+
316+
317+
############################################################################
318+
openml.config.stop_use_example_configuration()

examples/datasets_tutorial.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
How to list and download datasets.
77
"""
88

9+
############################################################################
10+
# .. warning:: This example uploads data. For that reason, this example
11+
# connects to the test server instead. This prevents the live server from
12+
# crowding with example datasets, tasks, studies, and so on.
13+
14+
openml.config.start_use_example_configuration()
15+
############################################################################
16+
917
import openml
1018
import pandas as pd
1119

@@ -101,3 +109,7 @@
101109
alpha=.8,
102110
cmap='plasma'
103111
)
112+
113+
114+
############################################################################
115+
openml.config.stop_use_example_configuration()

examples/flows_and_runs_tutorial.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
#
1616
# Train a scikit-learn model on the data manually.
17+
# .. warning:: This example uploads data. For that reason, this example
18+
# connects to the test server instead. This prevents the live server from
19+
# crowding with example datasets, tasks, studies, and so on.
1720

21+
openml.config.start_use_example_configuration()
1822
# NOTE: Dataset 68 exists on the test server https://test.openml.org/d/68
1923
dataset = openml.datasets.get_dataset(68)
2024
X, y = dataset.get_data(
@@ -159,3 +163,7 @@
159163
run = openml.runs.run_model_on_task(clf, task, avoid_duplicate_runs=False)
160164
myrun = run.publish()
161165
print("kNN on %s: http://test.openml.org/r/%d" % (data.name, myrun.run_id))
166+
167+
168+
############################################################################
169+
openml.config.stop_use_example_configuration()

examples/introduction_tutorial.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,20 @@
4545
# file must be in the directory ~/.openml/config and exist prior to
4646
# importing the openml module.
4747
# * Run the code below, replacing 'YOURKEY' with your API key.
48-
48+
# .. warning:: This example uploads data. For that reason, this example
49+
# connects to the test server instead. This prevents the live server from
50+
# crowding with example datasets, tasks, studies, and so on.
4951
############################################################################
5052
import openml
5153
from sklearn import neighbors
5254

53-
# Uncomment and set your OpenML key. Don't share your key with others.
55+
openml.config.start_use_example_configuration()
56+
57+
############################################################################
58+
# When using the main server, instead make sure your apikey is configured.
59+
# This can be done with the following line of code (uncomment it!).
60+
# Never share your apikey with others.
61+
5462
# openml.config.apikey = 'YOURKEY'
5563

5664
############################################################################
@@ -83,3 +91,6 @@
8391
# as to not pollute the main server.
8492
myrun = run.publish()
8593
print("kNN on %s: http://test.openml.org/r/%d" % (data.name, myrun.run_id))
94+
95+
############################################################################
96+
openml.config.stop_use_example_configuration()

examples/run_setup_tutorial.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
and solve the same task again;
2626
3) We will verify that the obtained results are exactly the same.
2727
28+
.. warning:: This example uploads data. For that reason, this example
29+
connects to the test server instead. This prevents the live server from
30+
crowding with example datasets, tasks, studies, and so on.
2831
"""
2932
import logging
3033
import numpy as np
@@ -36,6 +39,7 @@
3639

3740
root = logging.getLogger()
3841
root.setLevel(logging.INFO)
42+
openml.config.start_use_example_configuration()
3943

4044
###############################################################################
4145
# 1) Create a flow and use it to solve a task
@@ -100,3 +104,7 @@
100104
# the run has stored all predictions in the field data content
101105
np.testing.assert_array_equal(run_original.data_content,
102106
run_duplicate.data_content)
107+
108+
###############################################################################
109+
110+
openml.config.stop_use_example_configuration()

examples/sklearn/openml_run_example.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
import openml
88
from sklearn import tree, preprocessing, pipeline
99

10+
############################################################################
11+
# .. warning:: This example uploads data. For that reason, this example
12+
# connects to the test server instead. This prevents the live server from
13+
# crowding with example datasets, tasks, studies, and so on.
14+
15+
openml.config.start_use_example_configuration()
16+
############################################################################
17+
1018
# Uncomment and set your OpenML key. Don't share your key with others.
1119
# openml.config.apikey = 'YOURKEY'
1220

@@ -27,3 +35,6 @@
2735
run.publish()
2836

2937
print('URL for run: %s/run/%d' % (openml.config.server, run.run_id))
38+
39+
############################################################################
40+
openml.config.stop_use_example_configuration()

0 commit comments

Comments
 (0)