Skip to content

[Python] AttributeError: 'CognitiveServicesManagementClient' object has no attribute 'deployments' #4068

Closed

Description

Link to sample

https://learn.microsoft.com/en-us/rest/api/cognitiveservices/accountmanagement/deployments/list?view=rest-cognitiveservices-accountmanagement-2023-05-01&tabs=Python

Library name and version

azure-mgmt-cognitiveservices==13.5.0

Language of the Sample

  • C#/.NET
  • Java
  • JavaScript/TypedScript
  • Python
  • Golang
  • Other - Please specify in Issue details field

Sample Issue Type

  • Sample not working
  • Sample missing
  • Do not understand sample

Issue details

This part of the code:

deployment = cognitiveservices_client.deployments.begin_create_or_update(
    resource_group_name = resource_group_name,
    account_name = account_name,
    deployment_name = "chat",
    deployment = {
        "properties": {"model": {"format": "OpenAI", "name": "ada", "version": "1"}},
        "sku": {"capacity": 1, "name": "Standard"},
    },
)

results in this error:

AttributeError: 'CognitiveServicesManagementClient' object has no attribute 'deployments'

Expected behavior

I expect this code to create a deployment in the Azure OpenAI account. Creating deployments manually in the Azure Portal by using Azure AI Studio works without any problems.

Actual behavior

Not creating any deployments within the OpenAI account.

Reproduction Steps

Create an account like this:

from azure.mgmt.cognitiveservices import CognitiveServicesManagementClient

cognitiveservices_client = CognitiveServicesManagementClient(
    credential=credential,
    subscription_id=subscription_id
)

account_name = "anyname12345"

account = cognitiveservices_client.accounts.create(
    resource_group_name,
    account_name,
    {
      "location": "West Europe",
      "kind": "OpenAI",
      "sku": {
        "name": "S0"
      },
      "identity": {
        "type": "SystemAssigned"
      }
    }
)
print("Created OpenAI account:\n{}".format(account))

This should work and should output something like this:

Created OpenAI account:
{'additional_properties': {}, 'etag': '"200035e7-0000-0d00-0000-65a30a020000"', 'id': '/subscriptions/<subscription_id>/resourceGroups/<resource_group_name>/providers/Microsoft.CognitiveServices/accounts/<account_name>', 'kind': 'OpenAI', 'location': 'West Europe', 'name': '<account_name>', 'properties': <azure.mgmt.cognitiveservices.models._models_py3.CognitiveServicesAccountProperties object at 0x7fc63c41fc10>, 'sku': <azure.mgmt.cognitiveservices.models._models_py3.Sku object at 0x7fc63c41fdf0>, 'tags': None, 'type': 'Microsoft.CognitiveServices/accounts', 'identity': <azure.mgmt.cognitiveservices.models._models_py3.Identity object at 0x7fc63c41f2b0>}

Now try to get a list of deployments or create a deployment with that same cognitiveservices_client object:

    response = cognitiveservices_client.deployments.list(
        resource_group_name=resource_group_name,
        account_name=account_name
    )

or

deployment = cognitiveservices_client.deployments.begin_create_or_update(
    resource_group_name = resource_group_name,
    account_name = account_name,
    deployment_name = "chat",
    deployment = {
        "properties": {"model": {"format": "OpenAI", "name": "ada", "version": "1"}},
        "sku": {"capacity": 1, "name": "Standard"}
    }
)
print(deployment)

This should cause an error.

Environment

Authenticating as follows:

!az login --tenant $AZURE_TENANT --use-device-code --output none
from azure.identity import AzureCliCredential
credential = AzureCliCredential()

Using the following Python packages:
azure-mgmt-cognitiveservices==13.5.0

Python version: 3.8.18
JupyterLab version 3.4.4

Similar

  1. bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions