Skip to content

Commit f92b107

Browse files
authored
chore: deleted duplite and unused region tags (#500)
1 parent 501dc91 commit f92b107

File tree

6 files changed

+0
-268
lines changed

6 files changed

+0
-268
lines changed

automl/snippets/src/main/java/com/google/cloud/translate/automl/DatasetApi.java

-29
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,6 @@ public static void importData(
7575
}
7676
// [END automl_translate_import_data]
7777

78-
// [START automl_translate_delete_dataset]
79-
/**
80-
* Delete a dataset.
81-
*
82-
* @param projectId the Google Cloud Project ID.
83-
* @param computeRegion the Region name. (e.g., "us-central1").
84-
* @param datasetId the Id of the dataset.
85-
*/
86-
public static void deleteDataset(String projectId, String computeRegion, String datasetId)
87-
throws IOException, InterruptedException, ExecutionException {
88-
// Instantiates a client
89-
try (AutoMlClient client = AutoMlClient.create()) {
90-
91-
// Get the full path of the dataset.
92-
DatasetName datasetFullId = DatasetName.of(projectId, computeRegion, datasetId);
93-
94-
// Delete a dataset.
95-
Empty response = client.deleteDatasetAsync(datasetFullId).get();
96-
97-
System.out.println(String.format("Dataset deleted. %s", response));
98-
}
99-
}
100-
// [END automl_translate_delete_dataset]
101-
10278
public static void main(String[] args) throws Exception {
10379
DatasetApi datasetApi = new DatasetApi();
10480
datasetApi.argsHelper(args, System.out);
@@ -112,8 +88,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
11288
importDataParser.addArgument("datasetId");
11389
importDataParser.addArgument("path");
11490

115-
Subparser deleteDatasetParser = subparsers.addParser("delete_dataset");
116-
deleteDatasetParser.addArgument("datasetId");
11791

11892
String projectId = System.getenv("PROJECT_ID");
11993
String computeRegion = System.getenv("REGION_NAME");
@@ -124,9 +98,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
12498
if (ns.get("command").equals("import_data")) {
12599
importData(projectId, computeRegion, ns.getString("datasetId"), ns.getString("path"));
126100
}
127-
if (ns.get("command").equals("delete_dataset")) {
128-
deleteDataset(projectId, computeRegion, ns.getString("datasetId"));
129-
}
130101
} catch (ArgumentParserException e) {
131102
parser.handleError(e);
132103
}

automl/snippets/src/main/java/com/google/cloud/translate/automl/ModelApi.java

-73
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
import com.google.cloud.automl.v1beta1.Model;
2424
import com.google.cloud.automl.v1beta1.ModelName;
2525
import com.google.longrunning.Operation;
26-
import com.google.protobuf.Empty;
2726
import java.io.IOException;
2827
import java.io.PrintStream;
29-
import java.util.concurrent.ExecutionException;
3028
import net.sourceforge.argparse4j.ArgumentParsers;
3129
import net.sourceforge.argparse4j.inf.ArgumentParser;
3230
import net.sourceforge.argparse4j.inf.ArgumentParserException;
@@ -83,65 +81,6 @@ public static void listModels(String projectId, String computeRegion, String fil
8381
}
8482
// [END automl_translate_list_models]
8583

86-
// [START automl_translate_get_model]
87-
/**
88-
* Demonstrates using the AutoML client to get model details.
89-
*
90-
* @param projectId the Id of the project.
91-
* @param computeRegion the Region name.
92-
* @param modelId the Id of the model.
93-
* @throws IOException on Input/Output errors.
94-
*/
95-
public static void getModel(String projectId, String computeRegion, String modelId)
96-
throws IOException {
97-
// Instantiates a client
98-
try (AutoMlClient client = AutoMlClient.create()) {
99-
100-
// Get the full path of the model.
101-
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);
102-
103-
// Get complete detail of the model.
104-
Model model = client.getModel(modelFullId);
105-
106-
// Display the model information.
107-
System.out.println(String.format("Model name: %s", model.getName()));
108-
System.out.println(
109-
String.format(
110-
"Model id: %s", model.getName().split("/")[model.getName().split("/").length - 1]));
111-
System.out.println(String.format("Model display name: %s", model.getDisplayName()));
112-
System.out.println("Model create time:");
113-
System.out.println(String.format("\tseconds: %s", model.getCreateTime().getSeconds()));
114-
System.out.println(String.format("\tnanos: %s", model.getCreateTime().getNanos()));
115-
System.out.println(String.format("Model deployment state: %s", model.getDeploymentState()));
116-
}
117-
}
118-
// [END automl_translate_get_model]
119-
120-
// [START automl_translate_delete_model]
121-
/**
122-
* Demonstrates using the AutoML client to delete a model.
123-
*
124-
* @param projectId the Id of the project.
125-
* @param computeRegion the Region name.
126-
* @param modelId the Id of the model.
127-
* @throws Exception on AutoML Client errors
128-
*/
129-
public static void deleteModel(String projectId, String computeRegion, String modelId)
130-
throws InterruptedException, ExecutionException, IOException {
131-
// Instantiates a client
132-
try (AutoMlClient client = AutoMlClient.create()) {
133-
134-
// Get the full path of the model.
135-
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);
136-
137-
// Delete a model.
138-
Empty response = client.deleteModelAsync(modelFullId).get();
139-
140-
System.out.println("Model deletion started...");
141-
}
142-
}
143-
// [END automl_translate_delete_model]
144-
14584
// [START automl_translate_get_operation_status]
14685
/**
14786
* Demonstrates using the AutoML client to get operation status.
@@ -179,12 +118,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
179118
Subparser listModelParser = subparsers.addParser("list_models");
180119
listModelParser.addArgument("filter").nargs("?").setDefault("");
181120

182-
Subparser getModelParser = subparsers.addParser("get_model");
183-
getModelParser.addArgument("modelId");
184-
185-
Subparser deleteModelParser = subparsers.addParser("delete_model");
186-
deleteModelParser.addArgument("modelId");
187-
188121
Subparser getOperationStatusParser = subparsers.addParser("get_operation_status");
189122
getOperationStatusParser.addArgument("operationFullId");
190123

@@ -197,12 +130,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
197130
if (ns.get("command").equals("list_models")) {
198131
listModels(projectId, computeRegion, ns.getString("filter"));
199132
}
200-
if (ns.get("command").equals("get_model")) {
201-
getModel(projectId, computeRegion, ns.getString("modelId"));
202-
}
203-
if (ns.get("command").equals("delete_model")) {
204-
deleteModel(projectId, computeRegion, ns.getString("modelId"));
205-
}
206133
if (ns.get("command").equals("get_operation_status")) {
207134
getOperationStatus(ns.getString("operationFullId"));
208135
}

automl/snippets/src/main/java/com/google/cloud/vision/ClassificationDeployModel.java

-60
This file was deleted.

automl/snippets/src/main/java/com/google/cloud/vision/ModelApi.java

-85
This file was deleted.

automl/snippets/src/test/java/com/google/cloud/translate/automl/ModelApiIT.java

-7
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,5 @@ public void testModelApi() throws Exception {
6262
String got = bout.toString();
6363
modelId = got.split("\n")[1].split("/")[got.split("\n")[1].split("/").length - 1];
6464
assertThat(got).contains("Model id:");
65-
66-
// Act
67-
ModelApi.getModel(PROJECT_ID, COMPUTE_REGION, modelId);
68-
69-
// Assert
70-
got = bout.toString();
71-
assertThat(got).contains("Model name:");
7265
}
7366
}

automl/snippets/src/test/java/com/google/cloud/vision/ClassificationDeployModelIT.java

-14
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ public void tearDown() {
4848
System.setOut(originalPrintStream);
4949
}
5050

51-
@Test
52-
public void testClassificationDeployModelApi() {
53-
// As model deployment can take a long time, instead try to deploy a
54-
// nonexistent model and confirm that the model was not found, but other
55-
// elements of the request were valid.
56-
try {
57-
ClassificationDeployModel.classificationDeployModel(PROJECT_ID, MODEL_ID);
58-
String got = bout.toString();
59-
assertThat(got).contains("The model does not exist");
60-
} catch (IOException | ExecutionException | InterruptedException e) {
61-
assertThat(e.getMessage()).contains("The model does not exist");
62-
}
63-
}
64-
6551
@Test
6652
public void testClassificationUndeployModelApi() {
6753
// As model deployment can take a long time, instead try to deploy a

0 commit comments

Comments
 (0)