Skip to content

Commit 1833a5c

Browse files
Deleted settings
1 parent df64c89 commit 1833a5c

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

tpu/src/main/java/tpu/CreateTpuWithTopologyFlag.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
package tpu;
1818

1919
//[START tpu_vm_create_topology]
20-
import com.google.api.gax.longrunning.OperationTimedPollAlgorithm;
21-
import com.google.api.gax.retrying.RetrySettings;
2220
import com.google.cloud.tpu.v2.AcceleratorConfig;
2321
import com.google.cloud.tpu.v2.AcceleratorConfig.Type;
2422
import com.google.cloud.tpu.v2.CreateNodeRequest;
2523
import com.google.cloud.tpu.v2.Node;
2624
import com.google.cloud.tpu.v2.TpuClient;
27-
import com.google.cloud.tpu.v2.TpuSettings;
2825
import java.io.IOException;
2926
import java.util.concurrent.ExecutionException;
30-
import org.threeten.bp.Duration;
3127

3228
public class CreateTpuWithTopologyFlag {
3329

@@ -60,29 +56,10 @@ public static void main(String[] args)
6056
public static Node createTpuWithTopologyFlag(String projectId, String zone, String nodeName,
6157
Type tpuVersion, String tpuSoftwareVersion, String topology)
6258
throws IOException, ExecutionException, InterruptedException {
63-
// With these settings the client library handles the Operation's polling mechanism
64-
// and prevent CancellationException error
65-
TpuSettings.Builder clientSettings =
66-
TpuSettings.newBuilder();
67-
clientSettings
68-
.createNodeOperationSettings()
69-
.setPollingAlgorithm(
70-
OperationTimedPollAlgorithm.create(
71-
RetrySettings.newBuilder()
72-
.setInitialRetryDelay(Duration.ofMillis(5000L))
73-
.setRetryDelayMultiplier(1.5)
74-
.setMaxRetryDelay(Duration.ofMillis(45000L))
75-
.setInitialRpcTimeout(Duration.ZERO)
76-
.setRpcTimeoutMultiplier(1.0)
77-
.setMaxRpcTimeout(Duration.ZERO)
78-
.setTotalTimeout(Duration.ofHours(24L))
79-
.build()));
80-
8159
// Initialize client that will be used to send requests. This client only needs to be created
8260
// once, and can be reused for multiple requests.
83-
try (TpuClient tpuClient = TpuClient.create(clientSettings.build())) {
61+
try (TpuClient tpuClient = TpuClient.create()) {
8462
String parent = String.format("projects/%s/locations/%s", projectId, zone);
85-
8663
Node tpuVm =
8764
Node.newBuilder()
8865
.setName(nodeName)

tpu/src/test/java/tpu/TpuVmIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ public void testCreateTpuVmWithTopologyFlag()
130130
TpuClient mockTpuClient = mock(TpuClient.class);
131131
OperationFuture mockFuture = mock(OperationFuture.class);
132132

133-
mockedTpuClient.when(() -> TpuClient.create(any(TpuSettings.class)))
134-
.thenReturn(mockTpuClient);
133+
mockedTpuClient.when(TpuClient::create).thenReturn(mockTpuClient);
135134
when(mockTpuClient.createNodeAsync(any(CreateNodeRequest.class)))
136135
.thenReturn(mockFuture);
137136
when(mockFuture.get()).thenReturn(mockNode);

0 commit comments

Comments
 (0)