Skip to content

Commit

Permalink
Change docstring examples from pycon -> python
Browse files Browse the repository at this point in the history
This is 2.1b1
  • Loading branch information
sgillies committed Jul 11, 2023
1 parent 53b9478 commit 33f6903
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 63 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
2.1.0 (TBD)

2.1b1 (2023-07-11)

Added:
- Support for catalog source publishing stages (#977) and time range types
(#978) have been added to subscription_request.catalog_source.
Expand Down
2 changes: 1 addition & 1 deletion planet/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.0dev'
__version__ = '2.1b1'
134 changes: 73 additions & 61 deletions planet/subscription_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,32 @@ def build_request(name: str,
constructed.
Examples:
```python
>>> from datetime import datetime
>>> from planet.subscription_request import (
... build_request, catalog_source, amazon_s3)
...
... geom = {
... "coordinates": [[[139.5648193359375,35.42374884923695],
... [140.1031494140625,35.42374884923695],
... [140.1031494140625,35.77102915686019],
... [139.5648193359375,35.77102915686019],
... [139.5648193359375,35.42374884923695]]],
... "type": "Polygon"
... }
>>> source = catalog_source(
... ["PSScene"], ["ortho_analytic_4b"], geom, datetime(2021,3,1))
>>> delivery = amazon_s3(
... ACCESS_KEY_ID, SECRET_ACCESS_KEY, "test", "us-east-1")
...
>>> subscription_request = build_request(
... 'test_subscription', source=source, delivery=delivery)
...
```
from datetime import datetime
from planet.subscription_request import build_request, catalog_source, amazon_s3
geom = {
"coordinates": [
[
[139.5648193359375, 35.42374884923695],
[140.1031494140625, 35.42374884923695],
[140.1031494140625, 35.77102915686019],
[139.5648193359375, 35.77102915686019],
[139.5648193359375, 35.42374884923695],
]
],
"type": "Polygon",
}
source = catalog_source(["PSScene"], ["ortho_analytic_4b"], geom, datetime(2021, 3, 1))
delivery = amazon_s3(ACCESS_KEY_ID, SECRET_ACCESS_KEY, "test", "us-east-1")
subscription_request = build_request(
"test_subscription", source=source, delivery=delivery
)
```
"""
# Because source and delivery are Mappings we must make copies for
# the function's return value. dict() shallow copies a Mapping
Expand Down Expand Up @@ -179,6 +181,7 @@ def catalog_source(
Only monthly recurrences are supported at this time.
publishing_stages: A sequence of one or more of the values
"preview", "standard", or "finalized".
time_range_type: "acquired" (new in 2.1.0) or "published".
Returns:
dict: a representation of a subscription source.
Expand All @@ -188,28 +191,30 @@ def catalog_source(
configured.
Examples:
```pycon
>>> source = catalog_source(
... ["PSScene"],
... ["ortho_analytic_4b"],
... geometry={
... "type": "Polygon",
... "coordinates": [[[37.791595458984375, 14.84923123791421],
... [37.90214538574219, 14.84923123791421],
... [37.90214538574219, 14.945448293647944],
... [37.791595458984375, 14.945448293647944],
... [37.791595458984375, 14.84923123791421]]]
... },
... start_time=datetime(2021, 3, 1),
... publishing_stages=["standard"],
... time_range_type="acquired",
... )
>>> request = build_request(
... "Standard PSScene Ortho Analytic",
... source=source,
... delivery={})
```
```python
source = catalog_source(
["PSScene"],
["ortho_analytic_4b"],
geometry={
"type": "Polygon",
"coordinates": [
[
[37.791595458984375, 14.84923123791421],
[37.90214538574219, 14.84923123791421],
[37.90214538574219, 14.945448293647944],
[37.791595458984375, 14.945448293647944],
[37.791595458984375, 14.84923123791421],
]
],
},
start_time=datetime(2021, 3, 1),
publishing_stages=["standard"],
time_range_type="acquired",
)
request = build_request("Standard PSScene Ortho Analytic", source=source, delivery={})
```
"""
if len(item_types) > 1:
raise ClientError(
Expand Down Expand Up @@ -297,24 +302,31 @@ def planetary_variable_source(
configured.
Examples:
```python
>>> source = planetary_variable_source(
... "soil_water_content",
... "SWC-AMSR2-C_V1.0_100",
... geometry={
... "type": "Polygon",
... "coordinates": [[[37.791595458984375, 14.84923123791421],
... [37.90214538574219, 14.84923123791421],
... [37.90214538574219, 14.945448293647944],
... [37.791595458984375, 14.945448293647944],
... [37.791595458984375, 14.84923123791421]]]
... },
... start_time=datetime(2021, 3, 1)
... )
>>> request = build_request(
... "Soil Water Content",
... source=source,
... delivery={})
pv_source = planetary_variables_source(
"soil_water_content",
"SWC-AMSR2-C_V1.0_100",
geometry={
"type": "Polygon",
"coordinates": [
[
[37.791595458984375, 14.84923123791421],
[37.90214538574219, 14.84923123791421],
[37.90214538574219, 14.945448293647944],
[37.791595458984375, 14.945448293647944],
[37.791595458984375, 14.84923123791421],
]
],
},
start_time=datetime(2021, 3, 1),
)
request = build_request(
"soil_water_subscription",
source=pv_source,
delivery={},
)
```
"""
# TODO: validation of variable types and ids.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_subscriptions_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests of the Planet Subscriptions API client."""

import csv
from datetime import datetime
from itertools import zip_longest
import json
Expand Down Expand Up @@ -288,7 +289,6 @@ async def test_get_results_csv():
async with Session() as session:
client = SubscriptionsClient(session, base_url=TEST_URL)
results = [res async for res in client.get_results_csv("42")]
import csv
rows = list(csv.reader(results))
assert rows == [['id', 'status'], ['1234-abcd', 'SUCCESS']]

Expand Down

0 comments on commit 33f6903

Please sign in to comment.