Skip to content
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

polars expression serialization #308

Merged
merged 4 commits into from
Jan 6, 2025
Merged

Conversation

yusufuyanik1
Copy link
Collaborator

Changes

  1. Fixed Polars expression serialization for healthcheck filters.

    • Previously: Polars automatically converted expressions to JSON format
    • Now: Explicitly serialize expressions before writing to params.yml
    • Why: Newer Polars versions default to binary format which can't be safely stored in YAML
    • Solution: Added proper serialization/deserialization handling for expressions. Serialize just before creating YAML and deserialize in heatlhcheck.qmd
  2. Code Organization Improvements

    • Simplified executable version handling as per @operdeck's TODO suggestion
    • Moved utility functions (find_quarto_executable) from Reports.py to report_utils.py
    • Resolved circular import issue where Reports class was being imported in its util file

- Serializing polars expressions(filters) before dumping them to params.yml
- Simplified executable version handling per TODO suggestion
- Moved utility functions(find_quarto_executable) from Reports.py to report_utils.py
@yusufuyanik1
Copy link
Collaborator Author

@operdeck
match-case statements are failing in python 3.9 because they are introduced in 3.10
will change them to if-elif-else if there is no objection

def rag_background_styler(
    rag: Optional[Literal["Red", "Amber", "Yellow", "Green"]] = None,
):
    match rag[0].upper() if len(rag) > 0 else None:
        case "R":
            return style.fill(color="orangered")
        case "A":
            return style.fill(color="orange")
        case "Y":
            return style.fill(color="yellow")
        case "G":
            return None  # no green background to keep it light
        case _:
            raise ValueError(f"Not a supported RAG value: {rag}")

@operdeck
Copy link
Collaborator

operdeck commented Dec 30, 2024 via email

@yusufuyanik1 yusufuyanik1 merged commit 7d2e247 into master Jan 6, 2025
11 checks passed
@yusufuyanik1 yusufuyanik1 deleted the pl_expr_serialization branch January 6, 2025 11:04
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.

2 participants