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

New Resource: azurerm_cognitive_rai_blocklist #28043

Conversation

feliperezende-barbosa
Copy link
Contributor

@feliperezende-barbosa feliperezende-barbosa commented Nov 18, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave comments along the lines of "+1", "me too" or "any updates", they generate extra noise for PR followers and do not help prioritize for review

Description

New resource for using a blocklist in OpenAI reference

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
==> Checking that acceptance test packages are used...
TF_ACC=1 go test -v ./internal/services/cognitive -run=TestAccCognitiveRaiBlocklistSequential -timeout 60m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccCognitiveRaiBlocklistSequential
=== RUN   TestAccCognitiveRaiBlocklistSequential/raiBlocklist
=== RUN   TestAccCognitiveRaiBlocklistSequential/raiBlocklist/basic
=== RUN   TestAccCognitiveRaiBlocklistSequential/raiBlocklist/requiresImport
=== RUN   TestAccCognitiveRaiBlocklistSequential/raiBlocklist/complete
=== RUN   TestAccCognitiveRaiBlocklistSequential/raiBlocklist/update
--- PASS: TestAccCognitiveRaiBlocklistSequential (427.16s)
    --- PASS: TestAccCognitiveRaiBlocklistSequential/raiBlocklist (427.16s)
        --- PASS: TestAccCognitiveRaiBlocklistSequential/raiBlocklist/basic (108.09s)
        --- PASS: TestAccCognitiveRaiBlocklistSequential/raiBlocklist/requiresImport (104.71s)
        --- PASS: TestAccCognitiveRaiBlocklistSequential/raiBlocklist/complete (103.09s)
        --- PASS: TestAccCognitiveRaiBlocklistSequential/raiBlocklist/update (111.27s)
PASS
ok          github.com/hashicorp/terraform-provider-azurerm/internal/services/cognitive        428.793s

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

  • New Resource: azurerm_cognitive_account_rai_blocklist - support for creating Rai Blocklist in Azure OpenAI [GH-28043].

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #0000

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

@liuwuliuyun what is the difference between this resource and the custom_blocklist property in #28013

@feliperezende-barbosa
Copy link
Contributor Author

@liuwuliuyun what is the difference between this resource and the custom_blocklist property in #28013

The difference is that the blocklists must already be created in order to be referenced in the custom_blocklist property. It's the same idea when you deploy a cognitive deployment (openai) and need an RAI policy. The RAI policy must already be created. That's why there is an API separated for that Rai Blocklists.

@stephybun
Copy link
Member

This is helpful information @feliperezende-barbosa. In that case the custom_blocklist property should be modeled slightly differently in #28013.

@feliperezende-barbosa
Copy link
Contributor Author

This is helpful information @feliperezende-barbosa. In that case the custom_blocklist property should be modeled slightly differently in #28013.

I would say that the implementation is correct, in my point of view. Because what I implemented here is that it's only deploying an Rai Policy and in #28013 it needs to set up the Rai Blocklist already created with the name, enabled (if it'll be enabled) and a source (prompt, or completion). And also my idea is if this implementation is merged I'll implement the Rai Blocklist Items reference.

@stephybun
Copy link
Member

@feliperezende-barbosa more that if this resource azurerm_cognitive_rai_blocklist is input for the custom_blocklist block in azurerm_cognitive_account_rai_policy then the property custom_blocklist.name should actually become custom_blocklist.rai_blocklist_id. We should be passing in the IDs of resources where possible as this is consistent across the provider, clearer for the user, allows us to provide stronger schema validation and produces a better dependency graph.

@feliperezende-barbosa
Copy link
Contributor Author

@feliperezende-barbosa more that if this resource azurerm_cognitive_rai_blocklist is input for the custom_blocklist block in azurerm_cognitive_account_rai_policy then the property custom_blocklist.name should actually become custom_blocklist.rai_blocklist_id. We should be passing in the IDs of resources where possible as this is consistent across the provider, clearer for the user, allows us to provide stronger schema validation and produces a better dependency graph.

Good point. We can also update the rai_policy_name property in azurerm_cognitive_deployment to rai_policy_id (or something similar). Currently, if you enter a Rai Policy Name that does not exist, it throws an error.

@liuwuliuyun
Copy link
Contributor

@feliperezende-barbosa more that if this resource azurerm_cognitive_rai_blocklist is input for the custom_blocklist block in azurerm_cognitive_account_rai_policy then the property custom_blocklist.name should actually become custom_blocklist.rai_blocklist_id. We should be passing in the IDs of resources where possible as this is consistent across the provider, clearer for the user, allows us to provide stronger schema validation and produces a better dependency graph.

I'm good with changing custom_blocklist.name to custom_blocklist.rai_blocklist_id. Just a small suggestion: should we align the names of these two resources? Since they're both associated with the cognitive account, maybe we could rename this resource to azurerm_cognitive_account_rai_blocklist?

@feliperezende-barbosa
Copy link
Contributor Author

@feliperezende-barbosa more that if this resource azurerm_cognitive_rai_blocklist is input for the custom_blocklist block in azurerm_cognitive_account_rai_policy then the property custom_blocklist.name should actually become custom_blocklist.rai_blocklist_id. We should be passing in the IDs of resources where possible as this is consistent across the provider, clearer for the user, allows us to provide stronger schema validation and produces a better dependency graph.

I'm good with changing custom_blocklist.name to custom_blocklist.rai_blocklist_id. Just a small suggestion: should we align the names of these two resources? Since they're both associated with the cognitive account, maybe we could rename this resource to azurerm_cognitive_account_rai_blocklist?

Sure, no problem. I'm doing it.

@feliperezende-barbosa feliperezende-barbosa force-pushed the feature/cogservices-rai-blocklists branch from c9dbe2f to 010ba49 Compare December 11, 2024 02:39
@feliperezende-barbosa
Copy link
Contributor Author

@liuwuliuyun made the suggestion.

@liuwuliuyun
Copy link
Contributor

I also updated the custom_blocklist.name to custom_blocklist.rai_blocklist_id in #28013

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

I realised that acceptance test section in our guide on adding a new resource was a little outdated. That has since been updated but I've left a handful of comments on this PR which I would appreciate if you could fix up for consistency reasons. Once that's done I'll kick off the tests and this should be good to go!

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Thanks @feliperezende-barbosa LGTM 💯

@stephybun stephybun merged commit 941b107 into hashicorp:main Dec 12, 2024
33 checks passed
@github-actions github-actions bot added this to the v4.14.0 milestone Dec 12, 2024
stephybun added a commit that referenced this pull request Dec 12, 2024
jackofallops added a commit that referenced this pull request Dec 13, 2024
* Update CHANGELOG.md for #26304

* Update CHANGELOG.md for #28211

* Update for #28016

* Update for #28139

* Update for #27776

* Update for #28227

* Update for #28080

* Update for #28228

* Update for #27915

* reword nginx api upgrade

* Update for #28160

* Update for #28043

* run changelog-update-for-release.sh

---------

Co-authored-by: stephybun <[email protected]>
Co-authored-by: kt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants