Skip to content

Commit 1c25f30

Browse files
committed
chore: updated notebooks for demo
1 parent 288c37a commit 1c25f30

File tree

2 files changed

+275
-72
lines changed

2 files changed

+275
-72
lines changed

guides/execution_example.ipynb

Lines changed: 139 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,39 @@
66
"metadata": {},
77
"source": [
88
"# Service Execution\n",
9-
"This notebooks showcases a demo of the [APEx Dispatch API](https://github.com/ESA-APEx/apex_dispatch_api) for executing a service. In this notebook we will perform the execution for one of the services in the [APEx Algoritm Services Catalogue](https://algorithm-catalogue.apex.esa.int/), specfically the [Wind Turbine Detection](https://algorithm-catalogue.apex.esa.int/apps/wind_turbine_detection#execution-information)."
9+
"This notebooks showcases a demo of the [APEx Dispatch API](https://github.com/ESA-APEx/apex_dispatch_api) for executing a service. In this notebook we will perform the execution for one of the services in the [APEx Algoritm Services Catalogue](https://algorithm-catalogue.apex.esa.int/), specfically the [PV Farm Detection](https://algorithm-catalogue.apex.esa.int/apps/eurac_pv_farm_detection#description)."
1010
]
1111
},
1212
{
1313
"cell_type": "code",
1414
"execution_count": 1,
15+
"id": "0620587b-b6e9-4150-a6d3-d872171f68c5",
16+
"metadata": {},
17+
"outputs": [
18+
{
19+
"name": "stdout",
20+
"output_type": "stream",
21+
"text": [
22+
"Requirement already satisfied: esa-apex-algorithms in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (0.0.1)\n",
23+
"Requirement already satisfied: requests>=2.30.0 in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (from esa-apex-algorithms) (2.32.3)\n",
24+
"Requirement already satisfied: certifi>=2017.4.17 in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (from requests>=2.30.0->esa-apex-algorithms) (2025.1.31)\n",
25+
"Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (from requests>=2.30.0->esa-apex-algorithms) (2.3.0)\n",
26+
"Requirement already satisfied: charset-normalizer<4,>=2 in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (from requests>=2.30.0->esa-apex-algorithms) (3.4.1)\n",
27+
"Requirement already satisfied: idna<4,>=2.5 in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (from requests>=2.30.0->esa-apex-algorithms) (3.10)\n",
28+
"\n",
29+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n",
30+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
31+
"Note: you may need to restart the kernel to use updated packages.\n"
32+
]
33+
}
34+
],
35+
"source": [
36+
"%pip install esa-apex-algorithms"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": 2,
1542
"id": "d99f5fbc",
1643
"metadata": {},
1744
"outputs": [],
@@ -34,12 +61,13 @@
3461
"from shapely.geometry import shape\n",
3562
"from pyproj import Transformer\n",
3663
"from authlib.integrations.requests_client import OAuth2Session\n",
37-
"from urllib.parse import urlparse, parse_qs"
64+
"from urllib.parse import urlparse, parse_qs\n",
65+
"from esa_apex_toolbox.algorithms import GithubAlgorithmRepository"
3866
]
3967
},
4068
{
4169
"cell_type": "code",
42-
"execution_count": 2,
70+
"execution_count": 3,
4371
"id": "e8c7ffff-4d0a-4e0c-bc98-44f90316f20c",
4472
"metadata": {},
4573
"outputs": [],
@@ -62,7 +90,7 @@
6290
},
6391
{
6492
"cell_type": "code",
65-
"execution_count": 3,
93+
"execution_count": 4,
6694
"id": "4139eacf-03a4-4815-83d2-b2ee04e90331",
6795
"metadata": {},
6896
"outputs": [],
@@ -84,36 +112,117 @@
84112
},
85113
{
86114
"cell_type": "markdown",
87-
"id": "a2179224-deec-4005-90ad-78122871b35a",
115+
"id": "ab2349a7-5cb7-498c-af5d-d48d80084d65",
88116
"metadata": {},
89117
"source": [
90-
"## Definition of parameters"
118+
"## Look up the algorithm to execute"
91119
]
92120
},
93121
{
94122
"cell_type": "code",
95-
"execution_count": 4,
96-
"id": "f95065a9",
123+
"execution_count": 5,
124+
"id": "760e4d46-7e14-471c-b517-c62232f72fae",
97125
"metadata": {},
98126
"outputs": [],
99127
"source": [
100-
"dispatch_api = \"localhost:8000\""
128+
"repo = GithubAlgorithmRepository(\n",
129+
" owner=\"ESA-APEx\",\n",
130+
" repo=\"apex_algorithms\",\n",
131+
" folder=\"algorithm_catalog\",\n",
132+
" )"
101133
]
102134
},
103135
{
104136
"cell_type": "code",
105-
"execution_count": 5,
106-
"id": "251a343f",
137+
"execution_count": 6,
138+
"id": "16c3fbf4-dde4-49ab-a7d3-87e8ccc40664",
139+
"metadata": {},
140+
"outputs": [
141+
{
142+
"data": {
143+
"text/plain": [
144+
"['wind_turbine',\n",
145+
" 'eurac_pv_farm_detection',\n",
146+
" 'gep_bas',\n",
147+
" 'gep_ost',\n",
148+
" 'sar_coin',\n",
149+
" 'snap_insar_sentinel1_iw_slc',\n",
150+
" 'bap_composite',\n",
151+
" 'biopar',\n",
152+
" 'fusets_mogpr',\n",
153+
" 'max_ndvi',\n",
154+
" 'max_ndvi_composite',\n",
155+
" 'parcel_delineation',\n",
156+
" 'random_forest_firemapping',\n",
157+
" 'sentinel1_stats',\n",
158+
" 'variabilitymap',\n",
159+
" 'worldcereal_crop_extent',\n",
160+
" 'worldcereal_crop_type',\n",
161+
" 'worldcover_statistics',\n",
162+
" 'worldagrocommodities']"
163+
]
164+
},
165+
"execution_count": 6,
166+
"metadata": {},
167+
"output_type": "execute_result"
168+
}
169+
],
170+
"source": [
171+
"repo.list_algorithms()"
172+
]
173+
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": 7,
177+
"id": "ba7499b0-a4f6-4dc4-a11d-a6f204efdaa0",
107178
"metadata": {},
108179
"outputs": [],
109180
"source": [
110-
"application = \"https://raw.githubusercontent.com/ESA-APEx/apex_algorithms/refs/heads/main/algorithm_catalog/eurac/eurac_pv_farm_detection/openeo_udp/eurac_pv_farm_detection.json\"\n",
111-
"endpoint = \"https://openeofed.dataspace.copernicus.eu\""
181+
"service = repo.get_algorithm('eurac_pv_farm_detection')"
112182
]
113183
},
114184
{
115185
"cell_type": "code",
116-
"execution_count": 6,
186+
"execution_count": 8,
187+
"id": "3c23c79f-971c-4355-88b9-87bc3c41568f",
188+
"metadata": {},
189+
"outputs": [
190+
{
191+
"data": {
192+
"text/plain": [
193+
"Algorithm(id='eurac_pv_farm_detection', title='Photovoltaic farms mapping', description='Demonstrator service for the detection of photovoltaic farms. Photovoltaic farms (PV farms) mapping is essential for establishing valid policies regarding natural resources management and clean energy. ', udp_link=UdpLink(href='https://raw.githubusercontent.com/ESA-APEx/apex_algorithms/refs/heads/main/algorithm_catalog/eurac/eurac_pv_farm_detection/openeo_udp/eurac_pv_farm_detection.json', title='openEO Process Definition'), service_links=[ServiceLink(href='https://openeofed.dataspace.copernicus.eu', title='CDSE openEO federation')], license=None, organization='Eurac Research')"
194+
]
195+
},
196+
"execution_count": 8,
197+
"metadata": {},
198+
"output_type": "execute_result"
199+
}
200+
],
201+
"source": [
202+
"service"
203+
]
204+
},
205+
{
206+
"cell_type": "markdown",
207+
"id": "a2179224-deec-4005-90ad-78122871b35a",
208+
"metadata": {},
209+
"source": [
210+
"## Definition of parameters"
211+
]
212+
},
213+
{
214+
"cell_type": "code",
215+
"execution_count": 9,
216+
"id": "f95065a9",
217+
"metadata": {},
218+
"outputs": [],
219+
"source": [
220+
"dispatch_api = \"localhost:8000\""
221+
]
222+
},
223+
{
224+
"cell_type": "code",
225+
"execution_count": 10,
117226
"id": "c83aa9d5",
118227
"metadata": {},
119228
"outputs": [],
@@ -136,7 +245,7 @@
136245
},
137246
{
138247
"cell_type": "code",
139-
"execution_count": 7,
248+
"execution_count": 11,
140249
"id": "53d0800c-a6b3-4a64-a7a2-f27689adc7d7",
141250
"metadata": {},
142251
"outputs": [],
@@ -148,22 +257,22 @@
148257
},
149258
{
150259
"cell_type": "code",
151-
"execution_count": 8,
260+
"execution_count": 12,
152261
"id": "6de8d686",
153262
"metadata": {},
154263
"outputs": [
155264
{
156265
"data": {
157266
"application/vnd.jupyter.widget-view+json": {
158-
"model_id": "4fe3833455684ef3ad97a1e52e248de0",
267+
"model_id": "64d0258c1ba5405492fe6dd0358a5d3d",
159268
"version_major": 2,
160269
"version_minor": 0
161270
},
162271
"text/plain": [
163272
"Map(center=[47.985, 16.378000000000004], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_t…"
164273
]
165274
},
166-
"execution_count": 8,
275+
"execution_count": 12,
167276
"metadata": {},
168277
"output_type": "execute_result"
169278
}
@@ -191,7 +300,7 @@
191300
},
192301
{
193302
"cell_type": "code",
194-
"execution_count": 9,
303+
"execution_count": 13,
195304
"id": "47c7fe82-b611-404c-9cb8-204497dbec57",
196305
"metadata": {},
197306
"outputs": [],
@@ -202,7 +311,7 @@
202311
},
203312
{
204313
"cell_type": "code",
205-
"execution_count": 10,
314+
"execution_count": 14,
206315
"id": "b5ee27f5-9e69-4557-ba83-ec7cb74aa874",
207316
"metadata": {},
208317
"outputs": [],
@@ -263,29 +372,29 @@
263372
},
264373
{
265374
"cell_type": "code",
266-
"execution_count": 11,
375+
"execution_count": 15,
267376
"id": "c5ca3fdd-7559-4fc7-8318-61b5dc59475f",
268377
"metadata": {},
269378
"outputs": [
270379
{
271380
"name": "stdout",
272381
"output_type": "stream",
273382
"text": [
274-
"Open this URL in your browser: https://auth.dev.apex.esa.int/realms/apex/protocol/openid-connect/auth?response_type=code&client_id=apex-dispatcher-api-dev&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcallback&state=UHVmNmG43imicvDFxGrvj70H5JAXQ8\n"
383+
"Open this URL in your browser: https://auth.dev.apex.esa.int/realms/apex/protocol/openid-connect/auth?response_type=code&client_id=apex-dispatcher-api-dev&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcallback&state=13LGG7k5j3LJXZg9gkzwCyTqCEMIGU\n"
275384
]
276385
},
277386
{
278387
"name": "stdin",
279388
"output_type": "stream",
280389
"text": [
281-
"Paste the redirect URL here: http://localhost:8000/callback?state=UHVmNmG43imicvDFxGrvj70H5JAXQ8&session_state=6b99a56f-734f-4c38-b907-085815435e0b&iss=https%3A%2F%2Fauth.dev.apex.esa.int%2Frealms%2Fapex&code=c62e2916-9ec0-452d-acba-38a0e0705bc3.6b99a56f-734f-4c38-b907-085815435e0b.c2e791df-00a5-4981-b8af-b014848a2b73\n"
390+
"Paste the redirect URL here: http://localhost:8000/callback?state=13LGG7k5j3LJXZg9gkzwCyTqCEMIGU&session_state=2851af12-bde4-4034-b4ad-4a9e5501345f&iss=https%3A%2F%2Fauth.dev.apex.esa.int%2Frealms%2Fapex&code=d0d5bec8-7a7c-4230-b0ff-8ecd6bab4e54.2851af12-bde4-4034-b4ad-4a9e5501345f.c2e791df-00a5-4981-b8af-b014848a2b73\n"
282391
]
283392
},
284393
{
285394
"name": "stdout",
286395
"output_type": "stream",
287396
"text": [
288-
"{'id': 148, 'title': 'PV Farm Detection', 'label': 'openeo', 'status': 'created', 'service': {'endpoint': 'https://openeofed.dataspace.copernicus.eu', 'application': 'https://raw.githubusercontent.com/ESA-APEx/apex_algorithms/refs/heads/main/algorithm_catalog/eurac/eurac_pv_farm_detection/openeo_udp/eurac_pv_farm_detection.json'}, 'parameters': {'spatial_extent': {'west': 16.342, 'south': 47.962, 'east': 16.414, 'north': 48.008}, 'temporal_extent': ['2023-05-01', '2023-09-30']}}\n"
397+
"{'id': 195, 'title': 'PV Farm Detection', 'label': 'openeo', 'status': 'created', 'service': {'endpoint': 'https://openeofed.dataspace.copernicus.eu', 'application': 'https://raw.githubusercontent.com/ESA-APEx/apex_algorithms/refs/heads/main/algorithm_catalog/eurac/eurac_pv_farm_detection/openeo_udp/eurac_pv_farm_detection.json'}, 'parameters': {'spatial_extent': {'west': 16.342, 'south': 47.962, 'east': 16.414, 'north': 48.008}, 'temporal_extent': ['2023-05-01', '2023-09-30']}}\n"
289398
]
290399
}
291400
],
@@ -298,10 +407,9 @@
298407
" json={\n",
299408
" \"title\": \"PV Farm Detection\",\n",
300409
" \"label\": \"openeo\",\n",
301-
" \"service\": {\"\"\n",
302-
"\n",
303-
" \"endpoint\": endpoint,\n",
304-
" \"application\": application\n",
410+
" \"service\": {\n",
411+
" \"endpoint\": service.service_links[0].href,\n",
412+
" \"application\": service.udp_link.href\n",
305413
" },\n",
306414
" \"format\": output_format,\n",
307415
" \"parameters\": {\n",
@@ -325,7 +433,7 @@
325433
},
326434
{
327435
"cell_type": "code",
328-
"execution_count": 12,
436+
"execution_count": 16,
329437
"id": "02e5c413-d110-4110-be59-c86e5226edc5",
330438
"metadata": {},
331439
"outputs": [],
@@ -368,14 +476,14 @@
368476
},
369477
{
370478
"cell_type": "code",
371-
"execution_count": 13,
479+
"execution_count": 17,
372480
"id": "ac428293-7cd4-49a8-9bfa-4e0dc8f4d2cc",
373481
"metadata": {},
374482
"outputs": [
375483
{
376484
"data": {
377485
"application/vnd.jupyter.widget-view+json": {
378-
"model_id": "3780c8a4fbb248f4a4fb6f9f05e9929c",
486+
"model_id": "fb75b6e0c41f42f89c10dbe9e8c4fccc",
379487
"version_major": 2,
380488
"version_minor": 0
381489
},

0 commit comments

Comments
 (0)