@@ -30,7 +30,7 @@ def start(self): # pylint: disable=no-self-use
3030class VertexAITensorboardUploaderTest (absltest .TestCase ):
3131 """Tests VertexAITensorboardUploader."""
3232
33- @mock .patch ("multiprocessing.Process" , side_effect = fake_process )
33+ @mock .patch ("multiprocessing.get_context" )
3434 @mock .patch (f"{ uploader .TensorBoardUploader .__module__ } .TensorBoardUploader" , autospec = True )
3535 @mock .patch (
3636 f"{ initializer .global_config .__module__ } .global_config.create_client" ,
@@ -45,9 +45,15 @@ class VertexAITensorboardUploaderTest(absltest.TestCase):
4545 return_value = ("fake_bucket" , "fake_folder" ),
4646 )
4747 def test_uploader_calls (
48- self , bucket_folder_fn , create_client_fn , tb_uploader_class , unused
48+ self ,
49+ bucket_folder_fn ,
50+ create_client_fn ,
51+ tb_uploader_class ,
52+ mock_get_context ,
4953 ): # pylint: disable=no-self-use
50- del unused
54+ mock_context = mock .MagicMock ()
55+ mock_context .Process .side_effect = fake_process
56+ mock_get_context .return_value = mock_context
5157
5258 mock_settings = {
5359 "vertexai_tensorboard" : "fake_tb_instance" ,
@@ -61,6 +67,7 @@ def test_uploader_calls(
6167 )
6268 tb_uploader = cfg .instantiate ()
6369 tb_uploader .upload ()
70+ mock_get_context .assert_called_once_with ("spawn" )
6471 create_client_fn .assert_called_once ()
6572 bucket_folder_fn .assert_called_once ()
6673 tb_uploader_class .return_value .create_experiment .assert_called_once ()
0 commit comments