-
Notifications
You must be signed in to change notification settings - Fork 42
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
jonathom
wants to merge
2
commits into
master
Choose a base branch
from
issue241_id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+43
−15
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -823,32 +823,38 @@ def datacube_from_json(self, src: Union[str, Path], parameters: dict = None) -> | |
|
||
def load_collection( | ||
self, | ||
collection_id: str, | ||
id: str = None, | ||
spatial_extent: Optional[Dict[str, float]] = None, | ||
temporal_extent: Optional[List[Union[str, datetime.datetime, datetime.date]]] = None, | ||
bands: Optional[List[str]] = None, | ||
properties: Optional[Dict[str, Union[str, PGNode, Callable]]] = None, | ||
fetch_metadata=True, | ||
**kwargs | ||
) -> DataCube: | ||
""" | ||
Load a DataCube by collection id. | ||
|
||
:param collection_id: image collection identifier | ||
:param id: image collection identifier | ||
jonathom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
:param spatial_extent: limit data to specified bounding box or polygons | ||
:param temporal_extent: limit data to specified temporal interval | ||
:param bands: only add the specified bands | ||
:param properties: limit data by metadata property predicates | ||
:return: a datacube containing the requested data | ||
""" | ||
|
||
if "collection_id" in kwargs: | ||
id = kwargs["collection_id"] | ||
warnings.warn("The use of `collection_id` is deprecated, use `id` instead.", DeprecationWarning) | ||
|
||
if self._api_version.at_least("1.0.0"): | ||
return DataCube.load_collection( | ||
collection_id=collection_id, connection=self, | ||
collection_id=id, connection=self, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the but here it's fine to do it in a backwards incompatible way because these are practically "internal" methods nobody should be using |
||
spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=bands, properties=properties, | ||
fetch_metadata=fetch_metadata, | ||
) | ||
else: | ||
return ImageCollectionClient.load_collection( | ||
collection_id=collection_id, session=self, | ||
collection_id=id, session=self, | ||
spatial_extent=spatial_extent, temporal_extent=temporal_extent, bands=bands | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
id
default value None**kwargs
and check ifcollection_id
is set (and raise deprecation warning if that is the case)There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@soxofaan
like so?