Skip to content

Commit dc83f40

Browse files
committed
Add endpoint_url and cds_api_key to params schema
Addresses #65
1 parent e7f91b4 commit dc83f40

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## ESA CCI Open Data Portal / xcube Integration Setup\n",
8+
"\n",
9+
"To run the Notebooks in this folder, you will need a Python environment with [`xcube`](https://github.com/dcs4cop/xcube) and the `xcube` plugin [`xcube_cci`](https://github.com/dcs4cop/xcube-cci) installed.\n",
10+
"\n",
11+
"### Installation\n",
12+
"\n",
13+
"For creating an `xcube` Python environment and installing `xcube` follow the instructions given in the [xcube's README](https://github.com/dcs4cop/xcube/blob/master/README.md).\n",
14+
"For installing the `xcube_cci` plugin follow the instructions given in the [xcube-cci's README](https://github.com/dcs4cop/xcube-cci/blob/master/README.md).\n",
15+
"\n",
16+
"Before using Jupyter Lab for the first time install the `jupyterlab` package and make sure the \n",
17+
"[Jupyter GeoJSON extension](https://www.npmjs.com/package/@jupyterlab/geojson-extension) is installed too:\n",
18+
"\n",
19+
"```bash\n",
20+
"(xcube) conda install -c conda-forge jupyterlab\n",
21+
"(xcube) jupyter labextension install @jupyterlab/geojson-extension\n",
22+
"```\n",
23+
"\n",
24+
"### Running Juypter-Lab\n",
25+
"\n",
26+
"Start Jupyter Lab:\n",
27+
"\n",
28+
"```bash\n",
29+
"(xcube) $ jupyter-lab\n",
30+
"```\n",
31+
"\n",
32+
"### Test Setup\n",
33+
"\n",
34+
"Test whether setup was successful by importing some important `xcube_cci` exports:"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 1,
40+
"metadata": {},
41+
"outputs": [
42+
{
43+
"data": {
44+
"text/plain": [
45+
"'0.9.5'"
46+
]
47+
},
48+
"execution_count": 1,
49+
"metadata": {},
50+
"output_type": "execute_result"
51+
}
52+
],
53+
"source": [
54+
"from xcube_cci.version import version\n",
55+
"version"
56+
]
57+
}
58+
],
59+
"metadata": {
60+
"kernelspec": {
61+
"display_name": "Python 3 (ipykernel)",
62+
"language": "python",
63+
"name": "python3"
64+
},
65+
"language_info": {
66+
"codemirror_mode": {
67+
"name": "ipython",
68+
"version": 3
69+
},
70+
"file_extension": ".py",
71+
"mimetype": "text/x-python",
72+
"name": "python",
73+
"nbconvert_exporter": "python",
74+
"pygments_lexer": "ipython3",
75+
"version": "3.9.10"
76+
}
77+
},
78+
"nbformat": 4,
79+
"nbformat_minor": 4
80+
}

test/test_store.py

+13
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import os
4646
import re
4747
import tempfile
48+
import typing
4849
import unittest
4950
from collections.abc import Iterator
5051

@@ -329,6 +330,18 @@ def test_client_url_and_key_rc_file(self):
329330
self.assertEqual(endpoint_url, client.url)
330331
self.assertEqual(cds_api_key, client.key)
331332

333+
def test_new_datastore_with_credential_parameters(self):
334+
"""Test passing URL and key parameters to new_data_store"""
335+
336+
from xcube.core.store import new_data_store
337+
endpoint_url = 'https://example.com/'
338+
cds_api_key = 'plugh'
339+
store = typing.cast(CDSDataStore, new_data_store(
340+
'cds', endpoint_url=endpoint_url, cds_api_key=cds_api_key
341+
))
342+
self.assertEqual(endpoint_url, store.cds_api_url)
343+
self.assertEqual(cds_api_key, store.cds_api_key)
344+
332345
@staticmethod
333346
def _get_client(**opener_args):
334347
"""Return the client instantiated to open a dataset

xcube_cds/store.py

+2
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ def get_data_store_params_schema(cls) -> JsonObjectSchema:
752752
cds_params = dict(
753753
num_retries=JsonIntegerSchema(default=DEFAULT_NUM_RETRIES,
754754
minimum=0),
755+
endpoint_url=JsonStringSchema(),
756+
cds_api_key=JsonStringSchema(),
755757
)
756758

757759
params.update(cds_params)

0 commit comments

Comments
 (0)