-
Notifications
You must be signed in to change notification settings - Fork 98
Let Session get clients by name #867
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
Changes from 1 commit
3623413
577e22a
5882a44
7d13359
67f2116
ca11ada
6c88b93
a6d0ab5
69eb2c3
0762454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ | |
| import planet | ||
|
|
||
| DOWNLOAD_DIR = os.getenv('TEST_DOWNLOAD_DIR', '.') | ||
|
|
||
sgillies marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| iowa_aoi = { | ||
| "type": | ||
| "Polygon", | ||
|
|
@@ -36,11 +36,18 @@ | |
| [-91.198465, 42.893071]]] | ||
| } | ||
|
|
||
| iowa_images = ['20200925_161029_69_2223', '20200925_161027_48_2223'] | ||
sgillies marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| iowa_order = planet.order_request.build_request( | ||
| 'iowa_order', | ||
| [planet.order_request.product(iowa_images, 'analytic_udm2', 'PSScene')], | ||
| tools=[planet.order_request.clip_tool(iowa_aoi)]) | ||
| name='iowa_order', | ||
| products=[ | ||
| planet.order_request.product( | ||
| item_ids=['20200925_161029_69_2223', '20200925_161027_48_2223'], | ||
| product_bundle='analytic_udm2', | ||
| item_type='PSScene') | ||
| ], | ||
|
Contributor
Author
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. Using product()'s keyword arguments makes the calls more understandable and the whole example more instructive.
Contributor
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. This makes it much more readable, thank you! |
||
| tools=[ | ||
| planet.order_request.clip_tool(aoi=iowa_aoi) | ||
| ] | ||
| ) | ||
|
|
||
| oregon_aoi = { | ||
| "type": | ||
|
|
@@ -50,33 +57,36 @@ | |
| [-117.558734, 45.229745]]] | ||
| } | ||
|
|
||
| oregon_images = ['20200909_182525_1014', '20200909_182524_1014'] | ||
| oregon_order = planet.order_request.build_request( | ||
| 'oregon_order', | ||
| [planet.order_request.product(oregon_images, 'analytic_udm2', 'PSScene')], | ||
| tools=[planet.order_request.clip_tool(oregon_aoi)]) | ||
|
|
||
|
|
||
| async def create_and_download(order_detail, directory, client): | ||
| name='oregon_order', | ||
| products=[ | ||
| planet.order_request.product( | ||
| item_ids=['20200909_182525_1014', '20200909_182524_1014'], | ||
| product_bundle='analytic_udm2', | ||
| item_type='PSScene') | ||
| ], | ||
| tools=[ | ||
| planet.order_request.clip_tool(aoi=oregon_aoi) | ||
| ] | ||
| ) | ||
|
|
||
|
|
||
| async def create_and_download(client, order_detail, directory): | ||
|
Contributor
Author
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 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 |
||
| """Place an order, wait for completion, and download assets as a single task.""" | ||
| with planet.reporting.StateBar(state='creating') as reporter: | ||
| # create | ||
| order = await client.create_order(order_detail) | ||
| reporter.update(state='created', order_id=order['id']) | ||
|
|
||
| # wait for completion | ||
| await client.wait(order['id'], callback=reporter.update_state) | ||
|
|
||
| # download | ||
|
Contributor
Author
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 removed obvious comments and rolled them up into a docstring.
Contributor
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. Let's do the same thing for the data example. |
||
| await client.download_order(order['id'], directory, progress_bar=True) | ||
|
|
||
|
|
||
| async def main(): | ||
| async with planet.Session() as ps: | ||
| client = planet.OrdersClient(ps) | ||
|
|
||
| async with planet.Session() as sess: | ||
| client = sess.client('orders') | ||
| 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), | ||
|
Contributor
Author
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. See comment above. |
||
| create_and_download(client, oregon_order, DOWNLOAD_DIR), | ||
| ) | ||
|
|
||
|
|
||
|
|
||
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 we get rid of the 2020 copyright on line 1?
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.
nope, according to @cholmes investigation, we just add a line above