|
44 | 44 | _TEST_STAGING_BUCKET = "test-bucket"
|
45 | 45 | _TEST_NETWORK = "projects/12345/global/networks/myVPC"
|
46 | 46 |
|
| 47 | +# tensorboard |
| 48 | +_TEST_TENSORBOARD_ID = "1028944691210842416" |
| 49 | +_TEST_TENSORBOARD_NAME = f"projects/{_TEST_PROJECT}/locations/{_TEST_LOCATION}/tensorboards/{_TEST_TENSORBOARD_ID}" |
| 50 | + |
47 | 51 |
|
48 | 52 | @pytest.mark.usefixtures("google_auth_mock")
|
49 | 53 | class TestInit:
|
@@ -115,6 +119,59 @@ def test_init_experiment_sets_experiment_with_description(
|
115 | 119 | backing_tensorboard=None,
|
116 | 120 | )
|
117 | 121 |
|
| 122 | + @patch.object(_experiment_tracker, "set_tensorboard") |
| 123 | + def test_init_with_experiment_tensorboard_id_sets_global_tensorboard( |
| 124 | + self, set_tensorboard_mock |
| 125 | + ): |
| 126 | + creds = credentials.AnonymousCredentials() |
| 127 | + initializer.global_config.init( |
| 128 | + experiment_tensorboard=_TEST_TENSORBOARD_ID, |
| 129 | + project=_TEST_PROJECT, |
| 130 | + location=_TEST_LOCATION, |
| 131 | + credentials=creds, |
| 132 | + ) |
| 133 | + |
| 134 | + set_tensorboard_mock.assert_called_once_with( |
| 135 | + tensorboard=_TEST_TENSORBOARD_ID, |
| 136 | + project=_TEST_PROJECT, |
| 137 | + location=_TEST_LOCATION, |
| 138 | + credentials=creds, |
| 139 | + ) |
| 140 | + |
| 141 | + @patch.object(_experiment_tracker, "set_tensorboard") |
| 142 | + def test_init_with_experiment_tensorboard_resource_sets_global_tensorboard( |
| 143 | + self, set_tensorboard_mock |
| 144 | + ): |
| 145 | + initializer.global_config.init(experiment_tensorboard=_TEST_TENSORBOARD_NAME) |
| 146 | + |
| 147 | + set_tensorboard_mock.assert_called_once_with( |
| 148 | + tensorboard=_TEST_TENSORBOARD_NAME, |
| 149 | + project=None, |
| 150 | + location=None, |
| 151 | + credentials=None, |
| 152 | + ) |
| 153 | + |
| 154 | + @patch.object(_experiment_tracker, "set_tensorboard") |
| 155 | + @patch.object(_experiment_tracker, "set_experiment") |
| 156 | + def test_init_experiment_without_tensorboard_uses_global_tensorboard( |
| 157 | + self, |
| 158 | + set_tensorboard_mock, |
| 159 | + set_experiment_mock, |
| 160 | + ): |
| 161 | + |
| 162 | + initializer.global_config.init(experiment_tensorboard=_TEST_TENSORBOARD_NAME) |
| 163 | + |
| 164 | + initializer.global_config.init( |
| 165 | + experiment=_TEST_EXPERIMENT, |
| 166 | + ) |
| 167 | + |
| 168 | + set_experiment_mock.assert_called_once_with( |
| 169 | + tensorboard=_TEST_TENSORBOARD_NAME, |
| 170 | + project=None, |
| 171 | + location=None, |
| 172 | + credentials=None, |
| 173 | + ) |
| 174 | + |
118 | 175 | def test_init_experiment_description_fail_without_experiment(self):
|
119 | 176 | with pytest.raises(ValueError):
|
120 | 177 | initializer.global_config.init(experiment_description=_TEST_DESCRIPTION)
|
|
0 commit comments