Skip to content

Conversation

jreiberkyle
Copy link
Contributor

This PR is to be merged after #864 and assumes the item-type argument type is changed to str.

Related Issue(s):

Part of #506

Proposed Changes:

For inclusion in changelog (if applicable):

  1. Add AssetStatusBar reporter, use in data asset-wait cli command

Not intended for changelog:

Diff of User Interface

Old behavior:

New behavior:

> planet data asset-wait PSScene 20221003_002705_38_2461 basic_udm2
00:00 - [] 20221003_002705_38_2461 basic_udm2 - status: active
{'_links': {'_self': 'https://api.planet.com/data/v1/assets/eyJpIjogIjIwMjIxMDAzXzAwMjcwNV8zOF8yNDYxIiwgImMiOiAiUFNTY2VuZSIsICJ0IjogImJhc2ljX3VkbTIiLCAiY3QiOiAiaXRlbS10eXBlIn0', 'activate': 'https://api.planet.com/data/v1/assets/eyJpIjogIjIwMjIxMDAzXzAwMjcwNV8zOF8yNDYxIiwgImMiOiAiUFNTY2VuZSIsICJ0IjogImJhc2ljX3VkbTIiLCAiY3QiOiAiaXRlbS10eXBlIn0/activate', 'type': 'https://api.planet.com/data/v1/asset-types/basic_udm2'}, '_permissions': ['download'], 'expires_at': '2023-03-03T05:32:20.238271', 'location': 'https://api.planet.com/data/v1/download?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJjYkVGOTFxdXZjZ0E3Y0NIci1oUURxbHlmQ1M0WmJTNWZmWUEzdlFGYzVMcndCb0R5Tk1MbksyU2VHMnBlbThPTnVtZEtlczNiNXpWbk8yTXE5d0REUT09IiwiZXhwIjoxNjc3ODIxNTQwLCJ0b2tlbl90eXBlIjoidHlwZWQtaXRlbSIsIml0ZW1fdHlwZV9pZCI6IlBTU2NlbmUiLCJpdGVtX2lkIjoiMjAyMjEwMDNfMDAyNzA1XzM4XzI0NjEiLCJhc3NldF90eXBlIjoiYmFzaWNfdWRtMiJ9.J95vYO7ZXQho3pt47yZzfm3BRrrEqOH9d2k6jdJGQD4IKEOLzrpgEr0dGbjtSSyHuS5nopX23WX1_mYPN3yz3Q', 'md5_digest': '3a9f7dd1ce500f699d0a96afdd0e3aa2', 'status': 'active', 'type': 'basic_udm2'}

There is a [] entry above that will actually display the item-type (aka PSScene) when the item-type type is changed to str.

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

(Optional) @mentions for Notifications:

@jreiberkyle jreiberkyle self-assigned this Mar 3, 2023
@jreiberkyle jreiberkyle changed the base branch from main to data-asset-download-507 March 3, 2023 04:46

@property
def desc(self):
return f'{self.item_type} {self.item_id} {self.asset_type}'
Copy link
Contributor

@kevinlacaille kevinlacaille Mar 3, 2023

Choose a reason for hiding this comment

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

EDIT: This is a bug which is resolved when pulling in the most recent changes from your base branch. The bug stems from item_type being read in as a CommaSeparatedString, but it will now be read in as a string.

Is the bar supposed to read time - item_type item_ID asset_type - status: <status>? I currently seems to have some square brackets where item_type should be.

When I run it on my computer I get this:

❯ planet data asset-wait PSScene 20221003_002705_38_2461 basic_udm2                
00:00 - [] 20221003_002705_38_2461 basic_udm2 - status: active

assert not result.exception
assert "state: active" in result.output
assert "status: active" in result.output

Copy link
Contributor

Choose a reason for hiding this comment

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

I would check to see if all things you want to report end up in your reporting bar. Maybe something like this? This currently fails on my laptop, since item_type isn't showing up.

Suggested change
assert all([item in result.output for item in [item_type, item_id, asset_type_id]])

@kevinlacaille
Copy link
Contributor

I would recommend updating the reporting bar in the the data asset section of docs (cli-data.md).

i.e., Changing
00:00 - order my asset - state: active
to
00:00 - PSScene 20221003_002705_38_2461 basic_udm2 - status: active

max_attempts,
callback=bar.update_state)
click.echo(state)
with AssetStatusBar(item_type, item_id, asset_type_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the issue with item_type being reported as an empty list comes from item_type being brought in as a CommaSeparatedString.

When I change item_type to a string I get:
00:00 - PSScene 20221003_002705_38_2461 basic_udm2 - status: active

If you merge in recent changes from your base branch, this should fix this!

Copy link
Contributor

@kevinlacaille kevinlacaille left a comment

Choose a reason for hiding this comment

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

Overall, looks great! I would just take a look at my suggested fixes and update the docs. The issue with item_type not reporting properly will be fixed once you pull in your base branch.

Comment on lines +120 to +122
item_type,
item_id,
asset_type,
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth doing this:

Suggested change
item_type,
item_id,
asset_type,
item_type: str,
item_id: str,
asset_type: str,

Base automatically changed from data-asset-download-507 to main March 6, 2023 16:40
@jreiberkyle jreiberkyle merged commit 857d6da into main Mar 6, 2023
@jreiberkyle jreiberkyle deleted the data-asset-reporter branch March 6, 2023 18:18
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