Skip to content

Commit

Permalink
Add submodules for monty-stac-extension and update collection urls
Browse files Browse the repository at this point in the history
  • Loading branch information
subinasr committed Feb 20, 2025
1 parent 80279f1 commit 24ea016
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 70 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "monty-stac-extension"]
path = monty-stac-extension
url = [email protected]:IFRCGo/monty-stac-extension.git
1 change: 1 addition & 0 deletions monty-stac-extension
Submodule monty-stac-extension added at 407a6c
6 changes: 3 additions & 3 deletions pystac_monty/sources/desinventar.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ class DesinventarTransformer(MontyDataTransformer):
errored_events: Dict[str, int] = {}

def __init__(self, data_source: DesinventarDataSource) -> None:
super().__init__("desiventar")
super().__init__("desinventar")
self.data_source = data_source
self.events_collection_id = "desinventar-events"
self.events_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/main/examples/desinventar-events/desinventar-events.json" # noqa: E501
self.events_collection_url = "../../monty-stac-extension/examples/desinventar-events/desinventar-events.json" # noqa: E501

self.impacts_collection_id = "desinventar-impacts"
self.impacts_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/main/examples/desinventar-impacts/desinventar-impacts.json" # noqa: E501
self.impacts_collection_url = "../../monty-stac-extension/examples/desinventar-impacts/desinventar-impacts.json" # noqa: E501

def create_datetimes(self, row: DataRow) -> datetime | None:
start_year = strtoi(row["year"], None)
Expand Down
18 changes: 6 additions & 12 deletions pystac_monty/sources/emdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,13 @@ class EMDATTransformer:
"""

emdat_events_collection_id = "emdat-events"
emdat_events_collection_url = (
"https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/EMDAT/examples/emdat-events/emdat-events.json"
)
emdat_events_collection_url = ("../../monty-stac-extension/examples/emdat-events/emdat-events.json")

emdat_hazards_collection_id = "emdat-hazards"
emdat_hazards_collection_url = (
"https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/EMDAT/examples/emdat-hazards/emdat-hazards.json"
)
emdat_hazards_collection_url = ("../../monty-stac-extension/examples/emdat-hazards/emdat-hazards.json")

emdat_impacts_collection_id = "emdat-impacts"
emdat_impacts_collection_url = (
"https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/EMDAT/examples/emdat-impacts/emdat-impacts.json"
)
emdat_impacts_collection_url = ("../../monty-stac-extension/examples/emdat-impacts/emdat-impacts.json")

hazard_profiles = MontyHazardProfiles()

Expand Down Expand Up @@ -302,19 +296,19 @@ def _get_row_by_disno(self, disno: str) -> Optional[pd.Series]:

def get_event_collection(self) -> Collection:
"""Get event collection"""
response = requests.get(self.emdat_events_collection_url)
response = open(self.emdat_events_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_hazard_collection(self) -> Collection:
"""Get hazard collection"""
response = requests.get(self.emdat_hazards_collection_url)
response = open(self.emdat_hazards_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_impact_collection(self) -> Collection:
"""Get impact collection"""
response = requests.get(self.emdat_impacts_collection_url)
response = open(self.emdat_impacts_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

Expand Down
18 changes: 6 additions & 12 deletions pystac_monty/sources/gdacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,13 @@ class GDACSTransformer:
"""

gdacs_events_collection_id = "gdacs-events"
gdacs_events_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/gdacs-events/gdacs-events.json"
)
gdacs_events_collection_url = ("../../monty-stac-extension/examples/gdacs-events/gdacs-events.json")

gdacs_hazards_collection_id = "gdacs-hazards"
gdacs_hazards_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/gdacs-hazards/gdacs-hazards.json"
)
gdacs_hazards_collection_url = ("../../monty-stac-extension/examples/gdacs-hazards/gdacs-hazards.json")

gdacs_impacts_collection_id = "gdacs-impacts"
gdacs_impacts_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/gdacs-impacts/gdacs-impacts.json"
)
gdacs_impacts_collection_url = ("../../monty-stac-extension/examples/gdacs-impacts/gdacs-impacts.json")

data: list[GDACSDataSource] = []
hazard_profiles = MontyHazardProfiles()
Expand All @@ -98,17 +92,17 @@ def make_items(self) -> list[Item]:
return items

def get_event_collection(self) -> Collection:
response = requests.get(self.gdacs_events_collection_url)
response = open(self.gdacs_events_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_hazard_collection(self) -> Collection:
response = requests.get(self.gdacs_hazards_collection_url)
response = open(self.gdacs_hazards_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_impact_collection(self) -> Collection:
response = requests.get(self.gdacs_impacts_collection_url)
response = open(self.gdacs_impacts_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

Expand Down
12 changes: 6 additions & 6 deletions pystac_monty/sources/gfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class GFDTransformer:
"""Transform the source data into the STAC items"""

gfd_events_collection_id = "gfd-events"
gfd_events_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/gfd-documentation/examples/gfd-events/gfd-events.json" # noqa
gfd_events_collection_url = "../../monty-stac-extension/examples/gfd-events/gfd-events.json" # noqa

gfd_hazards_collection_id = "gfd-hazards"
gfd_hazards_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/gfd-documentation/examples/gfd-hazards/gfd-hazards.json" # noqa
gfd_hazards_collection_url = "../../monty-stac-extension/examples/gfd-hazards/gfd-hazards.json" # noqa

gfd_impacts_collection_id = "gfd-impacts"
gfd_impacts_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/gfd-documentation/examples/gfd-impacts/gfd-impacts.json" # noqa
gfd_impacts_collection_url = "../../monty-stac-extension/examples/gfd-impacts/gfd-impacts.json" # noqa
hazard_profiles = MontyHazardProfiles()

def __init__(self, data: GFDDataSource):
Expand All @@ -65,19 +65,19 @@ def make_items(self) -> List[Item]:

def get_event_collection(self, timeout: int = 30) -> Collection:
"""Get Event collection"""
response = requests.get(self.gfd_events_collection_url, timeout=timeout)
response = open(self.gfd_events_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_hazard_collection(self, timeout: int = 30) -> Collection:
"""Get Hazard collection"""
response = requests.get(self.gfd_hazards_collection_url, timeout=timeout)
response = open(self.gfd_hazards_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_impact_collection(self, timeout: int = 30) -> Collection:
"""Get Impact collection"""
response = requests.get(self.gfd_impacts_collection_url, timeout=timeout)
response = open(self.gfd_impacts_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

Expand Down
14 changes: 5 additions & 9 deletions pystac_monty/sources/gidd.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ class GIDDTransformer:
"""Transforms GIDD event data into STAC Items"""

gidd_events_collection_id = "gidd-events"
gidd_events_collection_url = (
"https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/IDMC/" "examples/idmc-events/idmc-events.json"
)
gidd_events_collection_url = ("../../monty-stac-extension/examples/idmc-events/idmc-events.json")
# TODO: Make these events collection id consistent
gidd_hazards_collection_id = "idmc-gidd-impacts"
gidd_hazards_collection_url = (
"https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/IDMC/"
"examples/idmc-gidd-impacts/idmc-gidd-impacts.json"
)
gidd_hazards_collection_url = ("../../monty-stac-extension/examples/idmc-gidd-impacts/idmc-gidd-impacts.json")
hazard_profiles = MontyHazardProfiles()

def __init__(self, data: GIDDDataSource) -> None:
Expand Down Expand Up @@ -71,15 +67,15 @@ def make_items(self) -> List[Item]:

def get_event_collection(self, timeout: int = 30) -> Collection:
"""Get the event collection"""
response = requests.get(self.gidd_events_collection_url, timeout=timeout)
response = open(self.gidd_events_collection_url)
if response.status_code == 200:
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)
return Collection.from_dict({})

def get_impact_collection(self, timeout: int = 30) -> Collection:
"""Get the hazard collection"""
response = requests.get(self.gidd_hazards_collection_url, timeout=timeout)
response = open(self.gidd_hazards_collection_url)
if response.status_code == 200:
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)
Expand Down
12 changes: 4 additions & 8 deletions pystac_monty/sources/glide.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ class GlideTransformer:

hazard_profiles = MontyHazardProfiles()

glide_events_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/glide-events/glide-events.json"
)
glide_events_collection_url = ("../../monty-stac-extension/examples/glide-events/glide-events.json")

glide_hazard_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/glide-hazards/glide-hazards.json"
)
glide_hazard_collection_url = ("../../monty-stac-extension/examples/glide-hazards/glide-hazards.json")

def __init__(self, data: GlideDataSource) -> None:
self.data = data
Expand Down Expand Up @@ -182,13 +178,13 @@ def make_date(self, event_date: dict) -> datetime:

def get_event_collection(self, timeout: int = 30) -> Collection:
"""Get event collection"""
response = requests.get(self.glide_events_collection_url, timeout=timeout)
response = open(self.glide_events_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_hazard_collection(self, timeout: int = 30) -> Collection:
"""Get hazard collection"""
response = requests.get(self.glide_hazard_collection_url, timeout=timeout)
response = open(self.glide_hazard_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

Expand Down
6 changes: 4 additions & 2 deletions pystac_monty/sources/idu.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ class IDUTransformer:
"""Transform the source data into the STAC items"""

idu_events_collection_id = "idu-events"
idu_events_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/update-idu-documentation/examples/idu-events/idu-events.json" # noqa
idu_events_collection_url = "../../monty-stac-extension/examples/idmc-events/idmc-events.json" # noqa
idu_impacts_collection_id = "idu-impacts"
# TODO: Update idu collection url after the PR is merged in monty-stac-extension
idu_impacts_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/update-idu-documentation/examples/idu-impacts/idu-impacts.json" # noqa

hazard_profiles = MontyHazardProfiles()
Expand All @@ -69,14 +70,15 @@ def make_items(self) -> List[Item]:

def get_event_collection(self, timeout: int = 30) -> Collection:
"""Get the event collection"""
response = requests.get(self.idu_events_collection_url, timeout=timeout)
response = open(self.idu_events_collection_url)
if response.status_code == 200:
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)
return Collection.from_dict({})

def get_impact_collection(self, timeout: int = 30) -> Collection:
"""Get the impact collection"""
# TODO: Update this when the collection url is updated
response = requests.get(self.idu_events_collection_url, timeout=timeout)
if response.status_code == 200:
collection_dict = json.loads(response.text)
Expand Down
3 changes: 3 additions & 0 deletions pystac_monty/sources/ifrc_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_data(self) -> dict:

class IFRCEventTransformer:
ifrcevent_events_collection_id = "ifrcevent-events"
# TODO: Update collection url after IFRC DREF PR is merged
ifrcevent_events_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/collection-ifrc-event/examples/ifrcevent-events/ifrcevent_events.json" # noqa: E501
ifrcevent_impacts_collection_id = "ifrcevent-impacts"
ifrcevent_impacts_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/collection-ifrc-event/examples/ifrcevent-impacts/ifrcevent_impacts.json" # noqa: E501
Expand All @@ -47,12 +48,14 @@ def __init__(self, data: IFRCEventDataSource, geocoder: MontyGeoCoder):

def get_event_collection(self) -> Collection:
"""Get event collection"""
# TODO: Update request after collection url is updated
response = requests.get(self.ifrcevent_events_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)

def get_impact_collection(self) -> Collection:
"""Get event collection"""
# TODO: Update request after collection url is updated
response = requests.get(self.ifrcevent_impacts_collection_url)
collection_dict = json.loads(response.text)
return Collection.from_dict(collection_dict)
Expand Down
12 changes: 6 additions & 6 deletions pystac_monty/sources/pdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ class PDCTransformer:
"""Transform the source data into the STAC items"""

pdc_events_collection_id = "pdc-events"
pdc_events_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/pdc-documentation/examples/pdc-events/pdc-events.json" # noqa
pdc_events_collection_url = "../../monty-stac-extension/examples/pdc-events/pdc-events.json" # noqa
pdc_hazards_collection_id = "pdc-hazards"
pdc_hazards_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/pdc-documentation/examples/pdc-hazards/pdc-hazards.json" # noqa
pdc_hazards_collection_url = "../../monty-stac-extension/examples/pdc-hazards/pdc-hazards.json" # noqa
pdc_impacts_collection_id = "pdc-impacts"
pdc_impacts_collection_url = "https://raw.githubusercontent.com/IFRCGo/monty-stac-extension/refs/heads/feature/pdc-documentation/examples/pdc-impacts/pdc-impacts.json" # noqa
pdc_impacts_collection_url = "../../monty-stac-extension/examples/pdc-impacts/pdc-impacts.json" # noqa

hazard_profiles = MontyHazardProfiles()

Expand Down Expand Up @@ -94,19 +94,19 @@ def make_items(self) -> List[Item]:

def get_event_collection(self, timeout: int = 30):
"""Get Event Collection"""
response = requests.get(self.pdc_events_collection_url, timeout=timeout)
response = open(self.pdc_events_collection_url)
collection_dict = response.json()
return Collection.from_dict(collection_dict)

def get_hazard_collection(self, timeout: int = 30):
"""Get Hazard Collection"""
response = requests.get(self.pdc_hazards_collection_url, timeout=timeout)
response = open(self.pdc_hazards_collection_url)
collection_dict = response.json()
return Collection.from_dict(collection_dict)

def get_impact_collection(self, timeout: int = 30):
"""Get Impact Collection"""
response = requests.get(self.pdc_impacts_collection_url, timeout=timeout)
response = open(self.pdc_impacts_collection_url)
collection_dict = response.json()
return Collection.from_dict(collection_dict)

Expand Down
18 changes: 6 additions & 12 deletions pystac_monty/sources/usgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ def get_losses_data(self) -> Optional[dict]:
class USGSTransformer:
"""Transforms USGS earthquake event data into STAC Items."""

usgs_events_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/usgs/examples/usgs-events/usgs-events.json"
)
usgs_hazards_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/usgs/examples/usgs-hazards/usgs-hazards.json"
)
usgs_impacts_collection_url = (
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/usgs/examples/usgs-impacts/usgs-impacts.json"
)
usgs_events_collection_url = ("../../monty-stac-extension/examples/usgs-events/usgs-events.json")
usgs_hazards_collection_url = ("../../monty-stac-extension/examples/usgs-hazards/usgs-hazards.json")
usgs_impacts_collection_url = ("../../monty-stac-extension/examples/usgs-impacts/usgs-impacts.json")

hazard_profiles = MontyHazardProfiles()

Expand Down Expand Up @@ -576,15 +570,15 @@ def _create_impact_item_from_losses(

def get_event_collection(self) -> Collection:
"""Get event collection."""
response = requests.get(self.usgs_events_collection_url)
response = open(self.usgs_events_collection_url)
return Collection.from_dict(json.loads(response.text))

def get_hazard_collection(self) -> Collection:
"""Get hazard collection."""
response = requests.get(self.usgs_hazards_collection_url)
response = open(self.usgs_hazards_collection_url)
return Collection.from_dict(json.loads(response.text))

def get_impact_collection(self) -> Collection:
"""Get impact collection."""
response = requests.get(self.usgs_impacts_collection_url)
response = open(self.usgs_impacts_collection_url)
return Collection.from_dict(json.loads(response.text))

0 comments on commit 24ea016

Please sign in to comment.