Skip to content

Use default_num_points when available #3774

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Sbozzolo
Copy link
Member

ClimaDiagnostics introduced a function to compute the default number of points for the NetCDFWriter. This commit uses this new function when available.

Copy link

coderabbitai bot commented Apr 15, 2025

Walkthrough

The update removes inline logic for estimating the number of NetCDF points in get_callbacks.jl and replaces it with a call to default_netcdf_points. This function is newly defined in compat.jl with behavior conditional on the ClimaDiagnostics version: for versions before 0.2.14, it calculates points based on processor count and configuration type; for 0.2.14 and later, it delegates to ClimaDiagnostics.Writers.default_num_points. Additionally, several package dependencies are bumped, including ClimaDiagnostics to 0.2.14. No changes were made to public function signatures or exports.

Suggested labels

dependencies

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 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 304c4f3 and 54862bd.

📒 Files selected for processing (3)
  • .buildkite/Manifest-v1.11.toml (5 hunks)
  • src/callbacks/get_callbacks.jl (1 hunks)
  • src/compat.jl (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/callbacks/get_callbacks.jl
  • src/compat.jl
  • .buildkite/Manifest-v1.11.toml
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: ci 1.11 - macOS-latest
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - macOS-latest
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: test (1.10)
  • GitHub Check: test (1.11)
  • GitHub Check: downstream ClimaCoupler.jl (1.10)
  • GitHub Check: downstream ClimaCoupler.jl (1.11)
  • GitHub Check: docbuild
  • GitHub Check: evaluate

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 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.

Copy link

@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: 2

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0628793 and 5a74ee6.

📒 Files selected for processing (2)
  • src/callbacks/get_callbacks.jl (1 hunks)
  • src/compat.jl (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: ci 1.11 - macOS-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: downstream ClimaCoupler.jl (1.11)
  • GitHub Check: downstream ClimaCoupler.jl (1.10)
  • GitHub Check: ci 1.10 - macOS-latest
  • GitHub Check: test (1.11)
  • GitHub Check: evaluate
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: test (1.10)
  • GitHub Check: docbuild
  • GitHub Check: format

@Sbozzolo Sbozzolo force-pushed the gb/default_num_points branch 3 times, most recently from 59ba581 to 15f03a1 Compare April 15, 2025 17:21
@nefrathenrici
Copy link
Member

@Sbozzolo Is there a reason this hasn't been reviewed/merged?

@Sbozzolo
Copy link
Member Author

@Sbozzolo Is there a reason this hasn't been reviewed/merged?

I ran into this problem with the macOS test and I couldn't debug it. I'll rebase and see if now this works

@Sbozzolo Sbozzolo force-pushed the gb/default_num_points branch 2 times, most recently from 2cbe413 to 304c4f3 Compare May 20, 2025 23:03
Copy link

@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

🧹 Nitpick comments (1)
src/compat.jl (1)

121-122: Improve error message specificity

The current error message doesn't indicate which config value caused the error.

-            error("Uncaught case")
+            error("Uncaught config case: $(parsed_args["config"])")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2cbe413 and 304c4f3.

📒 Files selected for processing (3)
  • .buildkite/Manifest-v1.11.toml (5 hunks)
  • src/callbacks/get_callbacks.jl (1 hunks)
  • src/compat.jl (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .buildkite/Manifest-v1.11.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/callbacks/get_callbacks.jl
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: test (1.10)
  • GitHub Check: test (1.11)
  • GitHub Check: evaluate
  • GitHub Check: docbuild
  • GitHub Check: ci 1.11 - windows-latest
  • GitHub Check: downstream ClimaCoupler.jl (1.11)
  • GitHub Check: downstream ClimaCoupler.jl (1.10)
  • GitHub Check: ci 1.10 - ubuntu-latest
  • GitHub Check: ci 1.11 - ubuntu-latest
  • GitHub Check: ci 1.10 - windows-latest
  • GitHub Check: ci 1.10 - macOS-latest
  • GitHub Check: ci 1.11 - macOS-latest
🔇 Additional comments (2)
src/compat.jl (2)

4-4: Good import addition for ClimaDiagnostics

This import is necessary for the new version-dependent functionality.


126-128: Good use of newer ClimaDiagnostics API

The function correctly delegates to the new ClimaDiagnostics function when available, which centralizes the calculation logic.

Comment on lines +101 to +129
if pkgversion(ClimaDiagnostics) < v"0.2.14"
function default_netcdf_points(space, parsed_args)
# Estimate the number of points we need to cover the entire domain
# ncolumns is the number of local columns
tot_num_columns =
ClimaComms.nprocs(ClimaComms.context(space)) *
Fields.ncolumns(space)
if parsed_args["config"] == "plane"
num1, num2 = tot_num_columns, 0
elseif parsed_args["config"] == "sphere"
num2 = round(Int, sqrt(tot_num_columns / 2))
num1 = 2num2
elseif parsed_args["config"] == "box"
num2 = round(Int, sqrt(tot_num_columns))
num1 = num2
elseif parsed_args["config"] == "column"
# We need at least two points horizontally because our column is
# actually a box
num1, num2 = 2, 2
else
error("Uncaught case")
end
return (num1, num2, Spaces.nlevels(space))
end
else
function default_netcdf_points(space, _)
return ClimaDiagnostics.Writers.default_num_points(space)
end
end
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Missing imports for Fields and ClimaComms

The function uses ClimaComms and Fields modules but there are no corresponding import statements visible in this file.


🏁 Script executed:

#!/bin/bash
# Check if Fields and ClimaComms are imported elsewhere
grep -r "import.*Fields" --include="*.jl" .
grep -r "import.*ClimaComms" --include="*.jl" .

Length of output: 5776


Let’s inspect the top of src/compat.jl for any import/using statements:


🏁 Script executed:

#!/bin/bash
grep -n '^import' src/compat.jl
grep -n '^using' src/compat.jl

Length of output: 199


Add missing imports for Fields and ClimaComms

The default_netcdf_points function calls Fields.ncolumns and ClimaComms.nprocs/ClimaComms.context, but neither module is imported in src/compat.jl.

• File: src/compat.jl – at the top, alongside the other import statements
• Add:

 import ClimaCore
+import ClimaCore: Fields
+import ClimaComms
 import ClimaUtilities
 import ClimaCore: Domains, Spaces, Topologies
 import ClimaDiagnostics
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if pkgversion(ClimaDiagnostics) < v"0.2.14"
function default_netcdf_points(space, parsed_args)
# Estimate the number of points we need to cover the entire domain
# ncolumns is the number of local columns
tot_num_columns =
ClimaComms.nprocs(ClimaComms.context(space)) *
Fields.ncolumns(space)
if parsed_args["config"] == "plane"
num1, num2 = tot_num_columns, 0
elseif parsed_args["config"] == "sphere"
num2 = round(Int, sqrt(tot_num_columns / 2))
num1 = 2num2
elseif parsed_args["config"] == "box"
num2 = round(Int, sqrt(tot_num_columns))
num1 = num2
elseif parsed_args["config"] == "column"
# We need at least two points horizontally because our column is
# actually a box
num1, num2 = 2, 2
else
error("Uncaught case")
end
return (num1, num2, Spaces.nlevels(space))
end
else
function default_netcdf_points(space, _)
return ClimaDiagnostics.Writers.default_num_points(space)
end
end
# At the top of src/compat.jl, alongside the other imports:
import ClimaCore
+import ClimaCore: Fields
+import ClimaComms
import ClimaUtilities
import ClimaCore: Domains, Spaces, Topologies
import ClimaDiagnostics
🤖 Prompt for AI Agents
In src/compat.jl around lines 101 to 129, the function default_netcdf_points
uses the Fields and ClimaComms modules but these are not imported in the file.
To fix this, add import statements for Fields and ClimaComms at the top of
src/compat.jl alongside the existing imports. This will ensure the function can
access Fields.ncolumns and ClimaComms.nprocs/context without errors.

`ClimaDiagnostics` introduced a function to compute the default number
of points for the NetCDFWriter. This commit uses this new function when
available.
@Sbozzolo Sbozzolo force-pushed the gb/default_num_points branch from 304c4f3 to 54862bd Compare May 20, 2025 23:30
@Sbozzolo
Copy link
Member Author

This uncovered an edge case in ClimaAnalysis. It got fixed in CliMA/ClimaAnalysis.jl@b014f0a
but it will need a new release

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