Skip to content

Commit

Permalink
Add test for loading ml model with results url. Open-EO/openeo-geopys…
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileSonneveld committed Mar 19, 2024
1 parent ad4aeec commit 6fdf4f6
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
95 changes: 95 additions & 0 deletions tests/data/mlmodels/randomforest_ml_model_results.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"assets": {
"randomforest.model.tar.gz": {
"file:size": 666,
"href": "https://github.com/Open-EO/openeo-geopyspark-integrationtests/raw/master/tests/data/mlmodels/randomforest.model.tar.gz",
"roles": [
"data"
],
"title": "randomforest.model.tar.gz",
"type": "application/octet-stream"
}
},
"description": "This is an artificial results file for testing.",
"extent": {
"spatial": {
"bbox": [
[
3.4,
51.1,
3.6,
51.2
]
]
},
"temporal": {
"interval": [
[
"2018-03-01T00:00:00Z",
"2018-10-31T00:00:00Z"
]
]
}
},
"id": "j-57bd02e55b364f9d9c9cc919e5fd4afc",
"license": "proprietary",
"links": [
{
"href": "urn:eop:VITO:TERRASCOPE_S2_TOC_V2:S2B_20181023T105109_31UES_TOC_V200",
"rel": "derived_from",
"title": "Derived from urn:eop:VITO:TERRASCOPE_S2_TOC_V2:S2B_20181023T105109_31UES_TOC_V200",
"type": "application/json"
},
{
"href": "urn:eop:VITO:TERRASCOPE_S2_TOC_V2:S2B_20181026T110129_31UES_TOC_V200",
"rel": "derived_from",
"title": "Derived from urn:eop:VITO:TERRASCOPE_S2_TOC_V2:S2B_20181026T110129_31UES_TOC_V200",
"type": "application/json"
},
{
"href": "https://openeo-dev.vito.be/openeo/1.2/jobs/j-2403137d68e0467d81ba6f03e70f0e0e/results",
"rel": "self",
"type": "application/json"
},
{
"href": "https://openeo-dev.vito.be/openeo/1.2/jobs/j-2403137d68e0467d81ba6f03e70f0e0e/results/YzkwNzQyODYzMmI0NmNiNDA2ZWYwMmEwMWE0YTVkYzM0YWVkYWQzNzAzNjlkN2I5ZDVjMzE0YTNiNjY2ZmQwM0BlZ2kuZXU=/d768733e986cf6cb542f4db1c611ea9d?expires=1711449373",
"rel": "canonical",
"type": "application/json"
},
{
"href": "http://ceos.org/ard/files/PFS/SR/v5.0/CARD4L_Product_Family_Specification_Surface_Reflectance-v5.0.pdf",
"rel": "card4l-document",
"type": "application/pdf"
},
{
"href": "https://openeo-dev.vito.be/openeo/1.2/jobs/j-2403137d68e0467d81ba6f03e70f0e0e/results/items/YzkwNzQyODYzMmI0NmNiNDA2ZWYwMmEwMWE0YTVkYzM0YWVkYWQzNzAzNjlkN2I5ZDVjMzE0YTNiNjY2ZmQwM0BlZ2kuZXU=/1612fa1ac689e7052651db3ca3037e1e/ml_model_metadata.json?expires=1711449373",
"rel": "item",
"type": "application/json"
}
],
"openeo:status": "finished",
"providers": [
{}
],
"stac_extensions": [
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
"https://stac-extensions.github.io/file/v2.1.0/schema.json",
"https://stac-extensions.github.io/processing/v1.1.0/schema.json",
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
"https://stac-extensions.github.io/ml-model/v1.0.0/schema.json"
],
"stac_version": "1.0.0",
"summaries": {
"ml-model:architecture": [
"random-forest"
],
"ml-model:learning_approach": [
"supervised"
],
"ml-model:prediction_type": [
"classification"
]
},
"title": "random_forest.py",
"type": "Collection"
}
23 changes: 23 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,29 @@ def test_random_forest_load_from_http(auth_connection: openeo.Connection, tmp_pa
assert_geotiff_basics(with_link_output_file, min_width = 15, min_height = 15)


@pytest.mark.batchjob
@pytest.mark.timeout(BATCH_JOB_TIMEOUT)
def test_random_forest_load_from_http_results(auth_connection: openeo.Connection, tmp_path):
"""
Make predictions with the random forest model using a http link to the batch job results.
"""

topredict_xybt = auth_connection.load_collection('PROBAV_L3_S10_TOC_333M', bands=["NDVI"],
spatial_extent={"west": 4.785919, "east": 4.909629,
"south": 51.259766, "north": 51.307638},
temporal_extent=["2017-11-01", "2017-11-01"])
topredict_cube_xyb = topredict_xybt.reduce_dimension(dimension="t", reducer="mean")
# Make predictions with the random forest model using http link.
random_forest_metadata_link = "https://github.com/Open-EO/openeo-geopyspark-integrationtests/raw/master/tests/data/mlmodels/randomforest_ml_model_results.json"
predicted_with_link = topredict_cube_xyb.predict_random_forest(
model=random_forest_metadata_link,
dimension="bands"
)
with_link_output_file = tmp_path / "predicted_with_link.tiff"
predicted_with_link.download(with_link_output_file, format="GTiff")
assert_geotiff_basics(with_link_output_file, min_width=15, min_height=15)


@pytest.mark.batchjob
@pytest.mark.timeout(BATCH_JOB_TIMEOUT)
def test_random_forest_train_and_load_from_jobid(auth_connection: openeo.Connection, tmp_path):
Expand Down

0 comments on commit 6fdf4f6

Please sign in to comment.