@@ -227,14 +227,14 @@ async def __get_item_url(self, item_id_future: Union[Optional[str], Task[Optiona
227
227
item_id = await await_if_necessary (item_id_future )
228
228
if item_id is NOT_FOUND or item_id is None :
229
229
logger .warning ("Attempt to make request for non-existent id." )
230
- return
230
+ return None
231
231
return root_uri_join (self .base_url_v2 , "item" , item_id )
232
232
233
233
async def __get_launch_url (self , launch_uuid_future : Union [Optional [str ], Task [Optional [str ]]]) -> Optional [str ]:
234
234
launch_uuid = await await_if_necessary (launch_uuid_future )
235
235
if launch_uuid is NOT_FOUND or launch_uuid is None :
236
236
logger .warning ("Attempt to make request for non-existent launch." )
237
- return
237
+ return None
238
238
return root_uri_join (self .base_url_v2 , "launch" , launch_uuid , "finish" )
239
239
240
240
async def start_launch (
@@ -272,7 +272,7 @@ async def start_launch(
272
272
273
273
response = await AsyncHttpRequest ((await self .session ()).post , url = url , json = request_payload ).make ()
274
274
if not response :
275
- return
275
+ return None
276
276
277
277
if not self ._skip_analytics :
278
278
stat_coro = async_send_event ("start_launch" , * agent_name_version (attributes ))
@@ -347,7 +347,7 @@ async def start_test_item(
347
347
348
348
response = await AsyncHttpRequest ((await self .session ()).post , url = url , json = request_payload ).make ()
349
349
if not response :
350
- return
350
+ return None
351
351
item_id = await response .id
352
352
if item_id is NOT_FOUND or item_id is None :
353
353
logger .warning ("start_test_item - invalid response: %s" , str (await response .json ))
@@ -402,7 +402,7 @@ async def finish_test_item(
402
402
).payload
403
403
response = await AsyncHttpRequest ((await self .session ()).put , url = url , json = request_payload ).make ()
404
404
if not response :
405
- return
405
+ return None
406
406
message = await response .message
407
407
logger .debug ("finish_test_item - ID: %s" , await await_if_necessary (item_id ))
408
408
logger .debug ("response message: %s" , message )
@@ -437,7 +437,7 @@ async def finish_launch(
437
437
(await self .session ()).put , url = url , json = request_payload , name = "Finish Launch"
438
438
).make ()
439
439
if not response :
440
- return
440
+ return None
441
441
message = await response .message
442
442
logger .debug ("finish_launch - ID: %s" , await await_if_necessary (launch_uuid ))
443
443
logger .debug ("response message: %s" , message )
@@ -465,15 +465,15 @@ async def update_test_item(
465
465
url = root_uri_join (self .base_url_v1 , "item" , item_id , "update" )
466
466
response = await AsyncHttpRequest ((await self .session ()).put , url = url , json = data ).make ()
467
467
if not response :
468
- return
468
+ return None
469
469
logger .debug ("update_test_item - Item: %s" , item_id )
470
470
return await response .message
471
471
472
472
async def __get_launch_uuid_url (self , launch_uuid_future : Union [str , Task [str ]]) -> Optional [str ]:
473
473
launch_uuid = await await_if_necessary (launch_uuid_future )
474
474
if launch_uuid is NOT_FOUND or launch_uuid is None :
475
475
logger .warning ("Attempt to make request for non-existent Launch UUID." )
476
- return
476
+ return None
477
477
logger .debug ("get_launch_info - ID: %s" , launch_uuid )
478
478
return root_uri_join (self .base_url_v1 , "launch" , "uuid" , launch_uuid )
479
479
@@ -486,7 +486,7 @@ async def get_launch_info(self, launch_uuid_future: Union[str, Task[str]]) -> Op
486
486
url = self .__get_launch_uuid_url (launch_uuid_future )
487
487
response = await AsyncHttpRequest ((await self .session ()).get , url = url ).make ()
488
488
if not response :
489
- return
489
+ return None
490
490
launch_info = None
491
491
if response .is_success :
492
492
launch_info = await response .json
@@ -499,7 +499,7 @@ async def __get_item_uuid_url(self, item_uuid_future: Union[Optional[str], Task[
499
499
item_uuid = await await_if_necessary (item_uuid_future )
500
500
if item_uuid is NOT_FOUND or item_uuid is None :
501
501
logger .warning ("Attempt to make request for non-existent UUID." )
502
- return
502
+ return None
503
503
return root_uri_join (self .base_url_v1 , "item" , "uuid" , item_uuid )
504
504
505
505
async def get_item_id_by_uuid (self , item_uuid_future : Union [str , Task [str ]]) -> Optional [str ]:
@@ -531,7 +531,7 @@ async def get_launch_ui_url(self, launch_uuid_future: Union[str, Task[str]]) ->
531
531
launch_info = await self .get_launch_info (launch_uuid )
532
532
launch_id = launch_info .get ("id" ) if launch_info else None
533
533
if not launch_id :
534
- return
534
+ return None
535
535
mode = launch_info .get ("mode" ) if launch_info else None
536
536
if not mode :
537
537
mode = self .mode
@@ -564,7 +564,7 @@ async def log_batch(self, log_batch: Optional[List[AsyncRPRequestLog]]) -> Optio
564
564
(await self .session ()).post , url = url , data = AsyncRPLogBatch (log_batch ).payload
565
565
).make ()
566
566
if not response :
567
- return
567
+ return None
568
568
return await response .messages
569
569
570
570
def clone (self ) -> "Client" :
@@ -639,6 +639,8 @@ def launch_uuid(self) -> Optional[str]:
639
639
640
640
:return: UUID string.
641
641
"""
642
+ if self .__launch_uuid is NOT_FOUND :
643
+ return None
642
644
return self .__launch_uuid
643
645
644
646
@property
@@ -750,7 +752,7 @@ async def start_launch(
750
752
name , start_time , description = description , attributes = attributes , rerun = rerun , rerun_of = rerun_of , ** kwargs
751
753
)
752
754
self .__launch_uuid = launch_uuid
753
- return launch_uuid
755
+ return self . launch_uuid
754
756
755
757
async def start_test_item (
756
758
self ,
@@ -791,7 +793,7 @@ async def start_test_item(
791
793
:return: Test Item UUID if successfully started or None.
792
794
"""
793
795
item_id = await self .__client .start_test_item (
794
- self .launch_uuid ,
796
+ self .__launch_uuid ,
795
797
name ,
796
798
start_time ,
797
799
item_type ,
@@ -842,7 +844,7 @@ async def finish_test_item(
842
844
:return: Response message.
843
845
"""
844
846
result = await self .__client .finish_test_item (
845
- self .launch_uuid ,
847
+ self .__launch_uuid ,
846
848
item_id ,
847
849
end_time ,
848
850
status = status ,
@@ -874,7 +876,7 @@ async def finish_launch(
874
876
"""
875
877
if self .use_own_launch :
876
878
result = await self .__client .finish_launch (
877
- self .launch_uuid , end_time , status = status , attributes = attributes , ** kwargs
879
+ self .__launch_uuid , end_time , status = status , attributes = attributes , ** kwargs
878
880
)
879
881
else :
880
882
result = ""
@@ -915,7 +917,7 @@ async def get_launch_info(self) -> Optional[dict]:
915
917
"""
916
918
if not self .launch_uuid :
917
919
return {}
918
- return await self .__client .get_launch_info (self .launch_uuid )
920
+ return await self .__client .get_launch_info (self .__launch_uuid )
919
921
920
922
async def get_item_id_by_uuid (self , item_uuid : str ) -> Optional [str ]:
921
923
"""Get Test Item ID by the given Item UUID.
@@ -931,17 +933,17 @@ async def get_launch_ui_id(self) -> Optional[int]:
931
933
:return: Launch ID of the Launch. None if not found.
932
934
"""
933
935
if not self .launch_uuid :
934
- return
935
- return await self .__client .get_launch_ui_id (self .launch_uuid )
936
+ return None
937
+ return await self .__client .get_launch_ui_id (self .__launch_uuid )
936
938
937
939
async def get_launch_ui_url (self ) -> Optional [str ]:
938
940
"""Get full quality URL of the current Launch.
939
941
940
942
:return: Launch URL string.
941
943
"""
942
944
if not self .launch_uuid :
943
- return
944
- return await self .__client .get_launch_ui_url (self .launch_uuid )
945
+ return None
946
+ return await self .__client .get_launch_ui_url (self .__launch_uuid )
945
947
946
948
async def get_project_settings (self ) -> Optional [dict ]:
947
949
"""Get settings of the current Project.
@@ -972,9 +974,9 @@ async def log(
972
974
"""
973
975
if item_id is NOT_FOUND :
974
976
logger .warning ("Attempt to log to non-existent item" )
975
- return
977
+ return None
976
978
rp_file = RPFile (** attachment ) if attachment else None
977
- rp_log = AsyncRPRequestLog (self .launch_uuid , time , rp_file , item_id , level , message )
979
+ rp_log = AsyncRPRequestLog (self .__launch_uuid , time , rp_file , item_id , level , message )
978
980
return await self .__client .log_batch (await self ._log_batcher .append_async (rp_log ))
979
981
980
982
def clone (self ) -> "AsyncRPClient" :
@@ -989,7 +991,7 @@ def clone(self) -> "AsyncRPClient":
989
991
endpoint = self .endpoint ,
990
992
project = self .project ,
991
993
client = cloned_client ,
992
- launch_uuid = self .launch_uuid ,
994
+ launch_uuid = self .__launch_uuid ,
993
995
log_batch_size = self .log_batch_size ,
994
996
log_batch_payload_limit = self .log_batch_payload_limit ,
995
997
log_batcher = self ._log_batcher ,
@@ -1017,7 +1019,7 @@ class _RPClient(RP, metaclass=AbstractBaseClass):
1017
1019
_item_stack : LifoQueue
1018
1020
_log_batcher : LogBatcher
1019
1021
__client : Client
1020
- __launch_uuid : Optional [Task [str ]]
1022
+ __launch_uuid : Optional [Task [Optional [ str ] ]]
1021
1023
__endpoint : str
1022
1024
__project : str
1023
1025
__step_reporter : StepReporter
@@ -1031,7 +1033,7 @@ def client(self) -> Client:
1031
1033
return self .__client
1032
1034
1033
1035
@property
1034
- def launch_uuid (self ) -> Task [Optional [str ]]:
1036
+ def launch_uuid (self ) -> Optional [ Task [Optional [str ] ]]:
1035
1037
"""Return current Launch UUID.
1036
1038
1037
1039
:return: UUID string.
@@ -1068,7 +1070,7 @@ def __init__(
1068
1070
project : str ,
1069
1071
* ,
1070
1072
client : Optional [Client ] = None ,
1071
- launch_uuid : Optional [Task [str ]] = None ,
1073
+ launch_uuid : Optional [Task [Optional [ str ] ]] = None ,
1072
1074
log_batch_size : int = 20 ,
1073
1075
log_batch_payload_limit : int = MAX_LOG_BATCH_PAYLOAD_SIZE ,
1074
1076
log_batcher : Optional [LogBatcher ] = None ,
@@ -1555,7 +1557,7 @@ def create_task(self, coro: Coroutine[Any, Any, _T]) -> Optional[Task[_T]]:
1555
1557
:return: Task instance.
1556
1558
"""
1557
1559
if not getattr (self , "_loop" , None ):
1558
- return
1560
+ return None
1559
1561
result = self ._loop .create_task (coro )
1560
1562
with self ._task_mutex :
1561
1563
self ._task_list .append (result )
@@ -1742,7 +1744,7 @@ def create_task(self, coro: Coroutine[Any, Any, _T]) -> Optional[Task[_T]]:
1742
1744
:return: Task instance.
1743
1745
"""
1744
1746
if not getattr (self , "_loop" , None ):
1745
- return
1747
+ return None
1746
1748
result = self ._loop .create_task (coro )
1747
1749
with self ._task_mutex :
1748
1750
tasks = self ._task_list .append (result )
0 commit comments