File tree Expand file tree Collapse file tree
hyperbrowser/client/managers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44from ...polling import (
5- build_fetch_operation_name ,
65 poll_until_terminal_status_async ,
76)
87from ..job_fetch_utils import (
98 collect_paginated_results_with_defaults_async ,
10- retry_operation_with_defaults_async ,
9+ fetch_job_result_with_defaults_async ,
1110)
1211from ..page_params_utils import build_page_batch_params
1312from ..job_pagination_utils import (
@@ -99,9 +98,9 @@ async def start_and_wait(
9998 )
10099
101100 if not return_all_pages :
102- return await retry_operation_with_defaults_async (
103- operation_name = build_fetch_operation_name ( operation_name ) ,
104- operation = lambda : self .get (job_id ),
101+ return await fetch_job_result_with_defaults_async (
102+ operation_name = operation_name ,
103+ fetch_result = lambda : self .get (job_id ),
105104 )
106105
107106 job_response = initialize_job_paginated_response (
Original file line number Diff line number Diff line change 22
33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44from ...polling import (
5- build_fetch_operation_name ,
65 poll_until_terminal_status_async ,
76)
87from ..job_fetch_utils import (
98 collect_paginated_results_with_defaults_async ,
10- retry_operation_with_defaults_async ,
9+ fetch_job_result_with_defaults_async ,
1110)
1211from ..page_params_utils import build_page_batch_params
1312from ..job_pagination_utils import (
@@ -109,9 +108,9 @@ async def start_and_wait(
109108 )
110109
111110 if not return_all_pages :
112- return await retry_operation_with_defaults_async (
113- operation_name = build_fetch_operation_name ( operation_name ) ,
114- operation = lambda : self .get (job_id ),
111+ return await fetch_job_result_with_defaults_async (
112+ operation_name = operation_name ,
113+ fetch_result = lambda : self .get (job_id ),
115114 )
116115
117116 job_response = initialize_job_paginated_response (
Original file line number Diff line number Diff line change 1818)
1919from ...job_fetch_utils import (
2020 collect_paginated_results_with_defaults_async ,
21- retry_operation_with_defaults_async ,
21+ fetch_job_result_with_defaults_async ,
2222)
2323from ....polling import (
24- build_fetch_operation_name ,
2524 poll_until_terminal_status_async ,
2625)
2726from ...response_utils import parse_response_model
@@ -96,9 +95,9 @@ async def start_and_wait(
9695 )
9796
9897 if not return_all_pages :
99- return await retry_operation_with_defaults_async (
100- operation_name = build_fetch_operation_name ( operation_name ) ,
101- operation = lambda : self .get (job_id ),
98+ return await fetch_job_result_with_defaults_async (
99+ operation_name = operation_name ,
100+ fetch_result = lambda : self .get (job_id ),
102101 )
103102
104103 job_response = initialize_paginated_job_response (
Original file line number Diff line number Diff line change 1818)
1919from ...job_fetch_utils import (
2020 collect_paginated_results_with_defaults_async ,
21- retry_operation_with_defaults_async ,
21+ fetch_job_result_with_defaults_async ,
2222)
2323from ....polling import (
24- build_fetch_operation_name ,
2524 poll_until_terminal_status_async ,
2625)
2726from ...response_utils import parse_response_model
@@ -94,9 +93,9 @@ async def start_and_wait(
9493 )
9594
9695 if not return_all_pages :
97- return await retry_operation_with_defaults_async (
98- operation_name = build_fetch_operation_name ( operation_name ) ,
99- operation = lambda : self .get (job_id ),
96+ return await fetch_job_result_with_defaults_async (
97+ operation_name = operation_name ,
98+ fetch_result = lambda : self .get (job_id ),
10099 )
101100
102101 job_response = initialize_paginated_job_response (
Original file line number Diff line number Diff line change 33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44
55from ..polling import (
6+ build_fetch_operation_name ,
67 collect_paginated_results ,
78 collect_paginated_results_async ,
89 retry_operation ,
@@ -39,6 +40,28 @@ async def retry_operation_with_defaults_async(
3940 )
4041
4142
43+ def fetch_job_result_with_defaults (
44+ * ,
45+ operation_name : str ,
46+ fetch_result : Callable [[], T ],
47+ ) -> T :
48+ return retry_operation_with_defaults (
49+ operation_name = build_fetch_operation_name (operation_name ),
50+ operation = fetch_result ,
51+ )
52+
53+
54+ async def fetch_job_result_with_defaults_async (
55+ * ,
56+ operation_name : str ,
57+ fetch_result : Callable [[], Awaitable [T ]],
58+ ) -> T :
59+ return await retry_operation_with_defaults_async (
60+ operation_name = build_fetch_operation_name (operation_name ),
61+ operation = fetch_result ,
62+ )
63+
64+
4265def collect_paginated_results_with_defaults (
4366 * ,
4467 operation_name : str ,
Original file line number Diff line number Diff line change 22
33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44from ...polling import (
5- build_fetch_operation_name ,
65 poll_until_terminal_status ,
76)
87from ..job_fetch_utils import (
98 collect_paginated_results_with_defaults ,
10- retry_operation_with_defaults ,
9+ fetch_job_result_with_defaults ,
1110)
1211from ..page_params_utils import build_page_batch_params
1312from ..job_pagination_utils import (
@@ -99,9 +98,9 @@ def start_and_wait(
9998 )
10099
101100 if not return_all_pages :
102- return retry_operation_with_defaults (
103- operation_name = build_fetch_operation_name ( operation_name ) ,
104- operation = lambda : self .get (job_id ),
101+ return fetch_job_result_with_defaults (
102+ operation_name = operation_name ,
103+ fetch_result = lambda : self .get (job_id ),
105104 )
106105
107106 job_response = initialize_job_paginated_response (
Original file line number Diff line number Diff line change 22
33from hyperbrowser .models .consts import POLLING_ATTEMPTS
44from ...polling import (
5- build_fetch_operation_name ,
65 poll_until_terminal_status ,
76)
87from ..job_fetch_utils import (
98 collect_paginated_results_with_defaults ,
10- retry_operation_with_defaults ,
9+ fetch_job_result_with_defaults ,
1110)
1211from ..page_params_utils import build_page_batch_params
1312from ..job_pagination_utils import (
@@ -107,9 +106,9 @@ def start_and_wait(
107106 )
108107
109108 if not return_all_pages :
110- return retry_operation_with_defaults (
111- operation_name = build_fetch_operation_name ( operation_name ) ,
112- operation = lambda : self .get (job_id ),
109+ return fetch_job_result_with_defaults (
110+ operation_name = operation_name ,
111+ fetch_result = lambda : self .get (job_id ),
113112 )
114113
115114 job_response = initialize_job_paginated_response (
Original file line number Diff line number Diff line change 1818)
1919from ...job_fetch_utils import (
2020 collect_paginated_results_with_defaults ,
21- retry_operation_with_defaults ,
21+ fetch_job_result_with_defaults ,
2222)
2323from ....polling import (
24- build_fetch_operation_name ,
2524 poll_until_terminal_status ,
2625)
2726from ...response_utils import parse_response_model
@@ -94,9 +93,9 @@ def start_and_wait(
9493 )
9594
9695 if not return_all_pages :
97- return retry_operation_with_defaults (
98- operation_name = build_fetch_operation_name ( operation_name ) ,
99- operation = lambda : self .get (job_id ),
96+ return fetch_job_result_with_defaults (
97+ operation_name = operation_name ,
98+ fetch_result = lambda : self .get (job_id ),
10099 )
101100
102101 job_response = initialize_paginated_job_response (
Original file line number Diff line number Diff line change 1818)
1919from ...job_fetch_utils import (
2020 collect_paginated_results_with_defaults ,
21- retry_operation_with_defaults ,
21+ fetch_job_result_with_defaults ,
2222)
2323from ....polling import (
24- build_fetch_operation_name ,
2524 poll_until_terminal_status ,
2625)
2726from ...response_utils import parse_response_model
@@ -94,9 +93,9 @@ def start_and_wait(
9493 )
9594
9695 if not return_all_pages :
97- return retry_operation_with_defaults (
98- operation_name = build_fetch_operation_name ( operation_name ) ,
99- operation = lambda : self .get (job_id ),
96+ return fetch_job_result_with_defaults (
97+ operation_name = operation_name ,
98+ fetch_result = lambda : self .get (job_id ),
10099 )
101100
102101 job_response = initialize_paginated_job_response (
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ def test_retry_and_paginated_fetch_primitives_are_centralized():
1919 or "retry_operation_async(" in module_text
2020 or "collect_paginated_results(" in module_text
2121 or "collect_paginated_results_async(" in module_text
22+ or "build_fetch_operation_name(" in module_text
2223 ):
2324 violating_modules .append (module_path .as_posix ())
2425
You can’t perform that action at this time.
0 commit comments