Skip to content

Commit

Permalink
Add warning and hint for legacy metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Ching Yi, Chan <[email protected]>
  • Loading branch information
qrtt1 committed Aug 30, 2023
1 parent 9ae345d commit 31e92c3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions piperider_cli/compare_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def _update_implicit_and_explicit_changeset(self):

self.summary_change_set = SummaryChangeSet(self._base, self._target)
except BaseException as e:
self.warning_for_legacy_metrics(e)

console = Console()
console.print('[bold yellow]Warning:[/bold yellow]')
if isinstance(e, ValueError) and e.args:
Expand All @@ -201,6 +203,21 @@ def _update_implicit_and_explicit_changeset(self):
console.print(e)
console.print('\nGot problem to generate changeset.')

def warning_for_legacy_metrics(self, e):
if not hasattr(e, 'MESSAGE') or getattr(e, 'MESSAGE') != 'Compilation Error':
return

""""

Check warning on line 210 in piperider_cli/compare_report.py

View check run for this annotation

Codecov / codecov/patch

piperider_cli/compare_report.py#L210

Added line #L210 was not covered by tests
Example for "msg":
'model.git_repo_analytics.commit_weekly' depends on 'metric.git_repo_analytics.total_commits' which is not in the graph!
"""
if not hasattr(e, 'msg') or "depends on" not in getattr(e, 'msg'):
return

Check warning on line 215 in piperider_cli/compare_report.py

View check run for this annotation

Codecov / codecov/patch

piperider_cli/compare_report.py#L214-L215

Added lines #L214 - L215 were not covered by tests

from piperider_cli.error import PipeRiderError
raise PipeRiderError("Found legacy metrics",

Check warning on line 218 in piperider_cli/compare_report.py

View check run for this annotation

Codecov / codecov/patch

piperider_cli/compare_report.py#L217-L218

Added lines #L217 - L218 were not covered by tests
hint="The dbt_metrics package has been deprecated and replaced with MetricFlow.")

def _update_github_pr_info(self):
if os.environ.get('GITHUB_EVENT_PATH'):
self.metadata = fetch_pr_metadata()
Expand Down

0 comments on commit 31e92c3

Please sign in to comment.