This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds enhancements to library (#22)
* feat: adds enhancements to library * chore: changes to synth.py * fix: broken pack n' play test * fix: add enhanced types to ts compiler * fix: project enabled * fix: adds docstrings to toValue(), fromValue() functions * fix: removing any * fix: edits to synth.py per reviewer * fix: add more test coverage * chore: added comment about conversion interface Co-authored-by: Sofia Leon <sofialeon@google.com>
- Loading branch information
Showing
25 changed files
with
1,274 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ system-test/*key.json | |
.DS_Store | ||
package-lock.json | ||
__pycache__ | ||
.vscode |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
samples/create-training-pipeline-image-classification.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
function main( | ||
datasetId, | ||
modelDisplayName, | ||
trainingPipelineDisplayName, | ||
project, | ||
location = 'us-central1' | ||
) { | ||
// [START aiplatform_create_training_pipeline_image_classification] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
* (Not necessary if passing values as arguments) | ||
*/ | ||
/* | ||
const datasetId = 'YOUR DATASET'; | ||
const modelDisplayName = 'NEW MODEL NAME; | ||
const trainingPipelineDisplayName = 'NAME FOR TRAINING PIPELINE'; | ||
const project = 'YOUR PROJECT ID'; | ||
const location = 'us-central1'; | ||
*/ | ||
// Imports the Google Cloud Pipeline Service Client library | ||
const aiplatform = require('@google-cloud/aiplatform'); | ||
|
||
const { | ||
definition, | ||
} = aiplatform.protos.google.cloud.aiplatform.v1beta1.schema.trainingjob; | ||
const ModelType = definition.AutoMlImageClassificationInputs.ModelType; | ||
|
||
// Specifies the location of the api endpoint | ||
const clientOptions = { | ||
apiEndpoint: 'us-central1-aiplatform.googleapis.com', | ||
}; | ||
|
||
// Instantiates a client | ||
const pipelineServiceClient = new aiplatform.PipelineServiceClient( | ||
clientOptions | ||
); | ||
|
||
async function createTrainingPipelineImageClassification() { | ||
// Configure the parent resource | ||
const parent = `projects/${project}/locations/${location}`; | ||
|
||
// Values should match the input expected by your model. | ||
const trainingTaskInputsMessage = new definition.AutoMlImageClassificationInputs( | ||
{ | ||
multiLabel: true, | ||
modelType: ModelType.CLOUD, | ||
budgetMilliNodeHours: 8000, | ||
disableEarlyStopping: false, | ||
} | ||
); | ||
|
||
const trainingTaskInputs = trainingTaskInputsMessage.toValue(); | ||
|
||
const trainingTaskDefinition = | ||
'gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_image_classification_1.0.0.yaml'; | ||
|
||
const modelToUpload = {displayName: modelDisplayName}; | ||
const inputDataConfig = {datasetId: datasetId}; | ||
const trainingPipeline = { | ||
displayName: trainingPipelineDisplayName, | ||
trainingTaskDefinition, | ||
trainingTaskInputs, | ||
inputDataConfig: inputDataConfig, | ||
modelToUpload: modelToUpload, | ||
}; | ||
const request = { | ||
parent, | ||
trainingPipeline, | ||
}; | ||
|
||
// Create training pipeline request | ||
const [response] = await pipelineServiceClient.createTrainingPipeline( | ||
request | ||
); | ||
|
||
console.log('Create training pipeline image classification response'); | ||
console.log(`\tName : ${response.name}`); | ||
console.log(`\tDisplay Name : ${response.displayName}`); | ||
console.log( | ||
`\tTraining task definition : ${response.trainingTaskDefinition}` | ||
); | ||
console.log( | ||
`\tTraining task inputs : \ | ||
${JSON.stringify(response.trainingTaskInputs)}` | ||
); | ||
console.log( | ||
`\tTraining task metadata : \ | ||
${JSON.stringify(response.trainingTaskMetadata)}` | ||
); | ||
console.log(`\tState ; ${response.state}`); | ||
console.log(`\tCreate time : ${JSON.stringify(response.createTime)}`); | ||
console.log(`\tStart time : ${JSON.stringify(response.startTime)}`); | ||
console.log(`\tEnd time : ${JSON.stringify(response.endTime)}`); | ||
console.log(`\tUpdate time : ${JSON.stringify(response.updateTime)}`); | ||
console.log(`\tLabels : ${JSON.stringify(response.labels)}`); | ||
|
||
const error = response.error; | ||
console.log('\tError'); | ||
if (error === null) { | ||
console.log('\t\tCode : {}'); | ||
console.log('\t\tMessage : {}'); | ||
} else { | ||
console.log(`\t\tCode : ${error.code}`); | ||
console.log(`\t\tMessage : ${error.message}`); | ||
} | ||
} | ||
|
||
createTrainingPipelineImageClassification(); | ||
// [END aiplatform_create_training_pipeline_image_classification] | ||
} | ||
|
||
process.on('unhandledRejection', err => { | ||
console.error(err.message); | ||
process.exitCode = 1; | ||
}); | ||
|
||
main(...process.argv.slice(2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright 2020, Google, LLC. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
function main(projectId, location = 'us-central1') { | ||
// [START aiplatform_list_endpoints] | ||
/** | ||
* TODO(developer): Uncomment these variables before running the sample. | ||
*/ | ||
// const projectId = 'YOUR_PROJECT_ID'; | ||
// const location = 'YOUR_PROJECT_LOCATION'; | ||
|
||
const {EndpointServiceClient} = require('@google-cloud/aiplatform'); | ||
|
||
// Specifies the location of the api endpoint | ||
const clientOptions = { | ||
apiEndpoint: 'us-central1-aiplatform.googleapis.com', | ||
}; | ||
const client = new EndpointServiceClient(clientOptions); | ||
|
||
async function listEndpoints() { | ||
// Configure the parent resource | ||
const parent = `projects/${projectId}/locations/${location}`; | ||
const request = { | ||
parent, | ||
}; | ||
|
||
// Get and print out a list of all the endpoints for this resource | ||
const [result] = await client.listEndpoints(request); | ||
for (const endpoint of result) { | ||
console.log(`\nEndpoint name: ${endpoint.name}`); | ||
console.log(`Display name: ${endpoint.displayName}`); | ||
if (endpoint.deployedModels[0]) { | ||
console.log( | ||
`First deployed model: ${endpoint.deployedModels[0].model}` | ||
); | ||
} | ||
} | ||
} | ||
|
||
listEndpoints(); | ||
// [END aiplatform_list_endpoints] | ||
} | ||
|
||
main(...process.argv.slice(2)).catch(err => { | ||
console.error(err); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.