Skip to content

Conversation

@varant-zlai
Copy link
Collaborator

@varant-zlai varant-zlai commented Aug 2, 2025

Summary

There was a bug where staging directory would accumulate multiple versions when the compilation was cancelled by the user.

Fixing that, and also unifying the friction warning with the final output display.

Improving warning messages.

Checklist

  • Not tested
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Improved user confirmation prompt with clearer messaging when in-place changes are detected during compilation.
    • Added conditional user prompt that skips confirmation if compilation errors exist.
    • Added error detection to suppress diff display and prompt users to fix Python errors before retrying compilation.
    • Introduced a flag to optionally ignore Python errors during compilation for testing purposes.
  • Bug Fixes

    • Ensured a fresh compilation environment by cleaning up the staging directory at the start of each compile.
    • Enhanced cleanup logic to discard staging files if compilation errors occur.
  • Refactor

    • Simplified change validation by removing version bump detection and related reporting.
    • Separated change detection from user confirmation for better clarity.
    • Updated the display of changes to group and order them more intuitively by category.
    • Removed deprecated parameters from staging query configurations and updated related query definitions.
  • Chores

    • Added assertions to validate that version parameters are integers in key functions.
    • Updated test and build configurations to support ignoring Python errors during compilation.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 2, 2025

Walkthrough

This update restructures the compiler's workflow by ensuring a clean staging environment, adjusting when the compile status is displayed, and introducing a user confirmation step for in-place changes. The configuration validation logic is refactored to remove version bump detection, clarify change categories, and separate user prompts. Diff output ordering and signage are also updated for clarity. Additional assertions were added to several core functions to enforce that the version parameter is an integer.

Changes

Cohort / File(s) Change Summary
Compiler Workflow Adjustments
api/python/ai/chronon/cli/compile/compiler.py
Clears staging dir before compile, adds _has_compilation_errors method, moves compile status display before user confirmation, finalizes output only if no errors or ignoring errors, else cleans staging.
Config Validation Refactor
api/python/ai/chronon/cli/compile/conf_validator.py
Removes version bump detection and reporting, simplifies change categories, moves user confirmation prompt to new method, updates prompt text, removes version-related helpers.
Diff Output Reordering and Messaging
api/python/ai/chronon/cli/compile/display/diff_result.py
Changes updated item signage, sorts and groups diff output by category (version-bumped, added, deleted, updated) for clearer display order.
Diff Display Suppression on Errors
api/python/ai/chronon/cli/compile/display/class_tracker.py
Adds ignore_python_errors param; suppresses diff if compile errors exist and not ignoring errors; shows styled message prompting fix.
Compile Context and Status Updates
api/python/ai/chronon/cli/compile/compile_context.py, api/python/ai/chronon/cli/compile/display/compile_status.py
Adds ignore_python_errors flag to context and status rendering, propagates flag to control error ignoring behavior in diffs.
Compile Command Extension
api/python/ai/chronon/repo/compile.py
Adds --ignore-python-errors CLI flag, passes flag to compile context to optionally ignore Python errors during compilation.
Version Parameter Type Assertions
api/python/ai/chronon/group_by.py, api/python/ai/chronon/join.py, api/python/ai/chronon/staging_query.py
Adds assertions to verify version parameter is an int, raising errors if not, to enforce type correctness early.
StagingQuery and Import Signature Updates
api/python/ai/chronon/staging_query.py
Removes name and start_partition parameters from Import and StagingQuery functions and related metadata; updates docstrings and assertions accordingly.
Test and Canary JSON Updates
api/python/test/canary/compiled/staging_queries/gcp/*, api/python/test/canary/staging_queries/gcp/sample_staging_query.py, api/python/test/sample/staging_queries/*
Removes startPartition and name fields from JSON and staging query instantiations to align with signature changes.
Test Compile Update
api/python/test/test_compile.py
Updates test to call compile with ignore_python_errors=True.
tox.ini Update
api/python/tox.ini
Adds --ignore-python-errors flag to compile commands in pre-commit hooks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Compiler
    participant ConfValidator

    User->>Compiler: compile()
    Compiler->>Compiler: Clear staging dir
    Compiler->>Compiler: Compile configs
    Compiler->>ConfValidator: validate_changes()
    ConfValidator-->>Compiler: Categorized changes
    Compiler->>Compiler: Display compile status
    Compiler->>ConfValidator: check_pending_changes_confirmation()
    ConfValidator-->>Compiler: User confirms in-place changes
    alt No compilation errors or ignoring errors
        Compiler->>Compiler: Move staging to output
        Compiler->>Compiler: Compile team metadata
    else Compilation errors present and not ignored
        Compiler->>Compiler: Clean staging dir
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • nikhil-zlai
  • david-zlai

Poem

A sweep of the stage, a prompt for the wise,
Now changes in place won't slip past our eyes.
Version bumps gone, the diff's neatly arrayed—
Compile with a flourish, no detail delayed!

🚦✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f1398e5 and cbfd010.

📒 Files selected for processing (25)
  • api/python/ai/chronon/cli/compile/compile_context.py (1 hunks)
  • api/python/ai/chronon/cli/compile/compiler.py (2 hunks)
  • api/python/ai/chronon/cli/compile/conf_validator.py (4 hunks)
  • api/python/ai/chronon/cli/compile/display/class_tracker.py (1 hunks)
  • api/python/ai/chronon/cli/compile/display/compile_status.py (2 hunks)
  • api/python/ai/chronon/cli/compile/display/diff_result.py (2 hunks)
  • api/python/ai/chronon/group_by.py (1 hunks)
  • api/python/ai/chronon/join.py (1 hunks)
  • api/python/ai/chronon/repo/compile.py (3 hunks)
  • api/python/ai/chronon/staging_query.py (3 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.cart__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.item__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.order__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.payment__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.purchases_labels__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.shipping__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.terminal__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.user__0 (0 hunks)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.v1_hub__0 (0 hunks)
  • api/python/test/canary/staging_queries/gcp/sample_staging_query.py (0 hunks)
  • api/python/test/sample/staging_queries/kaggle/outbrain.py (0 hunks)
  • api/python/test/sample/staging_queries/quickstart/checkouts_external.py (0 hunks)
  • api/python/test/sample/staging_queries/sample_team/sample_staging_query.py (0 hunks)
  • api/python/test/test_compile.py (1 hunks)
  • api/python/tox.ini (1 hunks)
💤 Files with no reviewable changes (13)
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.item__0
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.payment__0
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.shipping__0
  • api/python/test/sample/staging_queries/quickstart/checkouts_external.py
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.user__0
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.order__0
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.cart__0
  • api/python/test/sample/staging_queries/kaggle/outbrain.py
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.terminal__0
  • api/python/test/sample/staging_queries/sample_team/sample_staging_query.py
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.v1_hub__0
  • api/python/test/canary/compiled/staging_queries/gcp/sample_staging_query.purchases_labels__0
  • api/python/test/canary/staging_queries/gcp/sample_staging_query.py
✅ Files skipped from review due to trivial changes (1)
  • api/python/tox.ini
🚧 Files skipped from review as they are similar to previous changes (6)
  • api/python/ai/chronon/cli/compile/compiler.py
  • api/python/ai/chronon/group_by.py
  • api/python/ai/chronon/cli/compile/display/class_tracker.py
  • api/python/ai/chronon/cli/compile/display/diff_result.py
  • api/python/ai/chronon/join.py
  • api/python/ai/chronon/staging_query.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: if `generate_anomalous_data.py` contains unintended changes due to accidental commits, disregard rev...
Learnt from: chewy-zlai
PR: zipline-ai/chronon#46
File: docker-init/generate_anomalous_data.py:0-0
Timestamp: 2024-10-15T19:03:19.403Z
Learning: If `generate_anomalous_data.py` contains unintended changes due to accidental commits, disregard reviewing this file unless instructed otherwise.

Applied to files:

  • api/python/test/test_compile.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: aggregator_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: flink_tests
  • GitHub Check: online_tests
  • GitHub Check: api_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: service_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: python_tests
  • GitHub Check: join_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: groupby_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: streaming_tests
  • GitHub Check: batch_tests
  • GitHub Check: spark_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (17)
api/python/test/test_compile.py (1)

12-12: LGTM - Test updated for new ignore_python_errors flag

Change correctly aligns with the new compilation workflow.

api/python/ai/chronon/cli/compile/compile_context.py (2)

27-27: LGTM - Constructor parameter addition

Properly accepts ignore_python_errors with appropriate default.


31-31: LGTM - Instance attribute storage

Correctly stores the ignore_python_errors flag for later use.

api/python/ai/chronon/cli/compile/display/compile_status.py (2)

66-66: LGTM - Method signature updated

Properly adds ignore_python_errors parameter with default value.


84-84: LGTM - Parameter propagation

Correctly passes ignore_python_errors to tracker.diff().

api/python/ai/chronon/repo/compile.py (5)

18-23: LGTM - CLI option addition

Well-documented flag for testing purposes with appropriate default.


24-24: LGTM - Function signature update

Correctly adds ignore_python_errors parameter to compile function.


38-38: LGTM - Parameter passing

Properly forwards ignore_python_errors to internal __compile function.


41-41: LGTM - Internal function signature

Correctly adds parameter with default value for backward compatibility.


55-55: LGTM - CompileContext instantiation

Properly passes ignore_python_errors to CompileContext constructor.

api/python/ai/chronon/cli/compile/conf_validator.py (7)

632-637: LGTM - Simplified change categorization

Removes version bump complexity, focuses on core change types.


656-667: LGTM - Deleted object detection

Proper logic for identifying removed configurations.


668-674: LGTM - Change storage for later confirmation

Good separation of concerns - store changes for deferred confirmation.


696-717: LGTM - Separated confirmation logic

Well-structured method that properly handles error conditions and user prompts.


718-723: LGTM - Compilation error detection

Clean helper method for checking compilation errors across trackers.


731-731: LGTM - Simplified ConfigChange creation

Removes version-related fields, aligns with simplified workflow.


743-748: LGTM - Improved user prompt message

More descriptive and helpful confirmation message for users.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vz/cli_fixes

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@varant-zlai varant-zlai merged commit f1d1349 into main Aug 6, 2025
21 checks passed
@varant-zlai varant-zlai deleted the vz/cli_fixes branch August 6, 2025 03:47
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.

5 participants