Skip to content

Commit 3a0164d

Browse files
committed
fix: delete unused tests and restore some more files
1 parent 8fee3d5 commit 3a0164d

20 files changed

+1172
-259
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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+
* Batch reads Feature values from a Featurestore.
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+
inputCsvFile,
29+
destinationTableUri,
30+
location = 'us-central1',
31+
apiEndpoint = 'us-central1-aiplatform.googleapis.com',
32+
timeout = 300000
33+
) {
34+
// [START aiplatform_batch_read_feature_values_sample]
35+
/**
36+
* TODO(developer): Uncomment these variables before running the sample.\
37+
* (Not necessary if passing values as arguments)
38+
*/
39+
40+
// const project = 'YOUR_PROJECT_ID';
41+
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
42+
// const inputCsvFile = 'YOUR_INPUT_CSV_FILE_URI';
43+
// const destinationTableUri = 'YOUR_BQ_DESTINATION_TABLE_URI';
44+
// const location = 'YOUR_PROJECT_LOCATION';
45+
// const apiEndpoint = 'YOUR_API_ENDPOINT';
46+
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;
47+
48+
// Imports the Google Cloud Featurestore Service Client library
49+
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;
50+
51+
// Specifies the location of the api endpoint
52+
const clientOptions = {
53+
apiEndpoint: apiEndpoint,
54+
};
55+
56+
// Instantiates a client
57+
const featurestoreServiceClient = new FeaturestoreServiceClient(
58+
clientOptions
59+
);
60+
61+
async function batchReadFeatureValues() {
62+
// Configure the featurestoreId resource
63+
const featurestore = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;
64+
const csvReadInstances = {
65+
gcsSource: {
66+
uris: [inputCsvFile],
67+
},
68+
};
69+
70+
const destination = {
71+
bigqueryDestination: {
72+
// # Output to BigQuery table created earlier
73+
outputUri: destinationTableUri,
74+
},
75+
};
76+
77+
const usersFeatureSelector = {
78+
idMatcher: {
79+
ids: [
80+
// features, use "*" if you want to select all features within this entity type
81+
'age',
82+
'gender',
83+
'liked_genres',
84+
],
85+
},
86+
};
87+
88+
const usersEntityTypeSpec = {
89+
// Read the 'age', 'gender' and 'liked_genres' features from the 'perm_users' entity
90+
entityTypeId: 'perm_users',
91+
featureSelector: usersFeatureSelector,
92+
};
93+
94+
const moviesFeatureSelector = {
95+
idMatcher: {
96+
ids: ['*'],
97+
},
98+
};
99+
100+
const moviesEntityTypeSpec = {
101+
// Read the all features from the 'perm_movies' entity
102+
entityTypeId: 'perm_movies',
103+
featureSelector: moviesFeatureSelector,
104+
};
105+
106+
const entityTypeSpecs = [usersEntityTypeSpec, moviesEntityTypeSpec];
107+
108+
// Construct request
109+
const request = {
110+
featurestore: featurestore,
111+
csvReadInstances: csvReadInstances,
112+
destination: destination,
113+
entityTypeSpecs: entityTypeSpecs,
114+
};
115+
116+
// Batch Read Feature Values Request
117+
const [operation] = await featurestoreServiceClient.batchReadFeatureValues(
118+
request,
119+
{timeout: Number(timeout)}
120+
);
121+
const [response] = await operation.promise();
122+
123+
console.log('Batch read feature values response');
124+
console.log('Raw response:');
125+
console.log(JSON.stringify(response, null, 2));
126+
}
127+
batchReadFeatureValues();
128+
// [END aiplatform_batch_read_feature_values_sample]
129+
}
130+
131+
process.on('unhandledRejection', err => {
132+
console.error(err.message);
133+
process.exitCode = 1;
134+
});
135+
136+
main(...process.argv.slice(2));
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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(customJobId, project, location = 'us-central1') {
20+
// [START aiplatform_get_custom_job_sample]
21+
/**
22+
* TODO(developer): Uncomment these variables before running the sample.\
23+
*/
24+
25+
// const customJobId = 'YOUR_CUSTOM_JOB_ID';
26+
// const project = 'YOUR_PROJECT_ID';
27+
// const location = 'YOUR_PROJECT_LOCATION';
28+
29+
// Imports the Google Cloud Job Service Client library
30+
const {JobServiceClient} = require('@google-cloud/aiplatform');
31+
32+
// Specifies the location of the api endpoint
33+
const clientOptions = {
34+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
35+
};
36+
37+
// Instantiates a client
38+
const jobServiceClient = new JobServiceClient(clientOptions);
39+
40+
async function getCustomJob() {
41+
// Configure the name resource
42+
const name = `projects/${project}/locations/${location}/customJobs/${customJobId}`;
43+
const request = {
44+
name,
45+
};
46+
47+
// Get custom job request
48+
const [response] = await jobServiceClient.getCustomJob(request);
49+
50+
console.log('Get custom job response');
51+
console.log(`\t${JSON.stringify(response)}`);
52+
}
53+
getCustomJob();
54+
// [END aiplatform_get_custom_job_sample]
55+
}
56+
57+
process.on('unhandledRejection', err => {
58+
console.error(err.message);
59+
process.exitCode = 1;
60+
});
61+
62+
main(...process.argv.slice(2));
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
async function main(tuningJobId, project, location = 'us-central1') {
20+
// [START aiplatform_get_hyperparameter_tuning_job_sample]
21+
/**
22+
* TODO(developer): Uncomment these variables before running the sample.\
23+
* (Not necessary if passing values as arguments)
24+
*/
25+
26+
// const tuningJobId = 'YOUR_TUNING_JOB_ID';
27+
// const project = 'YOUR_PROJECT_ID';
28+
// const location = 'YOUR_PROJECT_LOCATION';
29+
30+
// Imports the Google Cloud Model Service Client library
31+
const {JobServiceClient} = require('@google-cloud/aiplatform');
32+
33+
// Specifies the location of the api endpoint
34+
const clientOptions = {
35+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
36+
};
37+
38+
// Instantiates a client
39+
const jobServiceClient = new JobServiceClient(clientOptions);
40+
41+
async function getHyperparameterTuningJob() {
42+
// Configure the parent resource
43+
const name = jobServiceClient.hyperparameterTuningJobPath(
44+
project,
45+
location,
46+
tuningJobId
47+
);
48+
const request = {
49+
name,
50+
};
51+
// Get and print out a list of all the endpoints for this resource
52+
const [response] =
53+
await jobServiceClient.getHyperparameterTuningJob(request);
54+
55+
console.log('Get hyperparameter tuning job response');
56+
console.log(`\tDisplay name: ${response.displayName}`);
57+
console.log(`\tTuning job resource name: ${response.name}`);
58+
console.log(`\tJob status: ${response.state}`);
59+
}
60+
getHyperparameterTuningJob();
61+
// [END aiplatform_get_hyperparameter_tuning_job_sample]
62+
}
63+
64+
process.on('unhandledRejection', err => {
65+
console.error(err.message);
66+
process.exitCode = 1;
67+
});
68+
69+
main(...process.argv.slice(2));
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
async function main(modelId, evaluationId, project, location = 'us-central1') {
20+
// [START aiplatform_get_model_evaluation_video_action_recognition_sample]
21+
/**
22+
* TODO(developer): Uncomment these variables before running the sample
23+
* (not necessary if passing values as arguments). To obtain evaluationId,
24+
* instantiate the client and run the following the commands.
25+
*/
26+
// const parentName = `projects/${project}/locations/${location}/models/${modelId}`;
27+
// const evalRequest = {
28+
// parent: parentName
29+
// };
30+
// const [evalResponse] = await modelServiceClient.listModelEvaluations(evalRequest);
31+
// console.log(evalResponse);
32+
33+
// const modelId = 'YOUR_MODEL_ID';
34+
// const evaluationId = 'YOUR_EVALUATION_ID';
35+
// const project = 'YOUR_PROJECT_ID';
36+
// const location = 'YOUR_PROJECT_LOCATION';
37+
38+
// Imports the Google Cloud Model Service Client library
39+
const {ModelServiceClient} = require('@google-cloud/aiplatform');
40+
41+
// Specifies the location of the api endpoint
42+
const clientOptions = {
43+
apiEndpoint: 'us-central1-aiplatform.googleapis.com',
44+
};
45+
46+
// Instantiates a client
47+
const modelServiceClient = new ModelServiceClient(clientOptions);
48+
49+
async function getModelEvaluationVideoActionRecognition() {
50+
// Configure the parent resources
51+
const name = modelServiceClient.modelEvaluationPath(
52+
project,
53+
location,
54+
modelId,
55+
evaluationId
56+
);
57+
const request = {
58+
name,
59+
};
60+
61+
// Create get model evaluation request
62+
const [response] = await modelServiceClient.getModelEvaluation(request);
63+
64+
console.log('Get model evaluation video action recognition response');
65+
console.log(`\tName : ${response.name}`);
66+
console.log(`\tMetrics schema uri : ${response.metricsSchemaUri}`);
67+
console.log(`\tMetrics : ${JSON.stringify(response.metrics)}`);
68+
console.log(`\tCreate time : ${JSON.stringify(response.createTime)}`);
69+
console.log(`\tSlice dimensions : ${response.sliceDimensions}`);
70+
}
71+
getModelEvaluationVideoActionRecognition();
72+
// [END aiplatform_get_model_evaluation_video_action_recognition_sample]
73+
}
74+
75+
process.on('unhandledRejection', err => {
76+
console.error(err.message);
77+
process.exitCode = 1;
78+
});
79+
80+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)