Skip to content

Better CLI info for item types #650

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

Merged
merged 30 commits into from
Aug 10, 2022
Merged

Conversation

kevinlacaille
Copy link
Contributor

Created a working solution, but debating whether it should exist in planet.cli.data (current home), in planet.clients.data.DataClient.get_item_type()

@kevinlacaille kevinlacaille linked an issue Aug 2, 2022 that may be closed by this pull request
@kevinlacaille
Copy link
Contributor Author

kevinlacaille commented Aug 5, 2022

Almost done, except:

  • planet data search item-type <some invalid item type> doesn't give me the error message I'd like
    Expected: Raised NoMatchException from planet.specs.get_match()
    Returned: An error message from click.ClickException(), which routes to click.exceptions.ClickException.show(), which gets the message from click.exceptions.BadParameter.format_message(). Still unsure which function raises this exception, but I know it's not planet.cli.cmds.translate_exceptions.wraper().
    • UPDATE: Fixed this by creating a callback function, planet.cli.data.check_item_types(), and having click.argument call it for an error. Thanks @sgillies and rasterio tests!
  • Need to write tests for:
    • planet.cli.data.check_item_types() for new exception message
    • get_item_types() for the new case where product_bundle is empty
    • planet.cli.data.search(), stats(), search_create() for new epilog message

@kevinlacaille kevinlacaille self-assigned this Aug 5, 2022
@kevinlacaille kevinlacaille marked this pull request as ready for review August 10, 2022 13:43
@kevinlacaille
Copy link
Contributor Author

kevinlacaille commented Aug 10, 2022

planet.data.cli.py

  • Added epilog to all commands that use item_types (search(), search-create(), and stats()) to tell user which item types are valid inputs.
    • Added a callback function, check_item_types(), to raise a BadParameter exception when an invalid item type is given, with a helpful message.

planet.specs.py

  • Made get_item_types() more flexible. Namely, allowed it to return all item types supported by Order API when given no product bundle.
  • Added helpful a message to a NoMatchException exception.

tests.integration.test_data_cli.py

  • Added a test for the planet data search command. Specifically, this tests what the epilog returns.
  • Fixed all the erroneous tests that had item types placed in tuples, not comma separated strings (not sure why these tests were passing in the first place).

tests.unit.test_data_item_type.py

  • Created this new module to test a new callback function in the Data CLI, check_item_types(). Huge thanks to @sgillies and rasterio’s tests for the inspiration!

tests.unit.test_specs.py

  • Changed test_get_item_types() to test for a given product bundle.
  • Added a test to test get_item_types() without a given product bundle.

FYI: @jreiberkyle @cholmes @mkshah605

@kevinlacaille kevinlacaille removed the request for review from mkshah605 August 10, 2022 13:44
@kevinlacaille kevinlacaille changed the title Better cli info item types 572 Better CLI info for item types Aug 10, 2022
@kevinlacaille kevinlacaille requested a review from sgillies August 10, 2022 18:25
Copy link
Contributor

@sgillies sgillies left a comment

Choose a reason for hiding this comment

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

Good work @kevinlacaille !

@kevinlacaille kevinlacaille merged commit da0810d into main Aug 10, 2022
@kevinlacaille kevinlacaille deleted the better_cli_info_item-types_572 branch August 10, 2022 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better CLI information on item-type options
2 participants