@@ -1174,7 +1174,7 @@ def _restore_version(
11741174 request_dict = _common .convert_to_dict (request_dict )
11751175 request_dict = _common .encode_unserializable_types (request_dict )
11761176
1177- response = self ._api_client .request ("get " , path , request_dict , http_options )
1177+ response = self ._api_client .request ("post " , path , request_dict , http_options )
11781178
11791179 response_dict = {} if not response .body else json .loads (response .body )
11801180
@@ -1715,11 +1715,6 @@ def _wait_for_operation(
17151715 "Create prompt operation did not complete within the"
17161716 f" specified timeout of { timeout } seconds."
17171717 )
1718- current_time = time .time ()
1719- if current_time - previous_time >= sleep_duration :
1720- sleep_duration = min (sleep_duration * wait_multiplier , max_wait_time )
1721- previous_time = current_time
1722- time .sleep (sleep_duration )
17231718 prompt_dataset_operation = self ._get_dataset_operation (
17241719 dataset_id = dataset_id ,
17251720 operation_id = operation_id ,
@@ -1729,6 +1724,14 @@ def _wait_for_operation(
17291724 if hasattr (prompt_dataset_operation , "done" )
17301725 else False
17311726 )
1727+ if not done :
1728+ current_time = time .time ()
1729+ if current_time - previous_time >= sleep_duration :
1730+ sleep_duration = min (
1731+ sleep_duration * wait_multiplier , max_wait_time
1732+ )
1733+ previous_time = current_time
1734+ time .sleep (sleep_duration )
17321735 if (
17331736 not prompt_dataset_operation
17341737 or prompt_dataset_operation .response is None
@@ -1948,11 +1951,6 @@ def _wait_for_project_operation(
19481951 f"Delete operation did not complete within the"
19491952 f" specified timeout of { timeout } seconds."
19501953 )
1951- current_time = time .time ()
1952- if current_time - previous_time >= sleep_duration :
1953- sleep_duration = min (sleep_duration * wait_multiplier , max_wait_time )
1954- previous_time = current_time
1955- time .sleep (sleep_duration )
19561954 operations_module = operations .Operations (api_client_ = self ._api_client )
19571955
19581956 if operation .name is None :
@@ -1961,6 +1959,14 @@ def _wait_for_project_operation(
19611959 operation_id = operation .name .split ("/" )[- 1 ],
19621960 )
19631961 done = (operation .done or False ) if hasattr (operation , "done" ) else False
1962+ if not done :
1963+ current_time = time .time ()
1964+ if current_time - previous_time >= sleep_duration :
1965+ sleep_duration = min (
1966+ sleep_duration * wait_multiplier , max_wait_time
1967+ )
1968+ previous_time = current_time
1969+ time .sleep (sleep_duration )
19641970 if hasattr (operation , "error" ) and operation .error is not None :
19651971 raise ValueError (f"Error in delete operation: { operation .error } " )
19661972
@@ -2369,7 +2375,7 @@ def update(
23692375
23702376 # Step 1: Update the dataset resource for the prompt and wait for the operation to complete.
23712377 updated_dataset_resource = self ._update_dataset_resource (
2372- name = f"projects/{ self ._api_client .project } /locations/{ self ._api_client .location } " ,
2378+ name = f"projects/{ self ._api_client .project } /locations/{ self ._api_client .location } /datasets/ { prompt_id } " ,
23732379 dataset_id = prompt_id ,
23742380 display_name = (
23752381 config .prompt_display_name
@@ -3159,7 +3165,7 @@ async def _restore_version(
31593165 request_dict = _common .encode_unserializable_types (request_dict )
31603166
31613167 response = await self ._api_client .async_request (
3162- "get " , path , request_dict , http_options
3168+ "post " , path , request_dict , http_options
31633169 )
31643170
31653171 response_dict = {} if not response .body else json .loads (response .body )
@@ -3709,7 +3715,7 @@ async def update(
37093715
37103716 # Step 1: Update the dataset resource for the prompt and wait for the operation to complete.
37113717 updated_dataset_resource = await self ._update_dataset_resource (
3712- name = f"projects/{ self ._api_client .project } /locations/{ self ._api_client .location } " ,
3718+ name = f"projects/{ self ._api_client .project } /locations/{ self ._api_client .location } /datasets/ { prompt_id } " ,
37133719 dataset_id = prompt_id ,
37143720 display_name = (
37153721 config .prompt_display_name
@@ -3910,11 +3916,6 @@ async def _wait_for_project_operation(
39103916 f"Delete operation did not complete within the"
39113917 f" specified timeout of { timeout } seconds."
39123918 )
3913- current_time = time .time ()
3914- if current_time - previous_time >= sleep_duration :
3915- sleep_duration = min (sleep_duration * wait_multiplier , max_wait_time )
3916- previous_time = current_time
3917- await asyncio .sleep (sleep_duration )
39183919 operations_module = operations .AsyncOperations (api_client_ = self ._api_client )
39193920
39203921 if operation .name is None :
@@ -3923,6 +3924,14 @@ async def _wait_for_project_operation(
39233924 operation_id = operation .name .split ("/" )[- 1 ],
39243925 )
39253926 done = (operation .done or False ) if hasattr (operation , "done" ) else False
3927+ if not done :
3928+ current_time = time .time ()
3929+ if current_time - previous_time >= sleep_duration :
3930+ sleep_duration = min (
3931+ sleep_duration * wait_multiplier , max_wait_time
3932+ )
3933+ previous_time = current_time
3934+ await asyncio .sleep (sleep_duration )
39263935 if hasattr (operation , "error" ) and operation .error is not None :
39273936 raise ValueError (f"Error in delete operation: { operation .error } " )
39283937
0 commit comments