Skip to content

fix: deploy metrics depending on computed attributes transitively last - #23

Merged
marmil-cz merged 1 commit into
masterfrom
mmil/computed_metrics
Oct 22, 2026
Merged

marmil-cz merged 1 commit into
masterfrom
mmil/computed_metrics

Conversation

@marmil-cz

@marmil-cz marmil-cz commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

The three-pass metrics deploy only moved a metric to the last pass when its own MAQL contained {computed_attribute/...}. A metric referencing another metric that uses a computed attribute was deployed in the first pass, before the computed attribute existed, and ended up as a placeholder or failed.

Add split_metrics_by_computed_attribute(), which also treats metrics that reference such metrics, at any depth, as dependent on a computed attribute. migrate_metrics now uses it to split plain metrics from metrics deployed after the computed attributes.

risk: low

Summary by CodeRabbit

  • Bug Fixes
    • Improved metric migration ordering by accounting for both direct and indirect dependencies on computed attributes. Plain metrics are deployed before computed attributes, followed by dependent metrics.

The three-pass metrics deploy only moved a metric to the last pass when
its own MAQL contained {computed_attribute/...}. A metric referencing
another metric that uses a computed attribute was deployed in the first
pass, before the computed attribute existed, and ended up as a
placeholder or failed.

Add split_metrics_by_computed_attribute(), which also treats metrics
that reference such metrics, at any depth, as dependent on a computed
attribute. migrate_metrics now uses it to split plain metrics from
metrics deployed after the computed attributes.

risk: low
@marmil-cz marmil-cz added the do not merge Do not merge this yet label Oct 22, 2026
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 717b3aa2-f53f-40e2-be40-49c55081a0b0
📥 Commits

Reviewing files that changed from the base of the PR and between a494d3d and d6c4d61.

📒 Files selected for processing: 3
  • src/gooddata_legacy2cloud/metrics/metrics_sorter.py
  • src/gooddata_legacy2cloud/workflows/migrate_metrics.py
  • tests/test_metrics_ca_split.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The metrics sorter now separates metrics with direct or transitive computed-attribute dependencies from plain metrics. The migration workflow uses these groups and retains the existing deployment order.

Changes: Metric dependency ordering

Layer / File(s) Summary
Dependency detection and tests
src/gooddata_legacy2cloud/metrics/metrics_sorter.py, tests/test_metrics_ca_split.py
split_metrics_by_computed_attribute identifies direct and transitive dependencies while preserving input order. Tests cover dependent metrics, unrelated metrics, and metrics without computed-attribute dependencies.
Migration integration
src/gooddata_legacy2cloud/workflows/migrate_metrics.py
The workflow uses the sorter to separate plain metrics from dependent metrics. Deployment remains ordered as plain metrics, computed attributes, then dependent metrics.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: xvalovic

Merge Risk: ⚪ Minimal · up to d6c4d

The reviewed dependency ordering is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: deploying metrics with transitive computed-attribute dependencies after other metrics.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit sorts the metrics in a neat and steady row
Plain ones hop ahead before the attributes grow
Dependent ones follow when their links are clear
Tests keep each order tidy, direct or far
Then the rabbit nibbles greens and rests its ears

Comment @coderabbitai help to get the list of available commands.

@marmil-cz marmil-cz removed the do not merge Do not merge this yet label Oct 22, 2026
@Martinlll

Copy link
Copy Markdown

Verified. Previously metric with dependency failed to migrate properly. After the fix from this PR metric is created after the input metric with CAs already exists and hence the dependency metric is properly created. The bug with "#API Error 400: #Some of given referenced 'metrics' entities do not exist. Not existing IDs" is no longer present.

@marmil-cz
marmil-cz merged commit e42943e into master Oct 22, 2026
2 checks passed
@marmil-cz
marmil-cz deleted the mmil/computed_metrics branch October 22, 2026 11:30
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.

3 participants