| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
- name: Main test block |
| 12 |
block: |
| 13 |
- name: Create test network |
| 14 |
google.cloud.gcp_compute_network: |
| 15 |
name: "{{ resource_name }}" |
| 16 |
state: present |
| 17 |
auto_create_subnetworks: true |
| 18 |
project: "{{ gcp_project }}" |
| 19 |
auth_kind: "{{ gcp_cred_kind }}" |
| 20 |
service_account_file: "{{ gcp_cred_file }}" |
| 21 |
register: _network |
| 22 |
|
| 23 |
- name: Test case |
| 24 |
block: |
| 25 |
- name: Create storage bucket |
| 26 |
google.cloud.gcp_storage_bucket: |
| 27 |
name: "{{ resource_name }}" |
| 28 |
state: present |
| 29 |
location: us-central1 |
| 30 |
project: "{{ gcp_project }}" |
| 31 |
auth_kind: "{{ gcp_cred_kind }}" |
| 32 |
service_account_file: "{{ gcp_cred_file }}" |
| 33 |
|
| 34 |
- name: Create delta configs |
| 35 |
ansible.builtin.copy: |
| 36 |
dest: "/tmp/{{ resource_name }}-{{ item }}" |
| 37 |
mode: "0644" |
| 38 |
content: | |
| 39 |
{"id": "42", "embedding": [0.5, 1.0], "restricts": [{"namespace": "class", "allow": ["cat", "pet"]},{"namespace": "category", "allow": ["feline"]}]} |
| 40 |
{"id": "43", "embedding": [0.6, 1.0], "restricts": [{"namespace": "class", "allow": ["dog", "pet"]},{"namespace": "category", "allow": ["canine"]}]} |
| 41 |
loop: |
| 42 |
- v1 |
| 43 |
- v2 |
| 44 |
|
| 45 |
- name: Upload delta configs to bucket |
| 46 |
google.cloud.gcp_storage_object: |
| 47 |
action: upload |
| 48 |
bucket: "{{ resource_name }}" |
| 49 |
src: "/tmp/{{ resource_name }}-{{ item }}" |
| 50 |
dest: "contents-{{ item }}/data.json" |
| 51 |
project: "{{ gcp_project }}" |
| 52 |
auth_kind: "{{ gcp_cred_kind }}" |
| 53 |
service_account_file: "{{ gcp_cred_file }}" |
| 54 |
loop: |
| 55 |
- v1 |
| 56 |
- v2 |
| 57 |
|
| 58 |
- name: Create Index |
| 59 |
google.cloud.gcp_vertexai_index: |
| 60 |
state: present |
| 61 |
display_name: "{{ resource_name }}" |
| 62 |
region: us-central1 |
| 63 |
metadata: |
| 64 |
contents_delta_uri: "gs://{{ resource_name }}/contents-v1" |
| 65 |
config: |
| 66 |
dimensions: 2 |
| 67 |
approximate_neighbors_count: 150 |
| 68 |
shard_size: SHARD_SIZE_SMALL |
| 69 |
distance_measure_type: DOT_PRODUCT_DISTANCE |
| 70 |
algorithm_config: |
| 71 |
tree_ah_config: |
| 72 |
leaf_node_embedding_count: 500 |
| 73 |
leaf_nodes_to_search_percent: 7 |
| 74 |
index_update_method: BATCH_UPDATE |
| 75 |
project: "{{ gcp_project }}" |
| 76 |
auth_kind: "{{ gcp_cred_kind }}" |
| 77 |
service_account_file: "{{ gcp_cred_file }}" |
| 78 |
register: _myidx |
| 79 |
|
| 80 |
- name: Run assertions |
| 81 |
ansible.builtin.assert: |
| 82 |
that: |
| 83 |
- _myidx.changed == true |
| 84 |
|
| 85 |
- name: Attempt to update description and metadata.contentsDeltaUri Index |
| 86 |
google.cloud.gcp_vertexai_index: |
| 87 |
state: present |
| 88 |
display_name: "{{ resource_name }}" |
| 89 |
description: "Updated description" |
| 90 |
region: us-central1 |
| 91 |
metadata: |
| 92 |
contents_delta_uri: "gs://{{ resource_name }}/contents-v2" |
| 93 |
config: |
| 94 |
dimensions: 2 |
| 95 |
project: "{{ gcp_project }}" |
| 96 |
auth_kind: "{{ gcp_cred_kind }}" |
| 97 |
service_account_file: "{{ gcp_cred_file }}" |
| 98 |
register: _myidx |
| 99 |
ignore_errors: true |
| 100 |
|
| 101 |
- name: Previous task should have failed |
| 102 |
ansible.builtin.assert: |
| 103 |
that: |
| 104 |
- _myidx.failed == true |
| 105 |
|
| 106 |
- name: Update Index description only |
| 107 |
google.cloud.gcp_vertexai_index: |
| 108 |
state: present |
| 109 |
display_name: "{{ resource_name }}" |
| 110 |
description: "Updated description" |
| 111 |
metadata: |
| 112 |
config: |
| 113 |
dimensions: 2 |
| 114 |
region: us-central1 |
| 115 |
project: "{{ gcp_project }}" |
| 116 |
auth_kind: "{{ gcp_cred_kind }}" |
| 117 |
service_account_file: "{{ gcp_cred_file }}" |
| 118 |
register: _myidx |
| 119 |
|
| 120 |
- name: Run assertions |
| 121 |
ansible.builtin.assert: |
| 122 |
that: |
| 123 |
- _myidx.changed == true |
| 124 |
- _myidx.description == "Updated description" |
| 125 |
|
| 126 |
- name: Update Index metadata only |
| 127 |
google.cloud.gcp_vertexai_index: |
| 128 |
state: present |
| 129 |
display_name: "{{ resource_name }}" |
| 130 |
region: us-central1 |
| 131 |
metadata: |
| 132 |
contents_delta_uri: "gs://{{ resource_name }}/contents-v2" |
| 133 |
config: |
| 134 |
dimensions: 2 |
| 135 |
project: "{{ gcp_project }}" |
| 136 |
auth_kind: "{{ gcp_cred_kind }}" |
| 137 |
service_account_file: "{{ gcp_cred_file }}" |
| 138 |
register: _myidx |
| 139 |
|
| 140 |
- name: Run assertions |
| 141 |
ansible.builtin.assert: |
| 142 |
that: |
| 143 |
- _myidx.changed == true |
| 144 |
|
| 145 |
- name: Delete Index |
| 146 |
google.cloud.gcp_vertexai_index: |
| 147 |
state: absent |
| 148 |
display_name: "{{ resource_name }}" |
| 149 |
metadata: |
| 150 |
config: |
| 151 |
dimensions: 2 |
| 152 |
region: us-central1 |
| 153 |
project: "{{ gcp_project }}" |
| 154 |
auth_kind: "{{ gcp_cred_kind }}" |
| 155 |
service_account_file: "{{ gcp_cred_file }}" |
| 156 |
|
| 157 |
always: |
| 158 |
- name: Delete delta configs |
| 159 |
ansible.builtin.file: |
| 160 |
path: "/tmp/{{ resource_name }}-{{ item }}" |
| 161 |
state: absent |
| 162 |
loop: |
| 163 |
- v1 |
| 164 |
- v2 |
| 165 |
|
| 166 |
- name: Empty bucket |
| 167 |
google.cloud.gcp_storage_object: |
| 168 |
action: delete |
| 169 |
bucket: "{{ resource_name }}" |
| 170 |
src: "contents-{{ item }}/data.json" |
| 171 |
project: "{{ gcp_project }}" |
| 172 |
auth_kind: "{{ gcp_cred_kind }}" |
| 173 |
service_account_file: "{{ gcp_cred_file }}" |
| 174 |
loop: |
| 175 |
- v1 |
| 176 |
- v2 |
| 177 |
|
| 178 |
- name: Destroy storage bucket |
| 179 |
google.cloud.gcp_storage_bucket: |
| 180 |
name: "{{ resource_name }}" |
| 181 |
state: absent |
| 182 |
location: us-central1 |
| 183 |
project: "{{ gcp_project }}" |
| 184 |
auth_kind: "{{ gcp_cred_kind }}" |
| 185 |
service_account_file: "{{ gcp_cred_file }}" |
| 186 |
|
| 187 |
always: |
| 188 |
- name: Destroy test network |
| 189 |
google.cloud.gcp_compute_network: |
| 190 |
name: "{{ resource_name }}" |
| 191 |
state: absent |
| 192 |
project: "{{ gcp_project }}" |
| 193 |
auth_kind: "{{ gcp_cred_kind }}" |
| 194 |
service_account_file: "{{ gcp_cred_file }}" |