@@ -1564,7 +1564,10 @@ def create(
15641564 )
15651565 dataset_resource_name = self ._wait_for_operation (
15661566 operation = create_prompt_dataset_operation ,
1567- timeout = config .timeout if config else 90 ,
1567+ timeout = config .timeout if config and config .timeout else 90 ,
1568+ max_wait_time = (
1569+ config .max_wait_time if config and config .max_wait_time else 60
1570+ ),
15681571 )
15691572 dataset_id = dataset_resource_name .split ("/" )[- 1 ]
15701573
@@ -1636,7 +1639,10 @@ def create_version(
16361639 )
16371640 dataset_resource_name = self ._wait_for_operation (
16381641 operation = create_prompt_dataset_operation ,
1639- timeout = config .timeout if config else 90 ,
1642+ timeout = config .timeout if config and config .timeout else 90 ,
1643+ max_wait_time = (
1644+ config .max_wait_time if config and config .max_wait_time else 60
1645+ ),
16401646 )
16411647 dataset_id = dataset_resource_name .split ("/" )[- 1 ]
16421648
@@ -1660,7 +1666,10 @@ def create_version(
16601666 )
16611667 dataset_version_resource_name = self ._wait_for_operation (
16621668 operation = create_dataset_version_operation ,
1663- timeout = config .timeout if config else 90 ,
1669+ timeout = config .timeout if config and config .timeout else 90 ,
1670+ max_wait_time = (
1671+ config .max_wait_time if config and config .max_wait_time else 60
1672+ ),
16641673 )
16651674
16661675 # Step 4: Get the dataset version resource and return it with the prompt
@@ -1679,12 +1688,14 @@ def _wait_for_operation(
16791688 self ,
16801689 operation : types .DatasetOperation ,
16811690 timeout : int ,
1691+ max_wait_time : int = 60 ,
16821692 ) -> str :
16831693 """Waits for a dataset operation to complete.
16841694
16851695 Args:
16861696 operation: The dataset operation to wait for.
16871697 timeout: The maximum time to wait for the operation to complete.
1698+ max_wait_time: The maximum interval between polling requests in seconds.
16881699
16891700 Returns:
16901701 The name of the Dataset resource from the operation result.
@@ -1706,7 +1717,6 @@ def _wait_for_operation(
17061717 start_time = time .time ()
17071718 sleep_duration = 5
17081719 wait_multiplier = 2
1709- max_wait_time = 60
17101720 previous_time = time .time ()
17111721
17121722 while not done :
@@ -1923,6 +1933,7 @@ def _wait_for_project_operation(
19231933 self ,
19241934 operation : genai_types .ProjectOperation ,
19251935 timeout : int ,
1936+ max_wait_time : int = 60 ,
19261937 ) -> None :
19271938 """Waits for a dataset deletion operation to complete.
19281939
@@ -1931,6 +1942,7 @@ def _wait_for_project_operation(
19311942 Args:
19321943 operation: The project operation to wait for.
19331944 timeout: The maximum time to wait for the operation to complete.
1945+ max_wait_time: The maximum interval between polling requests in seconds.
19341946 Raises:
19351947 TimeoutError: If the operation does not complete within the timeout.
19361948 ValueError: If the operation fails.
@@ -1940,7 +1952,6 @@ def _wait_for_project_operation(
19401952 start_time = time .time ()
19411953 sleep_duration = 5
19421954 wait_multiplier = 2
1943- max_wait_time = 60
19441955 previous_time = time .time ()
19451956 while not done :
19461957 if (time .time () - start_time ) > timeout :
@@ -1985,7 +1996,11 @@ def delete(
19851996 config = config ,
19861997 )
19871998 self ._wait_for_project_operation (
1988- operation = delete_prompt_operation , timeout = config .timeout if config else 90
1999+ operation = delete_prompt_operation ,
2000+ timeout = config .timeout if config and config .timeout else 90 ,
2001+ max_wait_time = (
2002+ config .max_wait_time if config and config .max_wait_time else 60
2003+ ),
19892004 )
19902005 logger .info (f"Deleted prompt with id: { prompt_id } " )
19912006
@@ -2013,7 +2028,11 @@ def delete_version(
20132028 )
20142029
20152030 self ._wait_for_project_operation (
2016- operation = delete_version_operation , timeout = config .timeout if config else 90
2031+ operation = delete_version_operation ,
2032+ timeout = config .timeout if config and config .timeout else 90 ,
2033+ max_wait_time = (
2034+ config .max_wait_time if config and config .max_wait_time else 60
2035+ ),
20172036 )
20182037 logger .info (
20192038 f"Deleted prompt version { version_id } from prompt with id: { prompt_id } "
@@ -2043,7 +2062,10 @@ def restore_version(
20432062 )
20442063 self ._wait_for_project_operation (
20452064 operation = restore_prompt_operation ,
2046- timeout = 90 ,
2065+ timeout = config .timeout if config and config .timeout else 90 ,
2066+ max_wait_time = (
2067+ config .max_wait_time if config and config .max_wait_time else 60
2068+ ),
20472069 )
20482070 dataset_version_resource = self ._get_dataset_version_resource (
20492071 dataset_id = prompt_id ,
@@ -2400,7 +2422,10 @@ def update(
24002422 )
24012423 dataset_version_resource_name = self ._wait_for_operation (
24022424 operation = create_dataset_version_operation ,
2403- timeout = config .timeout if config else 90 ,
2425+ timeout = config .timeout if config and config .timeout else 90 ,
2426+ max_wait_time = (
2427+ config .max_wait_time if config and config .max_wait_time else 60
2428+ ),
24042429 )
24052430 dataset_version_id = dataset_version_resource_name .split ("/" )[- 1 ]
24062431
@@ -3558,7 +3583,10 @@ async def create(
35583583 )
35593584 dataset_resource_name = await self ._wait_for_operation (
35603585 operation = create_prompt_dataset_operation ,
3561- timeout = config .timeout if config else 90 ,
3586+ timeout = config .timeout if config and config .timeout else 90 ,
3587+ max_wait_time = (
3588+ config .max_wait_time if config and config .max_wait_time else 60
3589+ ),
35623590 )
35633591 dataset_id = dataset_resource_name .split ("/" )[- 1 ]
35643592
@@ -3629,7 +3657,10 @@ async def create_version(
36293657 )
36303658 dataset_resource_name = await self ._wait_for_operation (
36313659 operation = create_prompt_dataset_operation ,
3632- timeout = config .timeout if config else 90 ,
3660+ timeout = config .timeout if config and config .timeout else 90 ,
3661+ max_wait_time = (
3662+ config .max_wait_time if config and config .max_wait_time else 60
3663+ ),
36333664 )
36343665 dataset_id = dataset_resource_name .split ("/" )[- 1 ]
36353666
@@ -3653,7 +3684,10 @@ async def create_version(
36533684 )
36543685 dataset_version_resource_name = await self ._wait_for_operation (
36553686 operation = create_dataset_version_operation ,
3656- timeout = config .timeout if config else 90 ,
3687+ timeout = config .timeout if config and config .timeout else 90 ,
3688+ max_wait_time = (
3689+ config .max_wait_time if config and config .max_wait_time else 60
3690+ ),
36573691 )
36583692
36593693 # Step 4: Get the dataset version resource and return it with the prompt
@@ -3740,7 +3774,10 @@ async def update(
37403774 )
37413775 dataset_version_resource_name = await self ._wait_for_operation (
37423776 operation = create_dataset_version_operation ,
3743- timeout = config .timeout if config else 90 ,
3777+ timeout = config .timeout if config and config .timeout else 90 ,
3778+ max_wait_time = (
3779+ config .max_wait_time if config and config .max_wait_time else 60
3780+ ),
37443781 )
37453782 dataset_version_id = dataset_version_resource_name .split ("/" )[- 1 ]
37463783
@@ -3760,12 +3797,14 @@ async def _wait_for_operation(
37603797 self ,
37613798 operation : types .DatasetOperation ,
37623799 timeout : int ,
3800+ max_wait_time : int = 60 ,
37633801 ) -> str :
37643802 """Waits for a dataset operation to complete.
37653803
37663804 Args:
37673805 operation: The dataset operation to wait for.
37683806 timeout: The maximum time to wait for the operation to complete.
3807+ max_wait_time: The maximum interval between polling requests in seconds.
37693808
37703809 Returns:
37713810 The name of the Dataset resource from the operation result.
@@ -3787,7 +3826,6 @@ async def _wait_for_operation(
37873826 start_time = time .time ()
37883827 sleep_duration = 5
37893828 wait_multiplier = 2
3790- max_wait_time = 60
37913829 previous_time = time .time ()
37923830
37933831 while not done :
@@ -3885,6 +3923,7 @@ async def _wait_for_project_operation(
38853923 self ,
38863924 operation : genai_types .ProjectOperation ,
38873925 timeout : int ,
3926+ max_wait_time : int = 60 ,
38883927 ) -> None :
38893928 """Waits for a dataset deletion operation to complete.
38903929
@@ -3893,6 +3932,7 @@ async def _wait_for_project_operation(
38933932 Args:
38943933 operation: The project operation to wait for.
38953934 timeout: The maximum time to wait for the operation to complete.
3935+ max_wait_time: The maximum interval between polling requests in seconds.
38963936 Raises:
38973937 TimeoutError: If the operation does not complete within the timeout.
38983938 ValueError: If the operation fails.
@@ -3902,7 +3942,6 @@ async def _wait_for_project_operation(
39023942 start_time = time .time ()
39033943 sleep_duration = 5
39043944 wait_multiplier = 2
3905- max_wait_time = 60
39063945 previous_time = time .time ()
39073946 while not done :
39083947 if (time .time () - start_time ) > timeout :
@@ -3947,7 +3986,11 @@ async def delete(
39473986 config = config ,
39483987 )
39493988 await self ._wait_for_project_operation (
3950- operation = delete_prompt_operation , timeout = config .timeout if config else 90
3989+ operation = delete_prompt_operation ,
3990+ timeout = config .timeout if config and config .timeout else 90 ,
3991+ max_wait_time = (
3992+ config .max_wait_time if config and config .max_wait_time else 60
3993+ ),
39513994 )
39523995 logger .info (f"Deleted prompt with id: { prompt_id } " )
39533996
@@ -3975,7 +4018,11 @@ async def delete_version(
39754018 )
39764019
39774020 await self ._wait_for_project_operation (
3978- operation = delete_version_operation , timeout = config .timeout if config else 90
4021+ operation = delete_version_operation ,
4022+ timeout = config .timeout if config and config .timeout else 90 ,
4023+ max_wait_time = (
4024+ config .max_wait_time if config and config .max_wait_time else 60
4025+ ),
39794026 )
39804027 logger .info (
39814028 f"Deleted prompt version { version_id } from prompt with id: { prompt_id } "
@@ -4114,7 +4161,10 @@ async def restore_version(
41144161 )
41154162 await self ._wait_for_project_operation (
41164163 operation = restore_prompt_operation ,
4117- timeout = 90 ,
4164+ timeout = config .timeout if config and config .timeout else 90 ,
4165+ max_wait_time = (
4166+ config .max_wait_time if config and config .max_wait_time else 60
4167+ ),
41184168 )
41194169 dataset_version_resource = await self ._get_dataset_version_resource (
41204170 dataset_id = prompt_id ,
0 commit comments