Skip to content

Added databricks_registered_model resource#2771

Merged
mgyucht merged 9 commits intodatabricks:masterfrom
arpitjasa-db:ucModel
Oct 13, 2023
Merged

Added databricks_registered_model resource#2771
mgyucht merged 9 commits intodatabricks:masterfrom
arpitjasa-db:ucModel

Conversation

@arpitjasa-db
Copy link
Copy Markdown
Contributor

@arpitjasa-db arpitjasa-db commented Oct 6, 2023

Changes

This PR adds Models in UC as a Terraform resource to the Databricks Terraform Provider, named in a future-proof way and to disambiguate from the soon-to-be deprecated workspace MLflow models.

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • relevant acceptance tests are passing
  • using Go SDK

Also tested manually using the make install-version of the Terraform provider that includes these changes and the Dogfood staging workspace.
Screenshot 2023-10-06 at 10 54 46 AM
Screenshot 2023-10-06 at 11 55 21 AM
Screenshot 2023-10-06 at 11 52 26 AM

@arpitjasa-db arpitjasa-db requested review from a team as code owners October 6, 2023 07:06
@arpitjasa-db arpitjasa-db requested review from a team, alexott, mgyucht, nfx, nkvuong, smurching and vladimirk-db and removed request for a team October 6, 2023 07:06
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 6, 2023

Codecov Report

Merging #2771 (de6ac27) into master (754aad4) will decrease coverage by 3.47%.
Report is 113 commits behind head on master.
The diff coverage is 74.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2771      +/-   ##
==========================================
- Coverage   88.21%   84.75%   -3.47%     
==========================================
  Files         145      149       +4     
  Lines       11989    13050    +1061     
==========================================
+ Hits        10576    11060     +484     
- Misses        930     1391     +461     
- Partials      483      599     +116     
Files Coverage Δ
access/resource_ip_access_list.go 80.95% <100.00%> (ø)
catalog/data_metastores.go 84.61% <100.00%> (ø)
catalog/resource_catalog.go 71.76% <100.00%> (ø)
catalog/resource_share.go 91.39% <100.00%> (+0.18%) ⬆️
catalog/resource_sql_table.go 92.18% <100.00%> (+1.08%) ⬆️
catalog/resource_table.go 100.00% <ø> (ø)
catalog/resource_volume.go 84.00% <ø> (ø)
clusters/data_spark_version.go 94.73% <100.00%> (+0.19%) ⬆️
clusters/resource_cluster.go 85.71% <100.00%> (+0.60%) ⬆️
common/version.go 80.00% <ø> (ø)
... and 39 more

... and 1 file with indirect coverage changes

m["name"].ForceNew = true
m["catalog_name"].ForceNew = true
m["schema_name"].ForceNew = true
m["storage_location"].ForceNew = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If it's computed, we may not need ForceNew.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but if someone manually sets this field after it's been computed, it still tries to modify the field in-place instead of replacing the whole resource. That's why I added both attributes

Copy link
Copy Markdown
Contributor

@nkvuong nkvuong left a comment

Choose a reason for hiding this comment

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

couple of suggested changes

Copy link
Copy Markdown
Contributor

@smurching smurching left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @arpitjasa-db !

@arpitjasa-db arpitjasa-db requested a review from nkvuong October 10, 2023 06:08
@tanmay-db tanmay-db self-requested a review October 11, 2023 11:35
Signed-off-by: Arpit Jasapara <[email protected]>
@nkvuong
Copy link
Copy Markdown
Contributor

nkvuong commented Oct 12, 2023

integration tests passed (failed tests are for databricks_sql_query)

Copy link
Copy Markdown
Contributor

@tanmay-db tanmay-db left a comment

Choose a reason for hiding this comment

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

LGTM, comments have also been addressed.

Copy link
Copy Markdown
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

Non-blocking comment.

Note that the FullName field is a read-only field only present on the create response and as parameter to the other API calls, so it doesn't show up in the resource schema (only as ID).

I looked at the schema diff and this is the result:

{
  "block": {
    "attributes": {
      "catalog_name": {
        "description_kind": "plain",
        "required": true,
        "type": "string"
      },
      "comment": {
        "description_kind": "plain",
        "optional": true,
        "type": "string"
      },
      "id": {
        "computed": true,
        "description_kind": "plain",
        "optional": true,
        "type": "string"
      },
      "name": {
        "description_kind": "plain",
        "required": true,
        "type": "string"
      },
      "schema_name": {
        "description_kind": "plain",
        "required": true,
        "type": "string"
      },
      "storage_location": {
        "computed": true,
        "description_kind": "plain",
        "optional": true,
        "type": "string"
      }
    },
    "description_kind": "plain"
  },
  "version": 0
}


This resource allows you to create [MLflow models](https://docs.databricks.com/applications/mlflow/models.html) in Databricks.

**Note** This documentation covers the Workspace Model Registry. Databricks recommends using [Models in Unity Catalog](registered_model.md). Models in Unity Catalog provides centralized model governance, cross-workspace access, lineage, and deployment. Workspace Model Registry will be deprecated in the future.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The deprecation notice can be left out if we don't know when this will happen (or ever).

Copy link
Copy Markdown
Contributor

@mgyucht mgyucht left a comment

Choose a reason for hiding this comment

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

To unblock the release of this resource, I'll approve. I think we can expand the set of fields accepted by the input and those provided for users to read after creation as a follow-up.


func ResourceRegisteredModel() *schema.Resource {
s := common.StructToSchema(
catalog.CreateRegisteredModelRequest{},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will work, but it will only include attributes defined in the create request. If the other fields in RegisteredModelInfo are of use to users, we may want to use catalog.RegisteredModelInfo and set Computed: true on all other fields. Note that if we do this, you'll need to set Optional: false on all of those fields, as this helper method infers that these fields are optional (which in this case is incorrect: read only fields in TF providers are Computed: true and Optional: false). Since adding read-only values to a TF resource is non-breaking, we can revisit this later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another note: owner is not part of the create structure but is part of the update, so users won't be able to set an owner for the model. We can revisit this later if need be.

* `name` - (Required) The name of the registered model.
* `catalog_name` - (Required) The name of the catalog where the schema and the registered model reside.
* `schema_name` - (Required) The name of the schema where the registered model resides.
* `comment` - The comment attached to the registered model.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you not want to document storage_location? Can users set this explicitly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For now, I will merge as is, and we can add more documentation in a follow-up.

@mgyucht mgyucht enabled auto-merge October 13, 2023 13:31
@mgyucht mgyucht added this pull request to the merge queue Oct 13, 2023
Merged via the queue into databricks:master with commit d5266ec Oct 13, 2023
@arpitjasa-db arpitjasa-db deleted the ucModel branch October 13, 2023 21:39
@tanmay-db tanmay-db mentioned this pull request Oct 16, 2023
5 tasks
github-merge-queue bot pushed a commit to databricks/cli that referenced this pull request Oct 16, 2023
## Changes
<!-- Summary of your changes that are easy to understand -->
Add UC Registered Models support to Databricks Asset Bundles as new
resource `registered_model`. Also added UC Permission support via new
resource `grant`.

## Tests
<!-- How is this tested? -->
Tested via unit tests and manual testing with [example
PR](https://github.com/databricks/bundle-examples-internal/pull/80) and
[custom Terraform
provider](databricks/terraform-provider-databricks#2771).
<img width="698" alt="Screenshot 2023-10-08 at 4 57 23 PM"
src="https://github.com/databricks/cli/assets/87999496/bcf605a9-7894-443b-865a-f7e240037815">
<img width="1109" alt="Screenshot 2023-10-08 at 4 56 47 PM"
src="https://github.com/databricks/cli/assets/87999496/e4d6e424-cd70-4809-8843-6939ed2e172f">
<img width="1091" alt="Screenshot 2023-10-08 at 4 56 57 PM"
src="https://github.com/databricks/cli/assets/87999496/88ebaabb-67db-4a11-88a5-df087e2e41c0">

---------

Signed-off-by: Arpit Jasapara <[email protected]>
Co-authored-by: Andrew Nester <[email protected]>
Co-authored-by: Pieter Noordhuis <[email protected]>
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.

10 participants