Skip to content

Commit 15191e0

Browse files
authored
Revert "Add client method to Session class"
1 parent 1f74347 commit 15191e0

File tree

8 files changed

+13
-79
lines changed

8 files changed

+13
-79
lines changed

CHANGES.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
2.0b2 (TBD)
2-
3-
Added:
4-
- The Session class can now construct clients by name with its client method
5-
(#858).
6-
71
2.0.0-beta.1 (2022-12-07)
82

93
Changed:

docs/get-started/upgrading.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The best way of doing this is wrapping any code that invokes a client class in a
2424

2525
```python
2626
async with Session() as session:
27-
client = session.client('orders')
27+
client = OrdersClient(session)
2828
result = await client.create_order(order)
2929
# Process result
3030
```
@@ -40,12 +40,12 @@ In V2, all `*Client` methods (for example, `DataClient().search`, `OrderClient()
4040
```python
4141
import asyncio
4242
from datetime import datetime
43-
from planet import Session
43+
from planet import Session, DataClient
4444
from planet import data_filter as filters
4545

4646
async def do_search():
4747
async with Session() as session:
48-
client = session.client('data')
48+
client = DataClient(session)
4949
date_filter = filters.date_range_filter('acquired', gte=datetime.fromisoformat("2022-11-18"), lte=datetime.fromisoformat("2022-11-21"))
5050
cloud_filter = filters.range_filter('cloud_cover', lte=0.1)
5151
download_filter = filters.permission_filter()
@@ -74,11 +74,11 @@ Is now
7474

7575
```python
7676
async with Session() as session:
77-
items = [i async for i in session.client('data').search(["PSScene"], all_filters)]
77+
items = [i async for i in planet.DataClient(session).search(["PSScene"], all_filters)]
7878
```
7979

8080
## Orders API
8181

82-
The Orders API capabilities in V1 were quite primitive, but those that did exist have been retained in much the same form; `ClientV1().create_order` becomes `OrdersClient(session).create_order`. (As with the `DataClient`, you must also use `async` and `Session` with `OrdersClient`.)
82+
The Orders API capabilities in V1 were quite primitive, but those that did exist have been retained in much the same form; `ClientV1().create_order` becomes `OrderClient(session).create_order`. (As with the `DataClient`, you must also use `async` and `Session` with `OrderClient`.)
8383

8484
Additionally, there is now also an order builder in `planet.order_request`, similar to the preexisting search filter builder. For more details on this, refer to the [Creating an Order](../../python/sdk-guide/#creating-an-order).

docs/python/sdk-guide.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ from planet import OrdersClient
116116

117117
async def main():
118118
async with Session() as sess:
119-
client = sess.client('orders')
119+
client = OrdersClient(sess)
120120
# perform operations here
121121

122122
asyncio.run(main())
@@ -198,7 +198,7 @@ the context of a `Session` with the `OrdersClient`:
198198
```python
199199
async def main():
200200
async with Session() as sess:
201-
cl = sess.client('orders')
201+
cl = OrdersClient(sess)
202202
order = await cl.create_order(request)
203203

204204
asyncio.run(main())
@@ -222,7 +222,7 @@ from planet import reporting
222222

223223
async def create_wait_and_download():
224224
async with Session() as sess:
225-
cl = sess.client('orders')
225+
cl = OrdersClient(sess)
226226
with reporting.StateBar(state='creating') as bar:
227227
# create order
228228
order = await cl.create_order(request)
@@ -272,7 +272,7 @@ from planet import collect, OrdersClient, Session
272272

273273
async def main():
274274
async with Session() as sess:
275-
client = sess.client('orders')
275+
client = OrdersClient(sess)
276276
orders_list = collect(client.list_orders())
277277

278278
asyncio.run(main())
@@ -297,7 +297,7 @@ from planet import DataClient
297297

298298
async def main():
299299
async with Session() as sess:
300-
client = sess.client('data')
300+
client = DataClient(sess)
301301
# perform operations here
302302

303303
asyncio.run(main())
@@ -344,7 +344,7 @@ the context of a `Session` with the `DataClient`:
344344
```python
345345
async def main():
346346
async with Session() as sess:
347-
cl = sess.client('data')
347+
cl = DataClient(sess)
348348
items = [i async for i in cl.search(['PSScene'], sfilter)]
349349

350350
asyncio.run(main())
@@ -364,7 +364,7 @@ print command to report wait status. `download_asset` has reporting built in.
364364
```python
365365
async def download_and_validate():
366366
async with Session() as sess:
367-
cl = sess.client('data')
367+
cl = DataClient(sess)
368368

369369
# get asset description
370370
item_type_id = 'PSScene'

planet/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616
from . import order_request, reporting
1717
from .__version__ import __version__ # NOQA
1818
from .auth import Auth
19-
from .clients import DataClient, OrdersClient, SubscriptionsClient # NOQA
19+
from .clients import DataClient, OrdersClient # NOQA
2020
from .io import collect
2121

2222
__all__ = [
2323
'Auth',
2424
'collect',
2525
'DataClient'
2626
'OrdersClient',
27-
'SubscriptionsClient',
2827
'order_request',
2928
'reporting',
3029
'Session',

planet/clients/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,10 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
1615
from .data import DataClient
1716
from .orders import OrdersClient
18-
from .subscriptions import SubscriptionsClient
1917

2018
__all__ = [
2119
'DataClient',
2220
'OrdersClient',
23-
'SubscriptionsClient',
2421
]
25-
26-
# Organize client classes by their module name to allow concise lookup.
27-
_client_directory = {
28-
'data': DataClient,
29-
'orders': OrdersClient,
30-
'subscriptions': SubscriptionsClient
31-
}

planet/http.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
import random
2323
import time
2424
from typing import AsyncGenerator, Optional
25-
2625
import httpx
27-
from typing_extensions import Literal
2826

2927
from .auth import Auth, AuthType
3028
from . import exceptions, models
@@ -415,29 +413,6 @@ async def stream(
415413
finally:
416414
await response.aclose()
417415

418-
def client(self,
419-
name: Literal['data', 'orders', 'subscriptions'],
420-
base_url: Optional[str] = None) -> object:
421-
"""Get a client by its module name.
422-
423-
Parameters:
424-
name: one of 'data', 'orders', or 'subscriptions'.
425-
426-
Returns:
427-
A client instance.
428-
429-
Raises:
430-
ClientError when no such client can be had.
431-
432-
"""
433-
# To avoid circular dependency.
434-
from planet.clients import _client_directory
435-
436-
try:
437-
return _client_directory[name](self, base_url=base_url)
438-
except KeyError:
439-
raise exceptions.ClientError("No such client.")
440-
441416

442417
class AuthSession(BaseSession):
443418
"""Synchronous connection to the Planet Auth service."""

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
'jsonschema',
3131
'pyjwt>=2.1',
3232
'tqdm>=4.56',
33-
'typing-extensions',
3433
]
3534

3635
test_requires = ['pytest', 'pytest-asyncio==0.16', 'pytest-cov', 'respx==0.19']

tests/unit/test_session.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)