Skip to content

Commit

Permalink
✨ etl pr, anomalist (#3664)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasrodes authored Nov 30, 2024
1 parent f7ae18f commit e06ea30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/pr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def bake_branch_name(repo, pr_title, no_llm, remote_branches):
category = pr_title.category

# Get input title (without emoji, scope, etc.)
title = _extract_relevant_title_for_branch_name(pr_title.title, not no_llm)
title = _extract_relevant_title_for_branch_name(pr_title.title, category, not no_llm)

# Bake complete PR branch name
# name = f"{user}-{category}-{title}"
Expand All @@ -383,13 +383,14 @@ def bake_branch_name(repo, pr_title, no_llm, remote_branches):
# if name in remote_branches:
# log.info("Generating a hash for this branch name to prevent name collisions.")
# name = f"{name}-{user}"
if name in remote_branches:
local_branches = [branch.name for branch in repo.branches]
if (name in remote_branches) or (name in local_branches):
log.info("Generating a hash for this branch name to prevent name collisions.")
name = f"{name}-{generate_short_hash()}"
return name


def _extract_relevant_title_for_branch_name(text_in: str, use_llm) -> str:
def _extract_relevant_title_for_branch_name(text_in: str, category: str, use_llm) -> str:
"""
Process the input string by:
1. Removing all symbols, keeping only letters and numbers.
Expand All @@ -411,8 +412,13 @@ def _extract_relevant_title_for_branch_name(text_in: str, use_llm) -> str:

# Split into tokens/words
tokens = cleaned_text.split()

# Clean if there is word included in category
tokens = [t for t in tokens if t.lower() != category]

# Keep only the first 3 tokens
tokens = tokens[:3]

# Combine tokens with '-'
name = "-".join(tokens).lower()

Expand Down
3 changes: 3 additions & 0 deletions apps/wizard/app_pages/anomalist/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ def show_anomaly_compact(index, df):
config = bake_chart_config(variable_id=indicator_id, selected_entities=entities)
config["hideAnnotationFieldsInTitle"]["time"] = True
config["hideFacetControl"] = False
config["hideShareButton"] = True
config["hideExploreTheDataButton"] = True
# config["isSocialMediaExport"] = False

# Actually plot
grapher_chart(chart_config=config, owid_env=OWID_ENV)
Expand Down

0 comments on commit e06ea30

Please sign in to comment.