You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43Lines changed: 43 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -328,6 +328,49 @@ operation.wait_sync()
328
328
print(f"New bucket ID: {operation.resource_id}")
329
329
```
330
330
331
+
##### Progress tracker
332
+
333
+
Some operations expose a progress tracker with ETA, work completion, and step
334
+
details. You can access it via [`Operation.progress_tracker`](https://nebius.github.io/pysdk/nebius.aio.operation.Operation.html#progress_tracker).
335
+
For operations that do not provide progress details (or v1alpha1 operations),
336
+
this returns `None`.
337
+
338
+
Example of polling with a single-line progress display:
339
+
340
+
```python
341
+
from asyncio import sleep
342
+
from datetime import datetime
343
+
from nebius.base.protos.well_known import local_timezone
344
+
345
+
whilenot operation.done():
346
+
await operation.update()
347
+
tracker = operation.progress_tracker()
348
+
parts = [f"waiting for operation {operation.id} to complete:"]
349
+
350
+
if tracker:
351
+
work = tracker.work_fraction()
352
+
if work isnotNone:
353
+
parts.append(f"{work:.0%}")
354
+
355
+
desc = tracker.description()
356
+
if desc:
357
+
parts.append(desc)
358
+
359
+
started = tracker.started_at()
360
+
if started isnotNone:
361
+
elapsed = datetime.now(local_timezone) - started
362
+
parts.append(f"{elapsed}")
363
+
364
+
eta = tracker.estimated_finished_at()
365
+
if eta isnotNone:
366
+
parts.append(f"eta {eta}")
367
+
368
+
print("".join(parts), end="\r", flush=True)
369
+
await sleep(1)
370
+
371
+
print()
372
+
```
373
+
331
374
##### Operations service
332
375
333
376
If you need to get an operation or list operations, you will need an [`OperationServiceClient`](https://nebius.github.io/pysdk/nebius.api.nebius.common.v1.OperationServiceClient.html).
0 commit comments