Skip to content

Commit

Permalink
introducing delete items upon de-labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
baloola committed Oct 6, 2023
1 parent 1ae7175 commit 007b680
Show file tree
Hide file tree
Showing 67 changed files with 64 additions and 3,042 deletions.
2 changes: 1 addition & 1 deletion stac/stac-generator/stac-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def insert_value(field, value_list, listed_fields, doc):
index_catalog = pystac.Catalog.from_file('./stac_dist/catalog.json')
for index, issue in enumerate(issues):
labels = issue["node"]["labels"]["edges"]
requested = {'node': {'name': 'data-request'}}
requested = {'node': {'name': 'test-approved'}}
if requested in labels:

title = issue["node"]["title"].split("]: ")[-1].replace(" ", "_")
Expand Down
26 changes: 25 additions & 1 deletion stac/stac-generator/update_items.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
import requests
import os
import pystac
from requests.auth import HTTPBasicAuth

username = os.environ["USERNAME"]
password = os.environ["PASSWORD"]

catalog_url = "https://fairicube.github.io/data-requests/catalog.json"
post_url = "https://stacapi-write.eoxhub.fairicube.eu/collections/index/items"
# post_url = "http://0.0.0.0:8082/collections/index/items"


def delete_item(id):
response = requests.delete(url=f"{post_url}/{id}",
auth=HTTPBasicAuth(username, password))
return response.status_code


index_catalog = requests.get(catalog_url).json()
catalog = pystac.Catalog.from_dict(index_catalog)
catalog_items = catalog.get_items()

catalog_items_list = []

for item in catalog_items:
catalog_items_list.append(item.id)

api_items = requests.get(url=f"{post_url}?limit=1000",
auth=HTTPBasicAuth(username, password)).json()

# check if the already ingested items are in the catalog, otherwise delete them
for item in api_items["features"]:
if item["id"] not in catalog_items_list:
delete_item(item["id"])

for link in index_catalog["links"]:
if link["rel"] == "item":
json_body = requests.get(link["href"]).json()
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion stac_dist/COPERNICUS_30/COPERNICUS_30.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
90
],
"stac_extensions": [
"https://stac-extensions.github.io/raster/v1.0.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json"
]
}
2 changes: 1 addition & 1 deletion stac_dist/CORINE_LAND_COVER/CORINE_LAND_COVER.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
71
],
"stac_extensions": [
"https://stac-extensions.github.io/raster/v1.0.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
72
],
"stac_extensions": [
"https://stac-extensions.github.io/raster/v1.0.0/schema.json",
"https://stac-extensions.github.io/raster/v1.1.0/schema.json",
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json"
]
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 007b680

Please sign in to comment.