|
6 | 6 | "metadata": {}, |
7 | 7 | "source": [ |
8 | 8 | "# 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)." |
10 | 10 | ] |
11 | 11 | }, |
12 | 12 | { |
13 | 13 | "cell_type": "code", |
14 | 14 | "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, |
15 | 42 | "id": "d99f5fbc", |
16 | 43 | "metadata": {}, |
17 | 44 | "outputs": [], |
|
34 | 61 | "from shapely.geometry import shape\n", |
35 | 62 | "from pyproj import Transformer\n", |
36 | 63 | "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" |
38 | 66 | ] |
39 | 67 | }, |
40 | 68 | { |
41 | 69 | "cell_type": "code", |
42 | | - "execution_count": 2, |
| 70 | + "execution_count": 3, |
43 | 71 | "id": "e8c7ffff-4d0a-4e0c-bc98-44f90316f20c", |
44 | 72 | "metadata": {}, |
45 | 73 | "outputs": [], |
|
62 | 90 | }, |
63 | 91 | { |
64 | 92 | "cell_type": "code", |
65 | | - "execution_count": 3, |
| 93 | + "execution_count": 4, |
66 | 94 | "id": "4139eacf-03a4-4815-83d2-b2ee04e90331", |
67 | 95 | "metadata": {}, |
68 | 96 | "outputs": [], |
|
84 | 112 | }, |
85 | 113 | { |
86 | 114 | "cell_type": "markdown", |
87 | | - "id": "a2179224-deec-4005-90ad-78122871b35a", |
| 115 | + "id": "ab2349a7-5cb7-498c-af5d-d48d80084d65", |
88 | 116 | "metadata": {}, |
89 | 117 | "source": [ |
90 | | - "## Definition of parameters" |
| 118 | + "## Look up the algorithm to execute" |
91 | 119 | ] |
92 | 120 | }, |
93 | 121 | { |
94 | 122 | "cell_type": "code", |
95 | | - "execution_count": 4, |
96 | | - "id": "f95065a9", |
| 123 | + "execution_count": 5, |
| 124 | + "id": "760e4d46-7e14-471c-b517-c62232f72fae", |
97 | 125 | "metadata": {}, |
98 | 126 | "outputs": [], |
99 | 127 | "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 | + " )" |
101 | 133 | ] |
102 | 134 | }, |
103 | 135 | { |
104 | 136 | "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", |
107 | 178 | "metadata": {}, |
108 | 179 | "outputs": [], |
109 | 180 | "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')" |
112 | 182 | ] |
113 | 183 | }, |
114 | 184 | { |
115 | 185 | "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, |
117 | 226 | "id": "c83aa9d5", |
118 | 227 | "metadata": {}, |
119 | 228 | "outputs": [], |
|
136 | 245 | }, |
137 | 246 | { |
138 | 247 | "cell_type": "code", |
139 | | - "execution_count": 7, |
| 248 | + "execution_count": 11, |
140 | 249 | "id": "53d0800c-a6b3-4a64-a7a2-f27689adc7d7", |
141 | 250 | "metadata": {}, |
142 | 251 | "outputs": [], |
|
148 | 257 | }, |
149 | 258 | { |
150 | 259 | "cell_type": "code", |
151 | | - "execution_count": 8, |
| 260 | + "execution_count": 12, |
152 | 261 | "id": "6de8d686", |
153 | 262 | "metadata": {}, |
154 | 263 | "outputs": [ |
155 | 264 | { |
156 | 265 | "data": { |
157 | 266 | "application/vnd.jupyter.widget-view+json": { |
158 | | - "model_id": "4fe3833455684ef3ad97a1e52e248de0", |
| 267 | + "model_id": "64d0258c1ba5405492fe6dd0358a5d3d", |
159 | 268 | "version_major": 2, |
160 | 269 | "version_minor": 0 |
161 | 270 | }, |
162 | 271 | "text/plain": [ |
163 | 272 | "Map(center=[47.985, 16.378000000000004], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_t…" |
164 | 273 | ] |
165 | 274 | }, |
166 | | - "execution_count": 8, |
| 275 | + "execution_count": 12, |
167 | 276 | "metadata": {}, |
168 | 277 | "output_type": "execute_result" |
169 | 278 | } |
|
191 | 300 | }, |
192 | 301 | { |
193 | 302 | "cell_type": "code", |
194 | | - "execution_count": 9, |
| 303 | + "execution_count": 13, |
195 | 304 | "id": "47c7fe82-b611-404c-9cb8-204497dbec57", |
196 | 305 | "metadata": {}, |
197 | 306 | "outputs": [], |
|
202 | 311 | }, |
203 | 312 | { |
204 | 313 | "cell_type": "code", |
205 | | - "execution_count": 10, |
| 314 | + "execution_count": 14, |
206 | 315 | "id": "b5ee27f5-9e69-4557-ba83-ec7cb74aa874", |
207 | 316 | "metadata": {}, |
208 | 317 | "outputs": [], |
|
263 | 372 | }, |
264 | 373 | { |
265 | 374 | "cell_type": "code", |
266 | | - "execution_count": 11, |
| 375 | + "execution_count": 15, |
267 | 376 | "id": "c5ca3fdd-7559-4fc7-8318-61b5dc59475f", |
268 | 377 | "metadata": {}, |
269 | 378 | "outputs": [ |
270 | 379 | { |
271 | 380 | "name": "stdout", |
272 | 381 | "output_type": "stream", |
273 | 382 | "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" |
275 | 384 | ] |
276 | 385 | }, |
277 | 386 | { |
278 | 387 | "name": "stdin", |
279 | 388 | "output_type": "stream", |
280 | 389 | "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" |
282 | 391 | ] |
283 | 392 | }, |
284 | 393 | { |
285 | 394 | "name": "stdout", |
286 | 395 | "output_type": "stream", |
287 | 396 | "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" |
289 | 398 | ] |
290 | 399 | } |
291 | 400 | ], |
|
298 | 407 | " json={\n", |
299 | 408 | " \"title\": \"PV Farm Detection\",\n", |
300 | 409 | " \"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", |
305 | 413 | " },\n", |
306 | 414 | " \"format\": output_format,\n", |
307 | 415 | " \"parameters\": {\n", |
|
325 | 433 | }, |
326 | 434 | { |
327 | 435 | "cell_type": "code", |
328 | | - "execution_count": 12, |
| 436 | + "execution_count": 16, |
329 | 437 | "id": "02e5c413-d110-4110-be59-c86e5226edc5", |
330 | 438 | "metadata": {}, |
331 | 439 | "outputs": [], |
|
368 | 476 | }, |
369 | 477 | { |
370 | 478 | "cell_type": "code", |
371 | | - "execution_count": 13, |
| 479 | + "execution_count": 17, |
372 | 480 | "id": "ac428293-7cd4-49a8-9bfa-4e0dc8f4d2cc", |
373 | 481 | "metadata": {}, |
374 | 482 | "outputs": [ |
375 | 483 | { |
376 | 484 | "data": { |
377 | 485 | "application/vnd.jupyter.widget-view+json": { |
378 | | - "model_id": "3780c8a4fbb248f4a4fb6f9f05e9929c", |
| 486 | + "model_id": "fb75b6e0c41f42f89c10dbe9e8c4fccc", |
379 | 487 | "version_major": 2, |
380 | 488 | "version_minor": 0 |
381 | 489 | }, |
|
0 commit comments