Skip to content

Commit

Permalink
chore: deleted duplite and unused region tags (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
munkhuushmgl authored and Shabirmean committed Nov 18, 2022
1 parent 6293490 commit 31a00eb
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,30 +75,6 @@ public static void importData(
}
// [END automl_translate_import_data]

// [START automl_translate_delete_dataset]
/**
* Delete a dataset.
*
* @param projectId the Google Cloud Project ID.
* @param computeRegion the Region name. (e.g., "us-central1").
* @param datasetId the Id of the dataset.
*/
public static void deleteDataset(String projectId, String computeRegion, String datasetId)
throws IOException, InterruptedException, ExecutionException {
// Instantiates a client
try (AutoMlClient client = AutoMlClient.create()) {

// Get the full path of the dataset.
DatasetName datasetFullId = DatasetName.of(projectId, computeRegion, datasetId);

// Delete a dataset.
Empty response = client.deleteDatasetAsync(datasetFullId).get();

System.out.println(String.format("Dataset deleted. %s", response));
}
}
// [END automl_translate_delete_dataset]

public static void main(String[] args) throws Exception {
DatasetApi datasetApi = new DatasetApi();
datasetApi.argsHelper(args, System.out);
Expand All @@ -112,8 +88,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
importDataParser.addArgument("datasetId");
importDataParser.addArgument("path");

Subparser deleteDatasetParser = subparsers.addParser("delete_dataset");
deleteDatasetParser.addArgument("datasetId");

String projectId = System.getenv("PROJECT_ID");
String computeRegion = System.getenv("REGION_NAME");
Expand All @@ -124,9 +98,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
if (ns.get("command").equals("import_data")) {
importData(projectId, computeRegion, ns.getString("datasetId"), ns.getString("path"));
}
if (ns.get("command").equals("delete_dataset")) {
deleteDataset(projectId, computeRegion, ns.getString("datasetId"));
}
} catch (ArgumentParserException e) {
parser.handleError(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
import com.google.cloud.automl.v1beta1.Model;
import com.google.cloud.automl.v1beta1.ModelName;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.io.PrintStream;
import java.util.concurrent.ExecutionException;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
Expand Down Expand Up @@ -83,65 +81,6 @@ public static void listModels(String projectId, String computeRegion, String fil
}
// [END automl_translate_list_models]

// [START automl_translate_get_model]
/**
* Demonstrates using the AutoML client to get model details.
*
* @param projectId the Id of the project.
* @param computeRegion the Region name.
* @param modelId the Id of the model.
* @throws IOException on Input/Output errors.
*/
public static void getModel(String projectId, String computeRegion, String modelId)
throws IOException {
// Instantiates a client
try (AutoMlClient client = AutoMlClient.create()) {

// Get the full path of the model.
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);

// Get complete detail of the model.
Model model = client.getModel(modelFullId);

// Display the model information.
System.out.println(String.format("Model name: %s", model.getName()));
System.out.println(
String.format(
"Model id: %s", model.getName().split("/")[model.getName().split("/").length - 1]));
System.out.println(String.format("Model display name: %s", model.getDisplayName()));
System.out.println("Model create time:");
System.out.println(String.format("\tseconds: %s", model.getCreateTime().getSeconds()));
System.out.println(String.format("\tnanos: %s", model.getCreateTime().getNanos()));
System.out.println(String.format("Model deployment state: %s", model.getDeploymentState()));
}
}
// [END automl_translate_get_model]

// [START automl_translate_delete_model]
/**
* Demonstrates using the AutoML client to delete a model.
*
* @param projectId the Id of the project.
* @param computeRegion the Region name.
* @param modelId the Id of the model.
* @throws Exception on AutoML Client errors
*/
public static void deleteModel(String projectId, String computeRegion, String modelId)
throws InterruptedException, ExecutionException, IOException {
// Instantiates a client
try (AutoMlClient client = AutoMlClient.create()) {

// Get the full path of the model.
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);

// Delete a model.
Empty response = client.deleteModelAsync(modelFullId).get();

System.out.println("Model deletion started...");
}
}
// [END automl_translate_delete_model]

// [START automl_translate_get_operation_status]
/**
* Demonstrates using the AutoML client to get operation status.
Expand Down Expand Up @@ -179,12 +118,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
Subparser listModelParser = subparsers.addParser("list_models");
listModelParser.addArgument("filter").nargs("?").setDefault("");

Subparser getModelParser = subparsers.addParser("get_model");
getModelParser.addArgument("modelId");

Subparser deleteModelParser = subparsers.addParser("delete_model");
deleteModelParser.addArgument("modelId");

Subparser getOperationStatusParser = subparsers.addParser("get_operation_status");
getOperationStatusParser.addArgument("operationFullId");

Expand All @@ -197,12 +130,6 @@ public static void argsHelper(String[] args, PrintStream out) throws Exception {
if (ns.get("command").equals("list_models")) {
listModels(projectId, computeRegion, ns.getString("filter"));
}
if (ns.get("command").equals("get_model")) {
getModel(projectId, computeRegion, ns.getString("modelId"));
}
if (ns.get("command").equals("delete_model")) {
deleteModel(projectId, computeRegion, ns.getString("modelId"));
}
if (ns.get("command").equals("get_operation_status")) {
getOperationStatus(ns.getString("operationFullId"));
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,5 @@ public void testModelApi() throws Exception {
String got = bout.toString();
modelId = got.split("\n")[1].split("/")[got.split("\n")[1].split("/").length - 1];
assertThat(got).contains("Model id:");

// Act
ModelApi.getModel(PROJECT_ID, COMPUTE_REGION, modelId);

// Assert
got = bout.toString();
assertThat(got).contains("Model name:");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ public void tearDown() {
System.setOut(originalPrintStream);
}

@Test
public void testClassificationDeployModelApi() {
// As model deployment can take a long time, instead try to deploy a
// nonexistent model and confirm that the model was not found, but other
// elements of the request were valid.
try {
ClassificationDeployModel.classificationDeployModel(PROJECT_ID, MODEL_ID);
String got = bout.toString();
assertThat(got).contains("The model does not exist");
} catch (IOException | ExecutionException | InterruptedException e) {
assertThat(e.getMessage()).contains("The model does not exist");
}
}

@Test
public void testClassificationUndeployModelApi() {
// As model deployment can take a long time, instead try to deploy a
Expand Down

0 comments on commit 31a00eb

Please sign in to comment.