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

Add meta to measures, entities, and dimensions #358

Merged
merged 5 commits into from
Nov 12, 2024

Conversation

DevonFulcher
Copy link
Contributor

@DevonFulcher DevonFulcher commented Oct 23, 2024

Description

This PR is modeled off of this prior PR. This PR adds meta to measures, entities, and dimensions.

Checklist

@cla-bot cla-bot bot added the cla:yes label Oct 23, 2024
@DevonFulcher DevonFulcher force-pushed the Add_meta_to_measures,_entities,_and_dimensions branch from e155c0d to f6fea48 Compare October 23, 2024 17:30
@DevonFulcher DevonFulcher marked this pull request as ready for review October 23, 2024 17:34
Copy link
Contributor

@courtneyholcomb courtneyholcomb left a comment

Choose a reason for hiding this comment

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

Looks good! Left one main point of feedback.

Would love to also get @WilliamDee 's eyes on this just in case because I'm not super familiar with how meta & config are supposed to look.

Also - whenever we make a schema change, we get the core team's approval first. I'm not sure if that's necessary here since it's just copying what exists on a metric already, but I would recommend asking Jordan to confirm if we should get their eyes on this before merging.

@@ -37,6 +42,16 @@ class PydanticDimensionTypeParams(HashableBaseModel):
validity_params: Optional[PydanticDimensionValidityParams] = None


class PydanticDimensionConfig(HashableBaseModel, ProtocolHint[DimensionConfig]):
Copy link
Contributor

Choose a reason for hiding this comment

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

If these protocols & implementations are all exactly the same structure, I think we should just use the MetricConfig protocol & implementation for all of them. Would be nice to remove the duplicate code if it's not needed. @WilliamDee would you foresee any problems with that?
It would be great if we could rename the class to just something more generic like SemanticLayerElementConfig or something if we're going to use it on all these elements. That would technically be a breaking change for DSI, but I just checked in dbt-core and it's not used anywhere. So it should be fine.
We would want to bump DSI to the next minor version if we do that. So if we do that, I can walk you through the steps for that.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could do that, but a foreseeable issue comes when or if the Config ever diverges for different elements. Then in that case it may be abit of a pain in the ass to change.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, seems like core just uses config as some arbitrary dict, https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/contracts/graph/unparsed.py#L615 so i think it's fine to generalize it in DSI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I made this update for the resources in this PR. I will make a follow-up PR to consolidate the other resources. I will wait on Grace's approval to merge this PR.

Copy link
Contributor

@WilliamDee WilliamDee left a comment

Choose a reason for hiding this comment

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

this all looks good to me! Just need to resolve the Courtney's comment of whether we want to consolidate the Config to a single class

Copy link
Contributor

@courtneyholcomb courtneyholcomb left a comment

Choose a reason for hiding this comment

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

Requested one more change!

dbt_semantic_interfaces/protocols/meta.py Outdated Show resolved Hide resolved
@courtneyholcomb
Copy link
Contributor

Also, do you mind searching dbt-mantle for the MetricConfig classes that will be removed to make sure they aren't used there? Both the protocol and the implementation. I already checked core.

@courtneyholcomb
Copy link
Contributor

Also, do you mind searching dbt-mantle for the MetricConfig classes that will be removed to make sure they aren't used there? Both the protocol and the implementation. I already checked core.

@DevonFulcher I also didn't realize we had config on semantic models too! So can you check both dbt-core and dbt-mantle to make sure all the SemanticModelConfig and MetricConfig classes aren't used?

@DevonFulcher
Copy link
Contributor Author

I also didn't realize we had config on semantic models too! So can you check both dbt-core and dbt-mantle to make sure all the SemanticModelConfig and MetricConfig classes aren't used?

@courtneyholcomb Based on my search, it looks like mantle and core have classes with the same name as SemanticModelConfig and MetricConfig, but those repos are not importing these classes from dsi. Also, to be clear, this PR shouldn't contain any breaking changes. That is my other PR here.

@courtneyholcomb
Copy link
Contributor

I also didn't realize we had config on semantic models too! So can you check both dbt-core and dbt-mantle to make sure all the SemanticModelConfig and MetricConfig classes aren't used?

@courtneyholcomb Based on my search, it looks like mantle and core have classes with the same name as SemanticModelConfig and MetricConfig, but those repos are not importing these classes from dsi. Also, to be clear, this PR shouldn't contain any breaking changes. That is my other PR here.

@DevonFulcher Sounds like we're good then!! And yeah, sorry, I didn't put this in the appropriate PR 😆

def _implements_protocol(self) -> SemanticLayerElementConfig: # noqa: D
return self

meta: Dict[str, Any] = Field(default_factory=dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would this work if we add more fields to the config and wanted to treat meta as optional? (For example, if we wanted to allow someone to add either some metadata or a tag.)

(This is not necessarily a blocking question.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! We can make this optional in the future, though, without a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not already optional? In a sense that, it'll default to an empty dict if you didn't provide it anything

Copy link
Contributor Author

@DevonFulcher DevonFulcher Nov 6, 2024

Choose a reason for hiding this comment

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

Ya, it is effectively optional because of the default, although not type Optional.

@DevonFulcher DevonFulcher merged commit c833632 into main Nov 12, 2024
22 checks passed
@DevonFulcher DevonFulcher deleted the Add_meta_to_measures,_entities,_and_dimensions branch November 12, 2024 19:36
DevonFulcher added a commit that referenced this pull request Nov 12, 2024
### Description

This PR addresses
[this](#358 (comment))
feedback to consolidate the meta config into central models. This is
technically a breaking change because some classes have been deleted,
but Courtney confirmed that these classes are not being used by
dbt-core.

### Checklist

- [x] I have read [the contributing
guide](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md)
and understand what's expected of me
- [x] I have signed the
[CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [x] This PR includes tests, or tests are not required/relevant for
this PR
- [x] I have run `changie new` to [create a changelog
entry](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md#adding-a-changelog-entry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants