Skip to content

Conversation

@sgillies
Copy link
Contributor

@sgillies sgillies commented Mar 8, 2023

This is take 2 of #858. After merging #860 (which reverted #858) the issue857 branch was in a state that I couldn't repair. So I started fresh. All the comments and examples of #858 still apply.

Resolves #857

@sgillies sgillies requested review from cholmes and jreiberkyle March 8, 2023 23:54
@sgillies
Copy link
Contributor Author

sgillies commented Mar 8, 2023

@jreiberkyle @cholmes review please 🙏

And just merge if you will, it's all good to go.

Copy link
Contributor

@jreiberkyle jreiberkyle left a comment

Choose a reason for hiding this comment

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

Some doc comments that may be helpful for @JuLeeAtPlanet

An opportunity to tweak the tests if you'd like to take it.

Yay for getting this into RC!

And test Session.client() within an async context
Copy link
Contributor

@jreiberkyle jreiberkyle left a comment

Choose a reason for hiding this comment

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

lgtm!

@kevinlacaille
Copy link
Contributor

kevinlacaille commented Mar 14, 2023

Could you please update both examples? It should only take a minute.

https://github.com/planetlabs/planet-client-python/blob/main/examples/orders_create_and_download_multiple_orders.py

https://github.com/planetlabs/planet-client-python/blob/main/examples/data_download_multiple_assets.py

Also, @mansi this will affect our notebooks and @emma-steuer this will affect your PR.

And use more keyword arguments to help users understand API semantics.
item_ids=['20200925_161029_69_2223', '20200925_161027_48_2223'],
product_bundle='analytic_udm2',
item_type='PSScene')
],
Copy link
Contributor Author

@sgillies sgillies Mar 14, 2023

Choose a reason for hiding this comment

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

Using product()'s keyword arguments makes the calls more understandable and the whole example more instructive.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes it much more readable, thank you!

# wait for completion
await client.wait(order['id'], callback=reporter.update_state)

# download
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed obvious comments and rolled them up into a docstring.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do the same thing for the data example.

)


async def create_and_download(client, order_detail, directory):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the client argument to the head of the list to make the signature of this function more like that of client.download_order(), where client (aka self) is implicitly the first argument.

await asyncio.gather(
create_and_download(iowa_order, DOWNLOAD_DIR, client),
create_and_download(oregon_order, DOWNLOAD_DIR, client),
create_and_download(client, iowa_order, DOWNLOAD_DIR),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comment above.

@sgillies
Copy link
Contributor Author

@kevinlacaille thanks for pointing out the examples! I'm going back to my ski vacation now.

import os

import planet

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we get rid of the 2020 copyright on line 1?

Copy link
Contributor

Choose a reason for hiding this comment

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

nope, according to @cholmes investigation, we just add a line above



async def download_and_validate(item_id, item_type_id, asset_type_id, client):
async def download_and_validate(client, item_id, item_type_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 like the positioning of client here, like self. I think you mentioned that in a comment somewhere. Great call.

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.

Looks great to me, thanks for addressing my concerns about the examples!

@jreiberkyle jreiberkyle merged commit 156e811 into main Mar 15, 2023
@jreiberkyle jreiberkyle deleted the issue857take2 branch March 15, 2023 19:06
}

oregon_images = ['20200909_182525_1014', '20200909_182524_1014']
oregon_items = ['20200909_182525_1014', '20200909_182524_1014']
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoopsie, the images suffix was from my old days in astronomy, thanks for catching this.

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.

Add a method to get a client from a Session instance

5 participants