Skip to content

Commit 67b5c93

Browse files
committed
fix: restore 5 files
1 parent 88f785e commit 67b5c93

File tree

5 files changed

+461
-0
lines changed

5 files changed

+461
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
async function main(
20+
datasetDisplayName,
21+
metadataSchemaUri,
22+
project,
23+
location = 'us-central1'
24+
) {
25+
// [START aiplatform_create_dataset_sample]
26+
/**
27+
* TODO(developer): Uncomment these variables before running the sample.\
28+
* (Not necessary if passing values as arguments)
29+
*/
30+
31+
// const datasetDisplayName = 'YOUR_DATASET_DISPLAY_NAME';
32+
// const metadataSchemaUri = 'YOUR_METADATA_SCHEMA_URI';
33+
// const project = 'YOUR_PROJECT_ID';
34+
// const location = 'YOUR_PROJECT_LOCATION';
35+
36+
// Imports the Google Cloud Dataset Service Client library
37+
const {DatasetServiceClient} = require('@google-cloud/aiplatform');
38+
39+
// Specifies the location of the api endpoint
40+
const clientOptions = {
41+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
42+
};
43+
44+
// Instantiates a client
45+
const datasetServiceClient = new DatasetServiceClient(clientOptions);
46+
47+
async function createDataset() {
48+
// Configure the parent resource
49+
const parent = `projects/${project}/locations/${location}`;
50+
// Configure the dataset resource
51+
const dataset = {
52+
displayName: datasetDisplayName,
53+
metadataSchemaUri: metadataSchemaUri,
54+
};
55+
const request = {
56+
parent,
57+
dataset,
58+
};
59+
60+
// Create Dataset Request
61+
const [response] = await datasetServiceClient.createDataset(request);
62+
console.log(`Long running operation : ${response.name}`);
63+
64+
// Wait for operation to complete
65+
const [createDatasetResponse] = await response.promise();
66+
67+
console.log('Create dataset response');
68+
console.log(`\tName : ${createDatasetResponse.name}`);
69+
console.log(`\tDisplay name : ${createDatasetResponse.displayName}`);
70+
console.log(
71+
`\tMetadata schema uri : ${createDatasetResponse.metadataSchemaUri}`
72+
);
73+
console.log(
74+
`\tMetadata : ${JSON.stringify(createDatasetResponse.metadata)}`
75+
);
76+
console.log(`\tCreate time : ${createDatasetResponse.createTime}`);
77+
console.log(`\tUpdate time : ${createDatasetResponse.updateTime}`);
78+
console.log(`\tLabels : ${JSON.stringify(createDatasetResponse.labels)}`);
79+
}
80+
createDataset();
81+
// [END aiplatform_create_dataset_sample]
82+
}
83+
84+
process.on('unhandledRejection', err => {
85+
console.error(err.message);
86+
process.exitCode = 1;
87+
});
88+
89+
main(...process.argv.slice(2));
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Creates a new Featurestore with fixed nodes configuration in a given project and location.
19+
* See https://cloud.google.com/vertex-ai/docs/featurestore/setup before running
20+
* the code snippet
21+
*/
22+
23+
'use strict';
24+
25+
async function main(
26+
project,
27+
featurestoreId,
28+
fixedNodeCount = 1,
29+
location = 'us-central1',
30+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
31+
timeout = 900000
32+
) {
33+
// [START aiplatform_create_featurestore_fixed_nodes_sample]
34+
/**
35+
* TODO(developer): Uncomment these variables before running the sample.\
36+
* (Not necessary if passing values as arguments)
37+
*/
38+
39+
// const project = 'YOUR_PROJECT_ID';
40+
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
41+
// const fixedNodeCount = <NO_OF_NODES>;
42+
// const location = 'YOUR_PROJECT_LOCATION';
43+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
44+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
45+
46+
// Imports the Google Cloud Featurestore Service Client library
47+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
48+
49+
// Specifies the location of the api endpoint
50+
const clientOptions = {
51+
apiEndpoint: apiEndpoint,
52+
};
53+
54+
// Instantiates a client
55+
const featurestoreServiceClient = new FeaturestoreServiceClient(
56+
clientOptions
57+
);
58+
59+
async function createFeaturestoreFixedNodes() {
60+
// Configure the parent resource
61+
const parent = `projects/${project}/locations/${location}`;
62+
63+
const featurestore = {
64+
onlineServingConfig: {fixedNodeCount: Number(fixedNodeCount)},
65+
};
66+
67+
const request = {
68+
parent: parent,
69+
featurestore: featurestore,
70+
featurestoreId: featurestoreId,
71+
};
72+
73+
// Create Featurestore request
74+
const [operation] = await featurestoreServiceClient.createFeaturestore(
75+
request,
76+
{timeout: Number(timeout)}
77+
);
78+
const [response] = await operation.promise();
79+
80+
console.log('Create featurestore fixed nodes response');
81+
console.log(`Name : ${response.name}`);
82+
console.log('Raw response:');
83+
console.log(JSON.stringify(response, null, 2));
84+
}
85+
createFeaturestoreFixedNodes();
86+
// [END aiplatform_create_featurestore_fixed_nodes_sample]
87+
}
88+
89+
process.on('unhandledRejection', err => {
90+
console.error(err.message);
91+
process.exitCode = 1;
92+
});
93+
94+
main(...process.argv.slice(2));
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
function main(
20+
displayName,
21+
containerImageUri,
22+
project,
23+
location = 'us-central1'
24+
) {
25+
// [START aiplatform_create_hyperparameter_tuning_job_sample]
26+
/**
27+
* TODO(developer): Uncomment these variables before running the sample.
28+
* (Not necessary if passing values as arguments)
29+
*/
30+
/*
31+
const displayName = 'YOUR HYPERPARAMETER TUNING JOB;
32+
const containerImageUri = 'TUNING JOB CONTAINER URI;
33+
const project = 'YOUR PROJECT ID';
34+
const location = 'us-central1';
35+
*/
36+
// Imports the Google Cloud Pipeline Service Client library
37+
const {JobServiceClient} = require('@google-cloud/aiplatform');
38+
39+
// Specifies the location of the api endpoint
40+
const clientOptions = {
41+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
42+
};
43+
44+
// Instantiates a client
45+
const jobServiceClient = new JobServiceClient(clientOptions);
46+
47+
async function createHyperParameterTuningJob() {
48+
// Configure the parent resource
49+
const parent = `projects/${project}/locations/${location}`;
50+
51+
// Create the hyperparameter tuning job configuration
52+
const hyperparameterTuningJob = {
53+
displayName,
54+
maxTrialCount: 2,
55+
parallelTrialCount: 1,
56+
maxFailedTrialCount: 1,
57+
studySpec: {
58+
metrics: [
59+
{
60+
metricId: 'accuracy',
61+
goal: 'MAXIMIZE',
62+
},
63+
],
64+
parameters: [
65+
{
66+
parameterId: 'lr',
67+
doubleValueSpec: {
68+
minValue: 0.001,
69+
maxValue: 0.1,
70+
},
71+
},
72+
],
73+
},
74+
trialJobSpec: {
75+
workerPoolSpecs: [
76+
{
77+
machineSpec: {
78+
machineType: 'n1-standard-4',
79+
acceleratorType: 'NVIDIA_TESLA_K80',
80+
acceleratorCount: 1,
81+
},
82+
replicaCount: 1,
83+
containerSpec: {
84+
imageUri: containerImageUri,
85+
command: [],
86+
args: [],
87+
},
88+
},
89+
],
90+
},
91+
};
92+
93+
const [response] = await jobServiceClient.createHyperparameterTuningJob({
94+
parent,
95+
hyperparameterTuningJob,
96+
});
97+
98+
console.log('Create hyperparameter tuning job response:');
99+
console.log(`\tDisplay name: ${response.displayName}`);
100+
console.log(`\tTuning job resource name: ${response.name}`);
101+
console.log(`\tJob status: ${response.state}`);
102+
}
103+
104+
createHyperParameterTuningJob();
105+
// [END aiplatform_create_hyperparameter_tuning_job_sample]
106+
}
107+
108+
process.on('unhandledRejection', err => {
109+
console.error(err.message);
110+
process.exitCode = 1;
111+
});
112+
113+
main(...process.argv.slice(2));
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2020 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
async function main(
20+
datasetId,
21+
modelDisplayName,
22+
trainingPipelineDisplayName,
23+
project,
24+
location = 'us-central1'
25+
) {
26+
// [START aiplatform_create_training_pipeline_video_action_recognition_sample]
27+
/**
28+
* TODO(developer): Uncomment these variables before running the sample.\
29+
* (Not necessary if passing values as arguments)
30+
*/
31+
32+
// const datasetId = 'YOUR_DATASET_ID';
33+
// const modelDisplayName = 'YOUR_MODEL_DISPLAY_NAME';
34+
// const trainingPipelineDisplayName = 'YOUR_TRAINING_PIPELINE_DISPLAY_NAME';
35+
// const project = 'YOUR_PROJECT_ID';
36+
// const location = 'YOUR_PROJECT_LOCATION';
37+
const aiplatform = require('@google-cloud/aiplatform');
38+
const {definition} =
39+
aiplatform.protos.google.cloud.aiplatform.v1.schema.trainingjob;
40+
41+
// Imports the Google Cloud Pipeline Service Client library
42+
const {PipelineServiceClient} = aiplatform.v1;
43+
44+
// Specifies the location of the api endpoint
45+
const clientOptions = {
46+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
47+
};
48+
49+
// Instantiates a client
50+
const pipelineServiceClient = new PipelineServiceClient(clientOptions);
51+
52+
async function createTrainingPipelineVideoActionRecognition() {
53+
// Configure the parent resource
54+
const parent = `projects/${project}/locations/${location}`;
55+
// Values should match the input expected by your model.
56+
const trainingTaskInputObj =
57+
new definition.AutoMlVideoActionRecognitionInputs({
58+
// modelType can be either 'CLOUD' or 'MOBILE_VERSATILE_1'
59+
modelType: 'CLOUD',
60+
});
61+
const trainingTaskInputs = trainingTaskInputObj.toValue();
62+
63+
const modelToUpload = {displayName: modelDisplayName};
64+
const inputDataConfig = {datasetId: datasetId};
65+
const trainingPipeline = {
66+
displayName: trainingPipelineDisplayName,
67+
trainingTaskDefinition:
68+
'gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_video_action_recognition_1.0.0.yaml',
69+
trainingTaskInputs,
70+
inputDataConfig,
71+
modelToUpload,
72+
};
73+
const request = {
74+
parent,
75+
trainingPipeline,
76+
};
77+
78+
// Create training pipeline request
79+
const [response] =
80+
await pipelineServiceClient.createTrainingPipeline(request);
81+
82+
console.log('Create training pipeline video action recognition response');
83+
console.log(`Name : ${response.name}`);
84+
console.log('Raw response:');
85+
console.log(JSON.stringify(response, null, 2));
86+
}
87+
createTrainingPipelineVideoActionRecognition();
88+
// [END aiplatform_create_training_pipeline_video_action_recognition_sample]
89+
}
90+
91+
process.on('unhandledRejection', err => {
92+
console.error(err.message);
93+
process.exitCode = 1;
94+
});
95+
96+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)