Skip to content

Setting up Python SDK for Personalizer #26296

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

Closed
wants to merge 17 commits into from

Conversation

sharathmalladi
Copy link
Contributor

Description

Python SDK for Azure Cognitive Services Personalizer.
Swagger link: TBD

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run python - [service] - ci

@sharathmalladi sharathmalladi marked this pull request as ready for review September 27, 2022 00:30
@kristapratico kristapratico self-requested a review September 27, 2022 00:37
Copy link
Member

@kristapratico kristapratico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the tests.yml is moved up a directory, we can run /azp run prepare-pipelines to create the CI pipeline for your library.

authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential, **kwargs)),
**kwargs
)
self._default_language = kwargs.pop("default_language", None)
Copy link
Member

@kristapratico kristapratico Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_language is specific to the question answering client library, you can remove it. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

from azure.core.pipeline.policies import AzureKeyCredentialPolicy, AsyncBearerTokenCredentialPolicy
from ._client import PersonalizerClient as PersonalizerClientGenerated

__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
Copy link
Member

@kristapratico kristapratico Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a duplicate, it's defined on L83 #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks!

DESCRIPTION:
This sample demos sending a rank and reward call to personalizer for multi-slot configuration.
USAGE: python multi_slot_rank_actions_and_reward_events_async.py
"""
Copy link
Member

@kristapratico kristapratico Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should describe the environment variables needed to run this sample under the comment header. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

return cast(Iterator[bytes], deserialized)

@distributed_trace
def import_method(self, body: IO, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements
Copy link
Member

@kristapratico kristapratico Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import is a keyword in Python so it looks like the generator is appending "method" to the method name. I missed this on the first review but we should probably give this a better name. Can you rename it through the swagger transform? Should look something like:

directive:
  - rename-operation:
      from: Model_Import
      to: Model_ImportModel

This will rename it to import_model (or whatever it should be named) #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. Fixed.

ServiceDirectory: personalizer
MatrixReplace:
- TestSamples=.*/true
Clouds: Canary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to run tests in Canary (it doesn't look like we do in the other languages).

Suggested change
Clouds: Canary

@@ -0,0 +1,18 @@
trigger: none
Copy link
Member

@kristapratico kristapratico Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be up one level: sdk/personalizer/tests.yml #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@sharathmalladi
Copy link
Contributor Author

/azp run prepare-pipelines

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sharathmalladi
Copy link
Contributor Author

Added the comment in github pr.


In reply to: 1133773653

@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-ai-personalizer

@sharathmalladi
Copy link
Contributor Author

All comments have been addressed. This PR is being replaced with a different PR: #26719

@sharathmalladi
Copy link
Contributor Author

Abandoning this PR as it had some leaked apikeys (the keys were rotated and so the risk is mitigated). This PR is superceded by this one: #26719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants