|
3 | 3 | from hyperbrowser.models.consts import POLLING_ATTEMPTS |
4 | 4 | from ...polling import ( |
5 | 5 | build_fetch_operation_name, |
6 | | - build_operation_name, |
7 | 6 | collect_paginated_results_async, |
8 | | - ensure_started_job_id, |
9 | 7 | poll_until_terminal_status_async, |
10 | 8 | retry_operation_async, |
11 | 9 | wait_for_job_result_async, |
|
20 | 18 | serialize_model_dump_to_dict, |
21 | 19 | ) |
22 | 20 | from ..response_utils import parse_response_model |
| 21 | +from ..start_job_utils import build_started_job_context |
23 | 22 | from ....models.scrape import ( |
24 | 23 | BatchScrapeJobResponse, |
25 | 24 | BatchScrapeJobStatusResponse, |
@@ -91,11 +90,11 @@ async def start_and_wait( |
91 | 90 | max_status_failures: int = POLLING_ATTEMPTS, |
92 | 91 | ) -> BatchScrapeJobResponse: |
93 | 92 | job_start_resp = await self.start(params) |
94 | | - job_id = ensure_started_job_id( |
95 | | - job_start_resp.job_id, |
96 | | - error_message="Failed to start batch scrape job", |
| 93 | + job_id, operation_name = build_started_job_context( |
| 94 | + started_job_id=job_start_resp.job_id, |
| 95 | + start_error_message="Failed to start batch scrape job", |
| 96 | + operation_name_prefix="batch scrape job ", |
97 | 97 | ) |
98 | | - operation_name = build_operation_name("batch scrape job ", job_id) |
99 | 98 |
|
100 | 99 | job_status = await poll_until_terminal_status_async( |
101 | 100 | operation_name=operation_name, |
@@ -196,11 +195,11 @@ async def start_and_wait( |
196 | 195 | max_status_failures: int = POLLING_ATTEMPTS, |
197 | 196 | ) -> ScrapeJobResponse: |
198 | 197 | job_start_resp = await self.start(params) |
199 | | - job_id = ensure_started_job_id( |
200 | | - job_start_resp.job_id, |
201 | | - error_message="Failed to start scrape job", |
| 198 | + job_id, operation_name = build_started_job_context( |
| 199 | + started_job_id=job_start_resp.job_id, |
| 200 | + start_error_message="Failed to start scrape job", |
| 201 | + operation_name_prefix="scrape job ", |
202 | 202 | ) |
203 | | - operation_name = build_operation_name("scrape job ", job_id) |
204 | 203 |
|
205 | 204 | return await wait_for_job_result_async( |
206 | 205 | operation_name=operation_name, |
|
0 commit comments