-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
UX improvements to model versions #7435
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
886170e
to
cd8832d
Compare
Holding off on merging until the outcome of this slack thread, wherein we decide whether to vendor Update: Let's opt for, this will come in v1.6; in the meantime, a macro you can copy-paste-edit-post-hook. |
for k, v in manifest.nodes.items() | ||
if k.startswith(f"{node.unique_id[:-len(str(node.version))]}") | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this can be simplified to:
max_version: Union[str, float, None] = max( # type: ignore
[v.version for v in manifest.nodes.values() if v.name == node.name]
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ... clearly better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broader refactoring suggestion: using UnparsedVersion
for the comparisons, similar to what we do in the graph selector method here
max_version = max(
[
UnparsedVersion(v.version)
for v in manifest.nodes.values()
if v.name == node.name and v.version is not None
]
)
assert node.latest_version
if max_version > UnparsedVersion(node.latest_version):
fire_event(
UnpinnedRefNewVersionAvailable(
node_info=get_node_info(),
ref_node_name=node.name,
ref_node_package=node.package_name,
ref_node_version=str(node.version),
ref_max_version=str(max_version.v),
)
)
The TypeError issues in unit testing should be fixed by updating the MockNode constructor:
+++ b/test/unit/utils.py
@@ -350,6 +350,7 @@ def MockNode(package, name, resource_type=None, **kwargs):
**kwargs,
)
node.name = name
+ node.is_versioned = resource_type is NodeType.Model and version is not None
return node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at the risk of expanding the intended scope of a partial parsing test - I'm going to borrow your commit 84cc3ca and check that this message is being logged in the case of an unpinned ref
to a latest-not-newest model
Looking at the logged message:
Should the second line be:
|
Will rebase after #7439 is merged |
fca9243
to
0713e9d
Compare
* Latest version should use un-suffixed alias * Latest version can be in un-suffixed file * FYI when unpinned ref to model with prerelease version * [WIP] Nicer error if versioned ref to unversioned model * Revert "Latest version should use un-suffixed alias" This reverts commit 3616c52. * Revert "[WIP] Nicer error if versioned ref to unversioned model" This reverts commit c9ae4af. * Define real event for UnpinnedRefNewVersionAvailable * Update pp test for implicit unsuffixed defined_in * Add changelog entry * Fix unit test * marky feedback * Add test case for UnpinnedRefNewVersionAvailable event (cherry picked from commit d53bb37)
* Latest version should use un-suffixed alias * Latest version can be in un-suffixed file * FYI when unpinned ref to model with prerelease version * [WIP] Nicer error if versioned ref to unversioned model * Revert "Latest version should use un-suffixed alias" This reverts commit 3616c52. * Revert "[WIP] Nicer error if versioned ref to unversioned model" This reverts commit c9ae4af. * Define real event for UnpinnedRefNewVersionAvailable * Update pp test for implicit unsuffixed defined_in * Add changelog entry * Fix unit test * marky feedback * Add test case for UnpinnedRefNewVersionAvailable event (cherry picked from commit d53bb37) Co-authored-by: Jeremy Cohen <[email protected]>
resolves #7443
Naive implementations for some of the proposed improvements I mention here:
Overview of changes
By default, land theWe are going to recommend accomplishing this with alatest_version
ofdim_customers
in<db>.<schema>.dim_customers
(no suffix). This is a behavior change to the built-ingenerate_alias_name
, so if we're going to do it, we should do it before the final release.post-hook
in the meantime. We are still discussing if it makes sense to vendor that macro code withindbt-core
.latest_version
of dim_customers in a file nameddim_customers.sql
(no suffix). The convention ofdim_customers_vX.sql
would also be supported — so this isn't actually a behavior change.ref
to a model that has a newer-than-latest (i.e.prerelease
) version defined: "Heads up, your unpinnedref
will roll over to the new version as soon as it's the latest." (Should this be a warning? If you're not actually referencing a model slated for deprecation...)(Bonus) Raise a nicer error if I've written a
ref
pinned to a specific version, and the model I'm referencing isn't actually versioned. This came up during training, when someone didn't correctly define theversions
block on their model — but it wasn't clear if the error was in the model configuration, or in the downstreamref
. This isn't a behavior change, and the codepath is slightly trickier, so I'll probably just kick it out of this PR. Update: Kicked out of scope.Checklist
changie new
to create a changelog entry