Skip to content

Conversation

@tchow-zlai
Copy link
Collaborator

@tchow-zlai tchow-zlai commented Jul 29, 2025

Summary

Results after this PR showing the logging:

Checklist

  • Added Unit Tests
  • Covered by existing CI
  • Integration tested
  • Documentation update

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor
    • Improved separation of configuration loading and execution logic for batch processing, resulting in a clearer and more maintainable workflow.
    • Streamlined batch processing setup by centralizing resource initialization and simplifying method interfaces for enhanced clarity and encapsulation.
    • Moved default dataset constant to a centralized location for consistent reference across components.
  • Chores
    • Simplified import statements across test and runner components to improve code readability and maintainability without affecting functionality.
    • Updated tests to instantiate batch processing runners with configuration objects for more realistic execution scenarios.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

Walkthrough

The BatchNodeRunner was refactored from a singleton object into a class taking a Node instance, centralizing TableUtils creation and removing redundant parameters. The main method was moved to a companion object, which now handles configuration loading and runner instantiation. Import statements were simplified in related test and runner files. The DefaultTablePartitionsDataset constant was moved from the NodeRunner trait to the NodeRunner companion object.

Changes

Cohort / File(s) Change Summary
BatchNodeRunner Refactor
spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
Converted singleton object to class with Node parameter; centralized TableUtils as instance variable; removed redundant parameters; moved main to companion object; updated method signatures; updated default dataset references to NodeRunner.DefaultTablePartitionsDataset.
Import Cleanup in KVUploadNodeRunner
spark/src/main/scala/ai/chronon/spark/kv_store/KVUploadNodeRunner.scala
Reordered imports; removed unused import of DefaultTablePartitionsDataset; updated default tablePartitionsDataset to use NodeRunner.DefaultTablePartitionsDataset.
Import Simplification in Tests
spark/src/test/scala/ai/chronon/spark/test/batch/ShortNamesTest.scala
Replaced multiple specific imports with a single wildcard import from ai.chronon.planner; removed unused Spark and test imports.
NodeRunner Trait Cleanup
api/src/main/scala/ai/chronon/api/planner/NodeRunner.scala
Removed DefaultTablePartitionsDataset constant from trait and moved it to companion object.
BatchNodeRunner Test Update
spark/src/test/scala/ai/chronon/spark/test/batch/BatchNodeRunnerTest.scala
Changed tests to instantiate BatchNodeRunner with deserialized Node config instead of static calls; updated dataset constant usage; no logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant BatchNodeRunner
    participant TableUtils

    CLI->>BatchNodeRunner: Parse CLI args, load Node config JSON
    CLI->>BatchNodeRunner: Instantiate BatchNodeRunner(node)
    BatchNodeRunner->>TableUtils: Initialize once per instance
    CLI->>BatchNodeRunner: runFromArgs(api, startDs, endDs, tablePartitionsDataset)
    BatchNodeRunner->>BatchNodeRunner: Execute run logic using instance TableUtils
    BatchNodeRunner->>CLI: Return exit code
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • piyush-zlai
  • varant-zlai
  • nikhil-zlai

Poem

Once a lone object ran the show,
Now a class with state in tow.
Utils held close, main moved out,
Cleaner code, no room for doubt.
Nodes load smooth, runs align,
BatchNodeRunner’s code shines fine! 🚀✨


📜 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 abdccd1 and 55190f5.

📒 Files selected for processing (2)
  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala (5 hunks)
  • spark/src/test/scala/ai/chronon/spark/test/batch/BatchNodeRunnerTest.scala (16 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • spark/src/test/scala/ai/chronon/spark/test/batch/BatchNodeRunnerTest.scala
  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
⏰ 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). (12)
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: flink_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: online_tests
  • GitHub Check: streaming_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: groupby_tests
  • GitHub Check: join_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: batch_tests
  • GitHub Check: spark_tests
  • GitHub Check: enforce_triggered_workflows
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tchow/logging-fix

🪧 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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

@tchow-zlai tchow-zlai closed this Jul 30, 2025
@tchow-zlai tchow-zlai reopened this Jul 30, 2025
@tchow-zlai tchow-zlai changed the title wip feat: Refactor BatchNodeRunner for cleaner working logging setup Jul 31, 2025
@tchow-zlai tchow-zlai changed the title feat: Refactor BatchNodeRunner for cleaner working logging setup feat: Refactor BatchNodeRunner for cleaner working logging setup ZIP-791 Jul 31, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fa1e6a and 03a8a02.

📒 Files selected for processing (3)
  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala (5 hunks)
  • spark/src/main/scala/ai/chronon/spark/kv_store/KVUploadNodeRunner.scala (1 hunks)
  • spark/src/test/scala/ai/chronon/spark/test/batch/ShortNamesTest.scala (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • spark/src/main/scala/ai/chronon/spark/kv_store/KVUploadNodeRunner.scala
  • spark/src/test/scala/ai/chronon/spark/test/batch/ShortNamesTest.scala
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: in `mockkvstore` located at `spark/src/test/scala/ai/chronon/spark/test/mockkvstore.scala`, the `mul...
Learnt from: chewy-zlai
PR: zipline-ai/chronon#50
File: spark/src/test/scala/ai/chronon/spark/test/MockKVStore.scala:19-28
Timestamp: 2024-10-31T18:29:45.027Z
Learning: In `MockKVStore` located at `spark/src/test/scala/ai/chronon/spark/test/MockKVStore.scala`, the `multiPut` method is intended to be a simple implementation without dataset existence validation, duplicate validation logic elimination, or actual storage of key-value pairs for verification.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: in the `kvstore` trait located at `online/src/main/scala/ai/chronon/online/kvstore.scala`, there are...
Learnt from: chewy-zlai
PR: zipline-ai/chronon#47
File: online/src/main/scala/ai/chronon/online/MetadataStore.scala:232-0
Timestamp: 2024-10-17T00:12:09.763Z
Learning: In the `KVStore` trait located at `online/src/main/scala/ai/chronon/online/KVStore.scala`, there are two `create` methods: `def create(dataset: String): Unit` and `def create(dataset: String, props: Map[String, Any]): Unit`. The version with `props` ignores the `props` parameter, and the simpler version without `props` is appropriate when `props` are not needed.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: in the `kvstore` trait located at `online/src/main/scala/ai/chronon/online/api.scala`, the default i...
Learnt from: piyush-zlai
PR: zipline-ai/chronon#33
File: online/src/main/scala/ai/chronon/online/Api.scala:69-69
Timestamp: 2024-10-08T16:18:45.669Z
Learning: In the `KVStore` trait located at `online/src/main/scala/ai/chronon/online/Api.scala`, the default implementation of the `create` method (`def create(dataset: String, props: Map[String, Any]): Unit = create(dataset)`) doesn't leverage the `props` parameter, but subclasses like `DynamoDBKVStoreImpl` use the `props` parameter in their overridden implementations.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: in the codebase, the `kvstore` implementation provides an implicit `executioncontext` in scope, so i...
Learnt from: piyush-zlai
PR: zipline-ai/chronon#33
File: cloud_aws/src/main/scala/ai/chronon/integrations/aws/DynamoDBKVStoreImpl.scala:29-30
Timestamp: 2024-10-08T16:18:45.669Z
Learning: In the codebase, the `KVStore` implementation provides an implicit `ExecutionContext` in scope, so it's unnecessary to import another.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: hardcoding future timestamps in tests within `dynamodbkvstoretest.scala` is acceptable when data is ...
Learnt from: piyush-zlai
PR: zipline-ai/chronon#33
File: cloud_aws/src/test/scala/ai/chronon/integrations/aws/DynamoDBKVStoreTest.scala:175-175
Timestamp: 2024-10-07T15:09:51.567Z
Learning: Hardcoding future timestamps in tests within `DynamoDBKVStoreTest.scala` is acceptable when data is generated and queried within the same time range, ensuring the tests remain valid over time.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: the bigtablekvstoreimpl in the chronon codebase only interacts with 4 bigtable tables total, so unbo...
Learnt from: piyush-zlai
PR: zipline-ai/chronon#657
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigTableKVStoreImpl.scala:93-97
Timestamp: 2025-04-21T15:10:40.819Z
Learning: The BigTableKVStoreImpl in the chronon codebase only interacts with 4 BigTable tables total, so unbounded caching in tableToContext is not a concern.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: in bigquery integration, table existence check is performed outside the bigqueryformat.createtable m...
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:29-60
Timestamp: 2025-01-24T23:55:30.256Z
Learning: In BigQuery integration, table existence check is performed outside the BigQueryFormat.createTable method, at a higher level in TableUtils.createTable.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
📚 Learning: for bigquery table creation operations in bigqueryformat.scala, allow exceptions to propagate direct...
Learnt from: tchow-zlai
PR: zipline-ai/chronon#263
File: cloud_gcp/src/main/scala/ai/chronon/integrations/cloud_gcp/BigQueryFormat.scala:56-57
Timestamp: 2025-01-24T23:55:40.650Z
Learning: For BigQuery table creation operations in BigQueryFormat.scala, allow exceptions to propagate directly without wrapping them in try-catch blocks, as the original BigQuery exceptions provide sufficient context.

Applied to files:

  • spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala
⏰ 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). (17)
  • GitHub Check: streaming_tests
  • GitHub Check: analyzer_tests
  • GitHub Check: fetcher_tests
  • GitHub Check: join_tests
  • GitHub Check: cloud_aws_tests
  • GitHub Check: batch_tests
  • GitHub Check: aggregator_tests
  • GitHub Check: spark_tests
  • GitHub Check: online_tests
  • GitHub Check: flink_tests
  • GitHub Check: service_tests
  • GitHub Check: service_commons_tests
  • GitHub Check: cloud_gcp_tests
  • GitHub Check: api_tests
  • GitHub Check: scala_compile_fmt_fix
  • GitHub Check: python_tests
  • GitHub Check: enforce_triggered_workflows
🔇 Additional comments (8)
spark/src/main/scala/ai/chronon/spark/batch/BatchNodeRunner.scala (8)

49-53: Good refactoring to class-based architecture.

Converting from singleton object to class with Node parameter improves testability and dependency injection. Centralizing TableUtils creation is clean.


55-87: Method signature simplified appropriately.

Removing tableUtils parameter makes sense since it's now an instance variable. Logic remains unchanged.


89-102: Clean parameter removal.

Method now uses instance tableUtils instead of parameter. Implementation unchanged.


104-111: Consistent with refactoring pattern.

Parameter removal and use of instance variable aligns with overall design changes.


113-138: Parameter cleanup maintained.

Removal of tableUtils parameter consistent with class-based approach.


140-171: Method signature updated correctly.

Removed redundant parameters, logic flow preserved. Good encapsulation.


173-255: Simplified method interface.

Removing confPath parameter and using constructor-provided node is cleaner. Core logic unchanged.


258-276: Well-structured companion object.

Main method properly handles configuration loading and runner instantiation. Good separation of concerns.

@tchow-zlai tchow-zlai merged commit a263093 into main Jul 31, 2025
21 checks passed
@tchow-zlai tchow-zlai deleted the tchow/logging-fix branch July 31, 2025 21:25
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.

4 participants