Skip to content

Commit 9bd7a3d

Browse files
authored
make call_sync internal API (#1083)
1 parent 9d16dd9 commit 9bd7a3d

File tree

7 files changed

+37
-37
lines changed

7 files changed

+37
-37
lines changed

planet/clients/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ def __init__(self, session: Session, base_url: Optional[str] = None):
9898
if self._base_url.endswith('/'):
9999
self._base_url = self._base_url[:-1]
100100

101-
def call_sync(self, f: Awaitable[T]) -> T:
101+
def _call_sync(self, f: Awaitable[T]) -> T:
102102
"""block on an async function call, using the call_sync method of the session"""
103-
return self._session.call_sync(f)
103+
return self._session._call_sync(f)
104104

105105
@staticmethod
106106
def _check_search_id(sid):

planet/clients/orders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ def __init__(self, session: Session, base_url: Optional[str] = None):
9999
if self._base_url.endswith('/'):
100100
self._base_url = self._base_url[:-1]
101101

102-
def call_sync(self, f: Awaitable[T]) -> T:
102+
def _call_sync(self, f: Awaitable[T]) -> T:
103103
"""block on an async function call, using the call_sync method of the session"""
104-
return self._session.call_sync(f)
104+
return self._session._call_sync(f)
105105

106106
@staticmethod
107107
def _check_order_id(oid):

planet/clients/subscriptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ def __init__(self,
6161
if self._base_url.endswith('/'):
6262
self._base_url = self._base_url[:-1]
6363

64-
def call_sync(self, f: Awaitable[T]) -> T:
64+
def _call_sync(self, f: Awaitable[T]) -> T:
6565
"""block on an async function call, using the call_sync method of the session"""
66-
return self._session.call_sync(f)
66+
return self._session._call_sync(f)
6767

6868
async def list_subscriptions(
6969
self,

planet/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def _start_background_loop(loop):
286286
daemon=True)
287287
self._loop_thread.start()
288288

289-
def call_sync(self, f: Awaitable[T]) -> T:
289+
def _call_sync(self, f: Awaitable[T]) -> T:
290290
return asyncio.run_coroutine_threadsafe(f, self._loop).result()
291291

292292
@classmethod

planet/sync/data.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def search(
8282

8383
try:
8484
while True:
85-
yield self._client.call_sync(results.__anext__())
85+
yield self._client._call_sync(results.__anext__())
8686
except StopAsyncIteration:
8787
pass
8888

@@ -125,7 +125,7 @@ def create_search(
125125
Raises:
126126
planet.exceptions.APIError: On API error.
127127
"""
128-
return self._client.call_sync(
128+
return self._client._call_sync(
129129
self._client.create_search(item_types,
130130
search_filter,
131131
name,
@@ -152,7 +152,7 @@ def update_search(self,
152152
Returns:
153153
Description of the saved search.
154154
"""
155-
return self._client.call_sync(
155+
return self._client._call_sync(
156156
self._client.update_search(search_id,
157157
item_types,
158158
search_filter,
@@ -184,7 +184,7 @@ def list_searches(self,
184184

185185
try:
186186
while True:
187-
yield self._client.call_sync(results.__anext__())
187+
yield self._client._call_sync(results.__anext__())
188188
except StopAsyncIteration:
189189
pass
190190

@@ -197,7 +197,7 @@ def delete_search(self, search_id: str):
197197
Raises:
198198
planet.exceptions.APIError: On API error.
199199
"""
200-
return self._client.call_sync(self._client.delete_search(search_id))
200+
return self._client._call_sync(self._client.delete_search(search_id))
201201

202202
def get_search(self, search_id: str) -> Dict:
203203
"""Get a saved search by id.
@@ -211,7 +211,7 @@ def get_search(self, search_id: str) -> Dict:
211211
Raises:
212212
planet.exceptions.APIError: On API error.
213213
"""
214-
return self._client.call_sync(self._client.get_search(search_id))
214+
return self._client._call_sync(self._client.get_search(search_id))
215215

216216
def run_search(self,
217217
search_id: str,
@@ -243,7 +243,7 @@ def run_search(self,
243243

244244
try:
245245
while True:
246-
yield self._client.call_sync(results.__anext__())
246+
yield self._client._call_sync(results.__anext__())
247247
except StopAsyncIteration:
248248
pass
249249

@@ -266,7 +266,7 @@ def get_stats(self,
266266
planet.exceptions.APIError: On API error.
267267
planet.exceptions.ClientError: If interval is not valid.
268268
"""
269-
return self._client.call_sync(
269+
return self._client._call_sync(
270270
self._client.get_stats(item_types, search_filter, interval))
271271

272272
def list_item_assets(self, item_type_id: str,
@@ -288,7 +288,7 @@ def list_item_assets(self, item_type_id: str,
288288
Raises:
289289
planet.exceptions.APIError: On API error.
290290
"""
291-
return self._client.call_sync(
291+
return self._client._call_sync(
292292
self._client.list_item_assets(item_type_id, item_id))
293293

294294
def get_asset(self, item_type_id: str, item_id: str,
@@ -308,7 +308,7 @@ def get_asset(self, item_type_id: str, item_id: str,
308308
planet.exceptions.ClientError: If asset type identifier is not
309309
valid.
310310
"""
311-
return self._client.call_sync(
311+
return self._client._call_sync(
312312
self._client.get_asset(item_type_id, item_id, asset_type_id))
313313

314314
def activate_asset(self, asset: Dict[str, Any]):
@@ -322,7 +322,7 @@ def activate_asset(self, asset: Dict[str, Any]):
322322
planet.exceptions.ClientError: If asset description is not
323323
valid.
324324
"""
325-
return self._client.call_sync(self._client.activate_asset(asset))
325+
return self._client._call_sync(self._client.activate_asset(asset))
326326

327327
def wait_asset(
328328
self,
@@ -352,7 +352,7 @@ def wait_asset(
352352
not available or if the maximum number of attempts is reached
353353
before the asset is active.
354354
"""
355-
return self._client.call_sync(
355+
return self._client._call_sync(
356356
self._client.wait_asset(asset, delay, max_attempts, callback))
357357

358358
def download_asset(self,
@@ -385,7 +385,7 @@ def download_asset(self,
385385
planet.exceptions.ClientError: If asset is not active or asset
386386
description is not valid.
387387
"""
388-
return self._client.call_sync(
388+
return self._client._call_sync(
389389
self._client.download_asset(asset,
390390
filename,
391391
directory,

planet/sync/orders.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def main():
6363
Raises:
6464
planet.exceptions.APIError: On API error.
6565
"""
66-
return self._client.call_sync(self._client.create_order(request))
66+
return self._client._call_sync(self._client.create_order(request))
6767

6868
def get_order(self, order_id: str) -> Dict:
6969
"""Get order details by Order ID.
@@ -78,7 +78,7 @@ def get_order(self, order_id: str) -> Dict:
7878
planet.exceptions.ClientError: If order_id is not a valid UUID.
7979
planet.exceptions.APIError: On API error.
8080
"""
81-
return self._client.call_sync(self._client.get_order(order_id))
81+
return self._client._call_sync(self._client.get_order(order_id))
8282

8383
def cancel_order(self, order_id: str) -> Dict[str, Any]:
8484
"""Cancel a queued order.
@@ -93,7 +93,7 @@ def cancel_order(self, order_id: str) -> Dict[str, Any]:
9393
planet.exceptions.ClientError: If order_id is not a valid UUID.
9494
planet.exceptions.APIError: On API error.
9595
"""
96-
return self._client.call_sync(self._client.cancel_order(order_id))
96+
return self._client._call_sync(self._client.cancel_order(order_id))
9797

9898
def cancel_orders(self,
9999
order_ids: Optional[List[str]] = None) -> Dict[str, Any]:
@@ -111,7 +111,7 @@ def cancel_orders(self,
111111
valid UUID.
112112
planet.exceptions.APIError: On API error.
113113
"""
114-
return self._client.call_sync(self._client.cancel_orders(order_ids))
114+
return self._client._call_sync(self._client.cancel_orders(order_ids))
115115

116116
def aggregated_order_stats(self) -> Dict[str, Any]:
117117
"""Get aggregated counts of active orders.
@@ -122,7 +122,7 @@ def aggregated_order_stats(self) -> Dict[str, Any]:
122122
Raises:
123123
planet.exceptions.APIError: On API error.
124124
"""
125-
return self._client.call_sync(self._client.aggregated_order_stats())
125+
return self._client._call_sync(self._client.aggregated_order_stats())
126126

127127
def download_asset(self,
128128
location: str,
@@ -146,7 +146,7 @@ def download_asset(self,
146146
Raises:
147147
planet.exceptions.APIError: On API error.
148148
"""
149-
return self._client.call_sync(
149+
return self._client._call_sync(
150150
self._client.download_asset(location,
151151
filename,
152152
directory,
@@ -175,7 +175,7 @@ def download_order(self,
175175
planet.exceptions.ClientError: If the order is not in a final
176176
state.
177177
"""
178-
return self._client.call_sync(
178+
return self._client._call_sync(
179179
self._client.download_order(order_id,
180180
directory,
181181
overwrite,
@@ -249,7 +249,7 @@ def wait(self,
249249
if the maximum number of attempts is reached before the
250250
specified state or a final state is reached.
251251
"""
252-
return self._client.call_sync(
252+
return self._client._call_sync(
253253
self._client.wait(order_id, state, delay, max_attempts, callback))
254254

255255
def list_orders(self,
@@ -319,6 +319,6 @@ def list_orders(self,
319319

320320
try:
321321
while True:
322-
yield self._client.call_sync(results.__anext__())
322+
yield self._client._call_sync(results.__anext__())
323323
except StopAsyncIteration:
324324
pass

planet/sync/subscriptions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def list_subscriptions(self,
113113

114114
try:
115115
while True:
116-
yield self._client.call_sync(results.__anext__())
116+
yield self._client._call_sync(results.__anext__())
117117
except StopAsyncIteration:
118118
pass
119119

@@ -130,7 +130,7 @@ def create_subscription(self, request: Dict) -> Dict:
130130
APIError: on an API server error.
131131
ClientError: on a client error.
132132
"""
133-
return self._client.call_sync(
133+
return self._client._call_sync(
134134
self._client.create_subscription(request))
135135

136136
def cancel_subscription(self, subscription_id: str) -> None:
@@ -146,7 +146,7 @@ def cancel_subscription(self, subscription_id: str) -> None:
146146
APIError: on an API server error.
147147
ClientError: on a client error.
148148
"""
149-
return self._client.call_sync(
149+
return self._client._call_sync(
150150
self._client.cancel_subscription(subscription_id))
151151

152152
def update_subscription(self, subscription_id: str, request: dict) -> dict:
@@ -164,7 +164,7 @@ def update_subscription(self, subscription_id: str, request: dict) -> dict:
164164
APIError: on an API server error.
165165
ClientError: on a client error.
166166
"""
167-
return self._client.call_sync(
167+
return self._client._call_sync(
168168
self._client.update_subscription(subscription_id, request))
169169

170170
def patch_subscription(self, subscription_id: str,
@@ -183,7 +183,7 @@ def patch_subscription(self, subscription_id: str,
183183
APIError: on an API server error.
184184
ClientError: on a client error.
185185
"""
186-
return self._client.call_sync(
186+
return self._client._call_sync(
187187
self._client.patch_subscription(subscription_id, request))
188188

189189
def get_subscription(self, subscription_id: str) -> Dict[str, Any]:
@@ -199,7 +199,7 @@ def get_subscription(self, subscription_id: str) -> Dict[str, Any]:
199199
APIError: on an API server error.
200200
ClientError: on a client error.
201201
"""
202-
return self._client.call_sync(
202+
return self._client._call_sync(
203203
self._client.get_subscription(subscription_id))
204204

205205
def get_results(
@@ -238,7 +238,7 @@ def get_results(
238238

239239
try:
240240
while True:
241-
yield self._client.call_sync(results.__anext__())
241+
yield self._client._call_sync(results.__anext__())
242242
except StopAsyncIteration:
243243
pass
244244

@@ -274,6 +274,6 @@ def get_results_csv(
274274
# https://github.com/hynek/stamina.
275275
try:
276276
while True:
277-
yield self._client.call_sync(results.__anext__())
277+
yield self._client._call_sync(results.__anext__())
278278
except StopAsyncIteration:
279279
pass

0 commit comments

Comments
 (0)