Skip to content

Commit

Permalink
Added deprecation Warning for STAC API Client (#161)
Browse files Browse the repository at this point in the history
* added deprecation warnings to stacapi.py and stacapi_io.py

* added deprecation warnings to stacapi.py and stacapi_io.py and changed NotImplementedErrors in data.py

* added deprecation warnings to stacapi.py and stacapi_io.py and changed NotImplementedErrors in data.py

* added deprecation warnings to stacapi.py and stacapi_io.py and changed NotImplementedErrors in data.py

Co-authored-by: Maxi Lehner <github@maxliehner.de>
  • Loading branch information
Zajquor and Maxi Lehner authored Jan 11, 2022
1 parent b214511 commit 93eda05
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
Changelog
=========
[1.3.4] (2022-01-11)
---------------------
Added
^^^^^
- added deprecation warnings in stacapi.py and stacapi_io.py

Changed
^^^^^^^
- changed NotImplementedErrors in data.py

[1.3.3] (2021-10-11)
---------------------
Added
Expand Down
2 changes: 1 addition & 1 deletion ukis_pysat/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.3"
__version__ = "1.3.4"
10 changes: 2 additions & 8 deletions ukis_pysat/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ def query_metadata(self, platform, date, aoi, cloud_cover=None, kwargs=None):
yield item

elif self.src == Datahub.STAC_API:
raise NotImplementedError(
f"Do this directly with our StacApi functionalities, see "
f"https://ukis-pysat.readthedocs.io/en/latest/api/stacapi.html."
)
raise NotImplementedError(f"Do this directly with the pystac-client functionalities.")

elif self.src == Datahub.EarthExplorer:
# query EarthExplorer for metadata
Expand Down Expand Up @@ -205,10 +202,7 @@ def query_metadata_srcid(self, platform, srcid):
yield item

elif self.src == Datahub.STAC_API:
raise NotImplementedError(
f"Do this directly with our StacApi functionalities, see "
f"https://ukis-pysat.readthedocs.io/en/latest/api/stacapi.html."
)
raise NotImplementedError(f"Do this directly with the pystac-client functionalities.")

elif self.src == Datahub.EarthExplorer:
from landsatxplore.util import guess_dataset
Expand Down
4 changes: 4 additions & 0 deletions ukis_pysat/stacapi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import os

import warnings

from urllib.parse import urljoin

try:
Expand All @@ -22,6 +25,7 @@ class StacApiError(Exception):

class StacApi:
def __init__(self, url=os.getenv("STAC_API_URL", None)):
warnings.warn("This feature is going to be deleted. Please use the pystac-client.", DeprecationWarning)
"""API to query STAC as part of ukis-pysat.data
:param url: STAC Server endpoint, reads from STAC_API_URL environment variable by default
"""
Expand Down
3 changes: 3 additions & 0 deletions ukis_pysat/stacapi_io.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from pystac import Item

import warnings


class STACAPI_IO:
def default_item_method(feature):
warnings.warn("This feature is going to be deleted. Please use the pystac-client.", DeprecationWarning)
return Item.from_dict(feature)

read_item_method = default_item_method
Expand Down

0 comments on commit 93eda05

Please sign in to comment.