Skip to content

Commit

Permalink
versions work!
Browse files Browse the repository at this point in the history
  • Loading branch information
rambleraptor committed Jul 17, 2019
1 parent 3505fe7 commit 25eefbc
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
8 changes: 8 additions & 0 deletions products/mlengine/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ datasources: !ruby/object:Overrides::ResourceOverrides
Model: !ruby/object:Overrides::Ansible::ResourceOverride
facts: !ruby/object:Provider::Ansible::FactsOverride
has_filters: false
Version: !ruby/object:Overrides::Ansible::ResourceOverride
facts: !ruby/object:Provider::Ansible::FactsOverride
has_filters: false
overrides: !ruby/object:Overrides::ResourceOverrides
Model: !ruby/object:Overrides::Ansible::ResourceOverride
transport: !ruby/object:Overrides::Ansible::Transport
decoder: decode_response
provider_helpers:
- products/mlengine/helpers/ansible/model_decoder.py
Version: !ruby/object:Overrides::Ansible::ResourceOverride
transport: !ruby/object:Overrides::Ansible::Transport
decoder: decode_response
provider_helpers:
- products/mlengine/helpers/ansible/model_decoder.py
files: !ruby/object:Provider::Config::Files
resource:
<%= lines(indent(compile('provider/ansible/resource~compile.yaml'), 4)) -%>
34 changes: 34 additions & 0 deletions products/mlengine/ansible_version_added.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
:facts:
:Model:
:version_added: '2.9'
:Version:
:version_added: '2.9'
:regular:
:Model:
:version_added: '2.9'
Expand All @@ -21,3 +23,35 @@
:version_added: '2.9'
:labels:
:version_added: '2.9'
:Version:
:version_added: '2.9'
:name:
:version_added: '2.9'
:description:
:version_added: '2.9'
:deploymentUri:
:version_added: '2.9'
:runtimeVersion:
:version_added: '2.9'
:machineType:
:version_added: '2.9'
:labels:
:version_added: '2.9'
:framework:
:version_added: '2.9'
:pythonVersion:
:version_added: '2.9'
:serviceAccount:
:version_added: '2.9'
:autoScaling:
:version_added: '2.9'
:minNodes:
:version_added: '2.9'
:manualScaling:
:version_added: '2.9'
:nodes:
:version_added: '2.9'
:predictionClass:
:version_added: '2.9'
:model:
:version_added: '2.9'
38 changes: 37 additions & 1 deletion products/mlengine/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@ objects:
self_link: projects/{{project}}/models/{{name}}
# This resources is not updatable (outside of versions, which is a version-level method)
input: true
async: !ruby/object:Api::Async
actions: ['delete']
operation: !ruby/object:Api::Async::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::Async::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::Async::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::Async::Error
path: 'error'
message: 'message'
description: |
Represents a machine learning solution.
Expand Down Expand Up @@ -81,12 +99,30 @@ objects:
description: |
Each version is a trained model deployed in the cloud, ready to handle
prediction requests. A model can have multiple versions
async: !ruby/object:Api::Async
operation: !ruby/object:Api::Async::Operation
path: 'name'
base_url: '{{op_id}}'
wait_ms: 1000
result: !ruby/object:Api::Async::Result
path: 'response'
resource_inside_response: true
status: !ruby/object:Api::Async::Status
path: 'done'
complete: True
allowed:
- True
- False
error: !ruby/object:Api::Async::Error
path: 'error'
message: 'message'
parameters:
- !ruby/object:Api::Type::ResourceRef
name: 'model'
description: The model that this version belongs to
resource: Model
imports: name
required: true
properties:
- !ruby/object:Api::Type::String
name: 'name'
Expand Down Expand Up @@ -115,7 +151,7 @@ objects:
- !ruby/object:Api::Type::Time
name: 'lastUseTime'
description: The time the version was last used for prediction.
output: ture
output: true
- !ruby/object:Api::Type::String
name: 'runtimeVersion'
description: The AI Platform runtime version to use for this deployment
Expand Down
41 changes: 41 additions & 0 deletions products/mlengine/examples/ansible/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2017 Google Inc.
# 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.
--- !ruby/object:Provider::Ansible::Example
task: !ruby/object:Provider::Ansible::Task
name: gcp_mlengine_version
code:
# ML Engine doesn't like dashes, which ansible's test name
# generator uses.
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
deployment_uri: gs://ansible-cloudml-bucket/
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>

dependencies:
- !ruby/object:Provider::Ansible::Task
name: gcp_mlengine_model
code:
name: <%= dependency_name('model', 'version').gsub('-', '_') %>
description: 'My model'
regions:
- 'us-central1'
online_prediction_logging: true
online_prediction_console_logging: true
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
register: model
3 changes: 2 additions & 1 deletion products/mlengine/helpers/ansible/model_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# Short names are given (and expected) by the API
# but are returned as full names.
def decode_response(response, module):
response['name'] = response['name'].split('/')[-1]
if 'name' in response and 'metadata' not in response:
response['name'] = response['name'].split('/')[-1]
return response

0 comments on commit 25eefbc

Please sign in to comment.