azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Unable to attach cognitive service using python SDK

Open akazlow opened this issue 2 years ago • 3 comments

  • Package Name: Azure Cognitive Search
  • Package Version: 11.2.1
  • Operating System: Windows
  • Python Version: 3.7

Describe the bug When creating an azure search skill set through the Python SDK, I am unable to attach an azure cognitive service. This causes entities populated by the skill set to not be populated. The CognitiveServiesAccount model that is to be used by the searchIndexerSkillset constructor does not seem to exist when I try to import it.

The documentation here says the cognitive services account object is a required parameter, but I am unable to add it and no errors are thrown when I create the skillset without it.

To Reproduce When creating a skillset, the CognitiveServicesAccount parameter is not required and a skillset is successfully created without it. This directly contradicts the online documentation for the searchIndexerSkillset constructor which states the CognitiveServicesAccount parameter is required.

CognitiveServicesAccount Required CognitiveServicesAccount Not Required

I am also unable to import the CognitiveServicesAccount object from the Python SDK, so it seems it is not possible to pass it in and specify what account I would like to attach to.

Module Not Found

When I create the skillset without it, there are no errors and it appears as if the skillset is successfully created.

Successful Creation

However, when I inspect the skillset in the portal, the cognitive services account is null so the skillset will not work. This is causing issues with programmatically deploying a working solution using Python.

Null Cognitive Service

Expected behavior When creating a skillset, I expect to be able to create a CognitiveServicesAccount object and pass it into the searchIndexerSkillset constructor. I also expect this parameter to be required and an error will be thrown if I do not pass in the CognitiveServicesAccount object. When I inspect the skillset in the portal I expect the correct cognitive service to be attached to the skillset.

Screenshots ai-openhack-cognitive-service-null ai-openhack-no-errors ai-openhack-no-module-cognitiveServicesAccount ai-openhack-param-not-required ai-openhack-param-required

Additional context To work around the issue stated above, the REST API can be used to update the skillset created through the Python SDK and attach a cognitive service account to it. The developer can also attach one through the portal.

The Python SDK documentation should be updated to state this issue and any workarounds. The issue should also be logged and eventually fixed so users can deploy a working solution using Python.

akazlow avatar Apr 07 '22 13:04 akazlow

Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Cognitive Services:0.49177337,Search:0.13391021,Docs:0.08864225'

azure-sdk avatar Apr 07 '22 13:04 azure-sdk

Hi @akazlow , thanks for the feedback. We'll take a look at this and get back to you asap.

kashifkhan avatar Apr 07 '22 18:04 kashifkhan

@akazlow You can use azure.search.documents.indexes.models.CognitiveServicesAccountKey to set the argument cognitive_services_account of SearchIndexerSkillset to attach the cognitive search.

LeoXLiu-DS avatar Oct 08 '22 21:10 LeoXLiu-DS

Hi @akazlow, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

ghost avatar Nov 29 '22 04:11 ghost