Spaces:
Sleeping
Sleeping
File size: 881 Bytes
eba303d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
from google.cloud import aiplatform_v1
from google.oauth2 import service_account
def list_models(project_id, location, credentials_path):
credentials = service_account.Credentials.from_service_account_file(credentials_path)
client = aiplatform_v1.ModelServiceClient(credentials=credentials)
parent = f"projects/{project_id}/locations/{location}"
response = client.list_models(parent=parent)
models = list(response)
if not models:
print("No models found.")
else:
for model in models:
print(f"Model display name: {model.display_name}")
print(f"Model resource name: {model.name}")
if __name__ == "__main__":
project_id = "igneous-spanner-441609-h6"
location = "us-central1"
credentials_path = "secrets/GOOGLE_VERTEX_AI_KEY_SYTOSS-441609.json"
list_models(project_id, location, credentials_path)
|