Search in sources :

Example 1 with CreateDatasetRequest

use of com.google.cloud.datalabeling.v1beta1.CreateDatasetRequest in project java-datalabeling by googleapis.

the class CreateDataset method createDataset.

// Create a dataset that is initially empty.
static void createDataset(String projectId, String datasetName) throws IOException {
    // String projectId = "YOUR_PROJECT_ID";
    // String datasetName = "YOUR_DATASET_DISPLAY_NAME";
    // [END datalabeling_create_dataset_beta]
    String endpoint = System.getenv("DATALABELING_ENDPOINT");
    if (endpoint == null) {
        endpoint = DataLabelingServiceSettings.getDefaultEndpoint();
    }
    // [START datalabeling_create_dataset_beta]
    DataLabelingServiceSettings settings = DataLabelingServiceSettings.newBuilder().setEndpoint(endpoint).build();
    try (DataLabelingServiceClient dataLabelingServiceClient = DataLabelingServiceClient.create(settings)) {
        ProjectName projectName = ProjectName.of(projectId);
        Dataset dataset = Dataset.newBuilder().setDisplayName(datasetName).setDescription("YOUR_DESCRIPTION").build();
        CreateDatasetRequest createDatasetRequest = CreateDatasetRequest.newBuilder().setParent(projectName.toString()).setDataset(dataset).build();
        Dataset createdDataset = dataLabelingServiceClient.createDataset(createDatasetRequest);
        System.out.format("Name: %s\n", createdDataset.getName());
        System.out.format("DisplayName: %s\n", createdDataset.getDisplayName());
        System.out.format("Description: %s\n", createdDataset.getDescription());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : CreateDatasetRequest(com.google.cloud.datalabeling.v1beta1.CreateDatasetRequest) DataLabelingServiceClient(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient) ProjectName(com.google.cloud.datalabeling.v1beta1.ProjectName) Dataset(com.google.cloud.datalabeling.v1beta1.Dataset) IOException(java.io.IOException) DataLabelingServiceSettings(com.google.cloud.datalabeling.v1beta1.DataLabelingServiceSettings)

Aggregations

CreateDatasetRequest (com.google.cloud.datalabeling.v1beta1.CreateDatasetRequest)1 DataLabelingServiceClient (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceClient)1 DataLabelingServiceSettings (com.google.cloud.datalabeling.v1beta1.DataLabelingServiceSettings)1 Dataset (com.google.cloud.datalabeling.v1beta1.Dataset)1 ProjectName (com.google.cloud.datalabeling.v1beta1.ProjectName)1 IOException (java.io.IOException)1