Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model copy does not accept project as an argument #4555

Open
racinmat opened this issue Oct 17, 2024 · 1 comment
Open

Model copy does not accept project as an argument #4555

racinmat opened this issue Oct 17, 2024 · 1 comment
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API.

Comments

@racinmat
Copy link

Copying model does not let you specify the model project, takes it from gcloud config.

Environment details

  • OS type and version:
  • Python version: Python 3.10.12
  • pip version: pip 23.3 from C:\Users\E10270\.conda\envs\wanna-deploy-py310\lib\site-packages\pip (python 3.10)
  • google-cloud-aiplatform version:
Name: google-cloud-aiplatform
Version: 1.63.0
Summary: Vertex AI API client library
Home-page: https://github.com/googleapis/python-aiplatform
Author: Google LLC
Author-email: [email protected]
License: Apache 2.0
Location: c:\users\e10270\.conda\envs\wanna-deploy-py310\lib\site-packages
Requires: docstring-parser, google-api-core, google-auth, google-cloud-bigquery, google-cloud-resource-manager, google-cloud-storage, packaging, proto-plus, protobuf, pydantic, shapely
Required-by: 

it does not matter as the issue happens in the newest version too.

Steps to reproduce

  1. run gcloud config set project <projectA>
  2. get model from project B
  3. try to copy it to different region in project B

Code example

from google.cloud.aiplatform import Model

model = Model(model_name='<my model>', project='<project b>, location='europe-west1')
model.copy(destination_location='europe-west4')

Stack trace

Traceback (most recent call last):
  File "C:\Users\E10270\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers\pydev\pydevconsole.py", line 364, in runcode
    coro = func()
  File "<input>", line 1, in <module>
  File "C:\Users\E10270\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
    pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
  File "C:\Users\E10270\AppData\Local\Programs\PyCharm Professional\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:\Projects\wanna-deploy\my_scripts\copy_model_test.py", line 4, in <module>
    model.copy(destination_location='europe-west4')
  File "C:\Users\E10270\.conda\envs\wanna-deploy-py310\lib\site-packages\google\cloud\aiplatform\models.py", line 6554, in copy
    model_copy_response = lro.result(timeout=None)
  File "C:\Users\E10270\.conda\envs\wanna-deploy-py310\lib\site-packages\google\api_core\future\polling.py", line 261, in result
    raise self._exception
google.api_core.exceptions.PermissionDenied: 403 PERMISSION_DENIED 7: PERMISSION_DENIED```

#### Root cause
https://github.com/googleapis/python-aiplatform/blob/v1.70.0/google/cloud/aiplatform/models.py#L6667-L6673 does not accept the project, and although the model contains the correct project, it pulls the project from global initializer here: https://github.com/googleapis/python-aiplatform/blob/v1.70.0/google/cloud/aiplatform/models.py#L6725-L6727 
and this causes the problem and requires people to switch the project in `gcloud`.
@product-auto-label product-auto-label bot added the api: vertex-ai Issues related to the googleapis/python-aiplatform API. label Oct 17, 2024
@sasha-gitg
Copy link
Member

Can you work around this using aiplatform.init(project='<project b>')?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API.
Projects
None yet
Development

No branches or pull requests

2 participants