Skip to content

Commit

Permalink
Add metric statistics and skip message
Browse files Browse the repository at this point in the history
Signed-off-by: Wei-Chun, Chang <[email protected]>
  • Loading branch information
wcchang1115 committed Aug 31, 2023
1 parent 257f883 commit c180b9f
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions piperider_cli/dbtutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def is_chosen(key, metric):
metric_map[metric.get('name')] = metric

def _create_metric(name, filter=None, alias=None):
statistics = Statistics()
metric = metric_map.get(name)

if metric.get('type') == 'simple':
Expand Down Expand Up @@ -490,21 +491,18 @@ def _create_metric(name, filter=None, alias=None):
label=metric.get('label'), description=metric.get('description'),
ref_id=metric.get('unique_id'))

statistics = Statistics()
statistics.add_field_one('total')

for f in m.model.filters:
if primary_entity not in f['field']:
if primary_entity in f['field']:
f['field'] = f['field'].replace(f'{primary_entity}__', '')
else:
console.print(
f"[[bold yellow]Warning[/bold yellow]] Skip metric '{metric.get('name')}'. "
f"Property 'filter' is not supported.")
f"[[bold yellow]Skip[/bold yellow]] Metric '{metric.get('name')}'. "
f"Dimension of foreign entities is not supported.")
statistics.add_field_one('nosupport')
return None
else:
f['field'] = f['field'].replace(f'{primary_entity}__', '')
if m.calculation_method == 'median':
console.print(
f"[[bold yellow]Warning[/bold yellow]] Skip metric '{metric.get('name')}'. "
f"[[bold yellow]Skip[/bold yellow]] Metric '{metric.get('name')}'. "
f"Aggregation type 'median' is not supported.")
statistics.add_field_one('nosupport')
return None
Expand All @@ -517,8 +515,9 @@ def _create_metric(name, filter=None, alias=None):
for ref_metric in metric.get('type_params').get('metrics'):
if ref_metric.get('offset_window') is not None:
console.print(
f"[[bold yellow]Warning[/bold yellow]] Skip metric '{metric.get('name')}'. "
f"[[bold yellow]Skip[/bold yellow]] Metric '{metric.get('name')}'. "
f"Derived metric property 'offset_window' is not supported.")
statistics.add_field_one('nosupport')
return None
m2 = _create_metric(
ref_metric.get('name'),
Expand Down Expand Up @@ -572,11 +571,15 @@ def _create_metric(name, filter=None, alias=None):
return m
else:
console.print(
f"[[bold yellow]Warning[/bold yellow]] Skip metric '{metric.get('name')}'. "
f"[[bold yellow]Skip[/bold yellow]] Metric '{metric.get('name')}'. "
f"Metric type 'Cumulative' is not supported.")
statistics.add_field_one('nosupport')
return None

for key, metric in manifest.get('metrics').items():
statistics = Statistics()
statistics.add_field_one('total')

if not is_chosen(key, metric):
continue

Expand Down

0 comments on commit c180b9f

Please sign in to comment.