Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 139 additions & 31 deletions guides/execution_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,39 @@
"metadata": {},
"source": [
"# Service Execution\n",
"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)."
"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)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "0620587b-b6e9-4150-a6d3-d872171f68c5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: esa-apex-algorithms in /Users/bramjanssen/.pyenv/versions/3.10.12/lib/python3.10/site-packages (0.0.1)\n",
"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",
"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",
"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",
"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",
"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",
"\n",
"\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",
"\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",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install esa-apex-algorithms"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d99f5fbc",
"metadata": {},
"outputs": [],
Expand All @@ -34,12 +61,13 @@
"from shapely.geometry import shape\n",
"from pyproj import Transformer\n",
"from authlib.integrations.requests_client import OAuth2Session\n",
"from urllib.parse import urlparse, parse_qs"
"from urllib.parse import urlparse, parse_qs\n",
"from esa_apex_toolbox.algorithms import GithubAlgorithmRepository"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "e8c7ffff-4d0a-4e0c-bc98-44f90316f20c",
"metadata": {},
"outputs": [],
Expand All @@ -62,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "4139eacf-03a4-4815-83d2-b2ee04e90331",
"metadata": {},
"outputs": [],
Expand All @@ -84,36 +112,117 @@
},
{
"cell_type": "markdown",
"id": "a2179224-deec-4005-90ad-78122871b35a",
"id": "ab2349a7-5cb7-498c-af5d-d48d80084d65",
"metadata": {},
"source": [
"## Definition of parameters"
"## Look up the algorithm to execute"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f95065a9",
"execution_count": 5,
"id": "760e4d46-7e14-471c-b517-c62232f72fae",
"metadata": {},
"outputs": [],
"source": [
"dispatch_api = \"localhost:8000\""
"repo = GithubAlgorithmRepository(\n",
" owner=\"ESA-APEx\",\n",
" repo=\"apex_algorithms\",\n",
" folder=\"algorithm_catalog\",\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "251a343f",
"execution_count": 6,
"id": "16c3fbf4-dde4-49ab-a7d3-87e8ccc40664",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['wind_turbine',\n",
" 'eurac_pv_farm_detection',\n",
" 'gep_bas',\n",
" 'gep_ost',\n",
" 'sar_coin',\n",
" 'snap_insar_sentinel1_iw_slc',\n",
" 'bap_composite',\n",
" 'biopar',\n",
" 'fusets_mogpr',\n",
" 'max_ndvi',\n",
" 'max_ndvi_composite',\n",
" 'parcel_delineation',\n",
" 'random_forest_firemapping',\n",
" 'sentinel1_stats',\n",
" 'variabilitymap',\n",
" 'worldcereal_crop_extent',\n",
" 'worldcereal_crop_type',\n",
" 'worldcover_statistics',\n",
" 'worldagrocommodities']"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"repo.list_algorithms()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "ba7499b0-a4f6-4dc4-a11d-a6f204efdaa0",
"metadata": {},
"outputs": [],
"source": [
"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",
"endpoint = \"https://openeofed.dataspace.copernicus.eu\""
"service = repo.get_algorithm('eurac_pv_farm_detection')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"id": "3c23c79f-971c-4355-88b9-87bc3c41568f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"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')"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"service"
]
},
{
"cell_type": "markdown",
"id": "a2179224-deec-4005-90ad-78122871b35a",
"metadata": {},
"source": [
"## Definition of parameters"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f95065a9",
"metadata": {},
"outputs": [],
"source": [
"dispatch_api = \"localhost:8000\""
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "c83aa9d5",
"metadata": {},
"outputs": [],
Expand All @@ -136,7 +245,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "53d0800c-a6b3-4a64-a7a2-f27689adc7d7",
"metadata": {},
"outputs": [],
Expand All @@ -148,22 +257,22 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "6de8d686",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4fe3833455684ef3ad97a1e52e248de0",
"model_id": "64d0258c1ba5405492fe6dd0358a5d3d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[47.985, 16.378000000000004], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_t…"
]
},
"execution_count": 8,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -191,7 +300,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "47c7fe82-b611-404c-9cb8-204497dbec57",
"metadata": {},
"outputs": [],
Expand All @@ -202,7 +311,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 14,
"id": "b5ee27f5-9e69-4557-ba83-ec7cb74aa874",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -263,29 +372,29 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"id": "c5ca3fdd-7559-4fc7-8318-61b5dc59475f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"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"
"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"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
"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"
"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"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'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"
"{'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"
]
}
],
Expand All @@ -298,10 +407,9 @@
" json={\n",
" \"title\": \"PV Farm Detection\",\n",
" \"label\": \"openeo\",\n",
" \"service\": {\"\"\n",
"\n",
" \"endpoint\": endpoint,\n",
" \"application\": application\n",
" \"service\": {\n",
" \"endpoint\": service.service_links[0].href,\n",
" \"application\": service.udp_link.href\n",
" },\n",
" \"format\": output_format,\n",
" \"parameters\": {\n",
Expand All @@ -325,7 +433,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 16,
"id": "02e5c413-d110-4110-be59-c86e5226edc5",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -368,14 +476,14 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 17,
"id": "ac428293-7cd4-49a8-9bfa-4e0dc8f4d2cc",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3780c8a4fbb248f4a4fb6f9f05e9929c",
"model_id": "fb75b6e0c41f42f89c10dbe9e8c4fccc",
"version_major": 2,
"version_minor": 0
},
Expand Down
Loading