Skip to content

added deprecation notices to older-style methods#128

Merged
marjo-luc merged 2 commits into
developfrom
chore/ogc-transition-prep
May 7, 2026
Merged

added deprecation notices to older-style methods#128
marjo-luc merged 2 commits into
developfrom
chore/ogc-transition-prep

Conversation

@marjo-luc
Copy link
Copy Markdown
Member

Preparatory work in support of the transition to OGC.

  • Added deprecation notices to older-style methods that older versions of maap-py use. If users call these methods, they will receive a message communicating deprecation along with the updated method to use.

Closes #1299

@marjo-luc marjo-luc self-assigned this May 6, 2026
@marjo-luc marjo-luc requested a review from sujen1412 May 6, 2026 20:08
Copy link
Copy Markdown
Contributor

@sujen1412 sujen1412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes for python client to raise a warning and not an HTTP code which is incorrect here since the HTTP method is not gone.
If we want to raise an error there should a be a true Exception being raised and not have the function return succesfully and the error is hidden in the json

Comment thread maap/maap.py Outdated
Comment on lines +234 to +257
def searchGranule(self):
"""
Search for granules in the CMR (Common Metadata Repository).

Queries the CMR database for granules matching the specified criteria.
Granules represent individual data files within a collection.

DEPRECATION NOTICE: This method is no longer supported. Use the following instead:

search_granule(limit=20, **kwargs)

limit : int, optional
Maximum number of results to return. Default is 20.
**kwargs : dict
Search parameters to filter results. Common parameters include:

"""
response = requests.Response()
response.status_code = 410
response._content = json.dumps({
"message": "searchGranule() is no longer supported. Use search_granule(limit=20, **kwargs) instead."
}).encode('utf-8')
response.headers['Content-Type'] = 'application/json'
return response
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code snippet will not give a warning to the caller instead give a hidden error message in the json with an HTTP code which is not relevant in a python function being deprecated.
One way to give warning would be show a warning message and not an error.

Suggested change
def searchGranule(self):
"""
Search for granules in the CMR (Common Metadata Repository).
Queries the CMR database for granules matching the specified criteria.
Granules represent individual data files within a collection.
DEPRECATION NOTICE: This method is no longer supported. Use the following instead:
search_granule(limit=20, **kwargs)
limit : int, optional
Maximum number of results to return. Default is 20.
**kwargs : dict
Search parameters to filter results. Common parameters include:
"""
response = requests.Response()
response.status_code = 410
response._content = json.dumps({
"message": "searchGranule() is no longer supported. Use search_granule(limit=20, **kwargs) instead."
}).encode('utf-8')
response.headers['Content-Type'] = 'application/json'
return response
def searchGranule(self, limit, **kwargs):
"""
Deprecated: use search_granule() instead.
"""
warnings.warn(
"searchGranule() is deprecated and will be removed in a future version. "
"Use search_granule(limit=20, **kwargs) instead.",
DeprecationWarning,
stacklevel=2
)
return self.search_granule(*args, **kwargs)

If we want to users to stop using that method and know that the method is no longer supported.

Suggested change
def searchGranule(self):
"""
Search for granules in the CMR (Common Metadata Repository).
Queries the CMR database for granules matching the specified criteria.
Granules represent individual data files within a collection.
DEPRECATION NOTICE: This method is no longer supported. Use the following instead:
search_granule(limit=20, **kwargs)
limit : int, optional
Maximum number of results to return. Default is 20.
**kwargs : dict
Search parameters to filter results. Common parameters include:
"""
response = requests.Response()
response.status_code = 410
response._content = json.dumps({
"message": "searchGranule() is no longer supported. Use search_granule(limit=20, **kwargs) instead."
}).encode('utf-8')
response.headers['Content-Type'] = 'application/json'
return response
def searchGranule(self, *args, **kwargs):
raise NotImplementedError(
"searchGranule() has been removed. "
"Use search_granule(limit=20, **kwargs) instead."
)

An HTTP code is wrong in this case as maap-py is a python client and not code for an API.

@marjo-luc marjo-luc requested a review from sujen1412 May 7, 2026 16:54
Copy link
Copy Markdown
Contributor

@sujen1412 sujen1412 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with note that raising better exceptions is coming in the next feature update.

@marjo-luc marjo-luc merged commit 4fbabf5 into develop May 7, 2026
2 checks passed
@marjo-luc marjo-luc deleted the chore/ogc-transition-prep branch May 7, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants