GoogleCloudPlatform / vertex-ai-samples

Notebooks, code samples, sample apps, and other resources that demonstrate how to use, develop and manage machine learning and generative AI workflows using Google Cloud Vertex AI.
https://cloud.google.com/vertex-ai
Apache License 2.0
1.62k stars 802 forks source link

Using model.resource_name and endpoint.resource_name to instantiate the model and endpoint resources #126

Closed candicehou07 closed 2 years ago

candicehou07 commented 2 years ago

Expected Behavior

In the notebooks/community/managed_notebooks/fraud_detection/fraud-detection-model.ipynb we need to Instantiate the resources using the resource names.

model = aiplatform.Model(model_name=model.resource_name) endpoint = aiplatform.Endpoint(endpoint_name=endpoint.resource_name)

Actual Behavior

Failed to instantiate the resources using the displayed_names

Steps to Reproduce the Problem

  1. Create a Managed-notebook in Vertex AI Workbench
  2. open the terminal and git clone the repo
  3. go to notebooks/community/managed_notebooks/fraud_detection/fraud-detection-model.ipynb
  4. run the cells until cell of "Deploy the model to the created Endpoint"
  5. run the current cell

Specifications

Screen Shot 2021-11-03 at 5 40 37 PM

kweinmeister commented 2 years ago

Hi, a few questions to troubleshoot this:

mattcarrollcode commented 2 years ago

@aarondietz234 Can you take a look at this?

candicehou07 commented 2 years ago

Hi, to answer the questions:


_InactiveRpcError Traceback (most recent call last) /opt/conda/lib/python3.7/site-packages/google/api_core/grpc_helpers.py in error_remappedcallable(*args, **kwargs) 65 try: ---> 66 return callable(*args, **kwargs) 67 except grpc.RpcError as exc:

/opt/conda/lib/python3.7/site-packages/grpc/_channel.py in call(self, request, timeout, metadata, credentials, wait_for_ready, compression) 945 wait_for_ready, compression) --> 946 return _end_unary_response_blocking(state, call, False, None) 947

/opt/conda/lib/python3.7/site-packages/grpc/_channel.py in _end_unary_response_blocking(state, call, with_call, deadline) 848 else: --> 849 raise _InactiveRpcError(state) 850

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "List of found errors: 1.Field: name; Message: Invalid Model resource name. " debug_error_string = "{"created":"@1636406161.921552593","description":"Error received from peer ipv4:142.250.128.95:443","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"List of found errors:\t1.Field: name; Message: Invalid Model resource name.\t","grpc_status":3}"

The above exception was the direct cause of the following exception:

InvalidArgument Traceback (most recent call last) /tmp/ipykernel_1/2157564676.py in 1 # instantiate the model and endpoint resources ----> 2 model = aiplatform.Model(model_name=MODEL_DISPLAY_NAME) 3 endpoint = aiplatform.Endpoint(endpoint_name=ENDPOINT_DISPLAY_NAME) 4 5 # deploy the model to the endpoint

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/models.py in init(self, model_name, project, location, credentials) 1394 resource_name=model_name, 1395 ) -> 1396 self._gca_resource = self._get_gca_resource(resource_name=model_name) 1397 1398 # TODO(b/170979552) Add support for predict schemata

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform/base.py in _get_gca_resource(self, resource_name) 531 ) 532 --> 533 return getattr(self.api_client, self._getter_method)(name=resource_name) 534 535 def _sync_gca_resource(self):

/opt/conda/lib/python3.7/site-packages/google/cloud/aiplatform_v1/services/model_service/client.py in get_model(self, request, name, retry, timeout, metadata) 589 590 # Send the request. --> 591 response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) 592 593 # Done; return the response.

/opt/conda/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py in call(self, timeout, retry, *args, *kwargs) 140 kwargs["metadata"] = metadata 141 --> 142 return wrapped_func(args, **kwargs) 143 144

/opt/conda/lib/python3.7/site-packages/google/api_core/grpc_helpers.py in error_remappedcallable(*args, **kwargs) 66 return callable(*args, **kwargs) 67 except grpc.RpcError as exc: ---> 68 raise exceptions.from_grpc_error(exc) from exc 69 70 return error_remapped_callable

InvalidArgument: 400 List of found errors: 1.Field: name; Message: Invalid Model resource name.

I tried to run with resource_name and it worked. I hope this helps with troubleshooting!