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

WIP Features client #1073

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

WIP Features client #1073

wants to merge 1 commit into from

Conversation

tbarsballe
Copy link
Contributor

Includes: list_collections, create_collection, list_features, create_features

This came out of an internal need for a project I was working on incorporating the SDK, and represents about the extent of time I have to contribute to Features API support at this time. If someone else can pick up from where this started, that would be great.

I have programmatically and manually tested all of the the FeaturesClient methods in the context of the project described above, and everything seems to be working. In particular, the API has different pagination scheme, currently handled by overriding Paged.__next_link, that could perhaps be incorporated directly into Paged, since the as-of-yet-unimplemented Analytics API uses the same pagination scheme.

Related Issue(s):

Oddly enough, we do not seem to have an issue for Features API support yet.

Proposed Changes:

For inclusion in changelog (if applicable):

  1. Add FeaturesClient to support the Features API

PR Checklist:

  • This PR is as small and focused as possible
  • If this PR includes proposed changes for inclusion in the changelog, the title of this PR summarizes those changes and is ready for inclusion in the Changelog.
  • I have updated docstrings for function changes and docs in the 'docs' folder for user interface / behavior changes
  • This PR does not break any examples or I have updated them

def _next_link(self, page):
next_link = False

#TODO: Build this into Paged.__next_link directly, other (unimplemented) APIs have a similar page structure
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#TODO: Build this into Paged.__next_link directly, other (unimplemented) APIs have a similar page structure
# TODO: Build this into Paged.__next_link directly, other (unimplemented) APIs have a similar page structure

LOGGER.debug('end of the pages')
return next_link

params = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
params = {}
params: list[str, Any] = {}

This is failing the mypy check since we're adding multiple types into this dict.

property_id: Optional[str] = None) -> AsyncIterator[str]:

url = f'{self._base_url}/collections/{collection_id}/items'
params = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
params = {}
params: dict[str, Any] = {}

"""Planet Features API Python client."""

import logging
from typing import AsyncIterator, Optional, Iterator
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from typing import AsyncIterator, Optional, Iterator
from typing import Any, AsyncIterator, Optional

@stephenhillier
Copy link
Contributor

I added some minor suggestions for the type errors. Just remembered your request for somebody picking this up so no need to follow up.

Looks like the biggest piece remaining is some test coverage. Maybe one of us can tackle that during one of the working session time blocks.

@tbarsballe
Copy link
Contributor Author

Thanks for taking a look. Test coverage is definitely a big missing piece.

CLI integration would be the other major part that's lacking, since this realy only covers the SDK part right now.

There's also a number of other Features API endpoints to implement - so far this covers all the major ones, but not any of the less-used ones (e.g. "alternates" or "validate")

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