Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename id in connection.load_collection #245

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jonathom
Copy link
Member

@jonathom jonathom commented Oct 5, 2021

Should the parameter also be changed in datacube.load_collection() and imagecollectionclient.load_collection()?

@@ -833,7 +833,7 @@ def load_collection(
"""
Load a DataCube by collection id.

:param collection_id: image collection identifier
Copy link
Member

Choose a reason for hiding this comment

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

Should this be deprecated instead of being removed?

Copy link
Member Author

@jonathom jonathom Oct 5, 2021

Choose a reason for hiding this comment

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

Would I just put @deprecated("Use 'id' instead") above the :param collection_id line?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me, but @soxofaan should have the final vote.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we can make a breaking change like this.
Existing code that uses keyword argument load_collection(collection_id="S2") will break.

There should be a fallback mechanism:

  • give id default value None
  • add a **kwargs and check if collection_id is set (and raise deprecation warning if that is the case)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what I meant to say :-D

Copy link
Member Author

Choose a reason for hiding this comment

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

@soxofaan

def load_collection(
    self,
    id: str = None,
[...]
    if "collection_id" in kwargs:
        id = kwargs["collection_id"]
        warnings.warn("The use of `collection_id` is deprecated, use `id` instead.", DeprecationWarning)

like so?

@@ -842,13 +842,13 @@ def load_collection(
"""
if self._api_version.at_least("1.0.0"):
return DataCube.load_collection(
collection_id=collection_id, connection=self,
collection_id=id, connection=self,
Copy link
Member

Choose a reason for hiding this comment

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

I think the load_collection methods of DataCube and ImageCollectionClient should also be addressed

but here it's fine to do it in a backwards incompatible way because these are practically "internal" methods nobody should be using

@soxofaan
Copy link
Member

soxofaan commented Oct 5, 2021

also to do:

  • test coverage for old style and new style
  • Changelog entry because this is somewhat "breaking" (with fallback mechanism)

@jonathom
Copy link
Member Author

jonathom commented Oct 5, 2021

test coverage for old style and new style

What do you mean by this?

@soxofaan
Copy link
Member

soxofaan commented Oct 5, 2021

test that both load_collection(collection_id="Sentinel2") and load_collection(id="Sentinel2") work

@jonathom
Copy link
Member Author

jonathom commented Oct 6, 2021

Alright, did that. Didn't add tests for imagecollectionclient and datacube yet, but I can if you want @soxofaan.

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.

Connection.load_collection: add/rename argument "id" (instead of "collection_id")
3 participants