Skip to content

Fix computed attribute setup to only update each computed attribute once #6402

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

Merged
merged 1 commit into from
May 5, 2025

Conversation

dgarros
Copy link
Collaborator

@dgarros dgarros commented May 4, 2025

While working on #6393, I noticed a bug with computed_attribute_setup_jinja2 that cause some computed attribute to be updated multiple time after the schema has been updated, if they are referencing more than one kind of nodes.

Looking closer at the code, I tried to see if I could update this part of the code to avoid updating all computed attributes when we update the schema.
As part of this effort, I've refactored the function setup_triggers to be idempotent and to properly report which automations has been updated instead of updating everything all the time. This by itself isn't a complete fix but if we could generate a hash that represent the part of the computed attribute that isn't captured in the Automation and include it somehow in the automation, I think it would provide a reliable way to identify which computed attribute needs to be recalculated.

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label May 4, 2025
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is not related to this PR but I noticed these 2 files that don't have the right format in the changelog directory

Copy link

codspeed-hq bot commented May 4, 2025

CodSpeed Performance Report

Merging #6402 will not alter performance

Comparing dga-20250504-fix-comp-attr-setup (39ed671) with stable (512f2bf)

Summary

✅ 10 untouched benchmarks

@dgarros dgarros changed the title Update computed attribute setup to only recalculate trigger that have been updated Fix computed attribute setup to only recalculate each computed attribute once May 4, 2025
@dgarros dgarros changed the title Fix computed attribute setup to only recalculate each computed attribute once Fix computed attribute setup to only update each computed attribute once May 4, 2025
@dgarros dgarros marked this pull request as ready for review May 4, 2025 15:58
@dgarros dgarros requested a review from a team as a code owner May 4, 2025 15:59
Copy link
Contributor

@ogenstad ogenstad left a comment

Choose a reason for hiding this comment

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

LGTM, I like the idea of storing some kind of hash "somewhere". We'd have to consider something for the Python transform based ones the for Jinja2 the hash alone would do, if we can get the commit ID for the repo of the transforms we could include that too. We have the description field within the transform itself, other than that it could be something in our database.

# Because the automation in Prefect doesn't capture all information about the computed attribute
# we can't tell right now if a given computed attribute has changed and need to be updated
unique_nodes: set[tuple[str, str, str]] = {
(trigger.branch, trigger.computed_attribute.kind, trigger.computed_attribute.attribute.name) # type: ignore[attr-defined]
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 mypy ignore actually required?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch ... thks

@dgarros dgarros force-pushed the dga-20250504-fix-comp-attr-setup branch from b528160 to 39ed671 Compare May 5, 2025 14:11
@dgarros dgarros merged commit 46423d4 into stable May 5, 2025
35 checks passed
@dgarros dgarros deleted the dga-20250504-fix-comp-attr-setup branch May 5, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants