-
Notifications
You must be signed in to change notification settings - Fork 989
Add .coderabbit.yaml to configure automated review behavior #2765
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughA new configuration file named Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
411386e
to
4e942ce
Compare
Performance benchmarks:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 4
🔭 Outside diff range comments (2)
.coderabbit.yaml (1)
1-10
: 💡 Verification agent🧩 Analysis chain
Configuration file structure looks good, but verify GitHub checks timeout unit.
The configuration file correctly sets up CodeRabbit with version 1 and disables review status comments as requested in the PR objectives. However, there appears to be a potential issue with the GitHub checks timeout configuration.
According to the CodeRabbit schema, the timeout configuration should likely be under
reviews.tools.github-checks.timeout_ms
and the value should be in milliseconds. The current format might not be recognized correctly.version: 1 # Disable automatic 'review_status' comments on pull requests review_status: false # Increase GitHub check timeout to avoid premature reviews -github: - checks: - timeout: 180 +reviews: + tools: + github-checks: + timeout_ms: 180000
🌐 Web query:
What is the correct format for configuring GitHub check timeout in CodeRabbit's yaml configuration?
💡 Result:
Format for Configuring GitHub Check Timeout in CodeRabbit YAML
To set a timeout for GitHub checks in CodeRabbit's
.coderabbit.yaml
configuration file, use the following format under thegithub-checks
section:github-checks: enabled: true timeout_ms: 90000
- The
timeout_ms
parameter specifies the timeout in milliseconds for GitHub checks run by CodeRabbit[1].- For example,
timeout_ms: 90000
sets the timeout to 90 seconds.This format is confirmed by public
.coderabbit.yaml
files in various repositories and aligns with best practices for CodeRabbit configuration[1].Key points:
- Place the configuration at the root level of your
.coderabbit.yaml
file.- Ensure that
github-checks
is enabled for the timeout to be effective.- The timeout value must be given in milliseconds.
No additional nesting or parameters are required for this functionality in CodeRabbit YAML[1].
Citations:
- 1: https://github.com/PHAREHUB/PHARE/blob/master/.coderabbit.yaml
- 2: https://github.com/0xSpaceShard/starknet-devnet/blob/main/.coderabbit.yaml
- 3: https://docs.coderabbit.ai/platforms/github-com
- 4: https://github.com/ls1intum/Artemis/blob/develop/.coderabbit.yaml
- 5: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
- 6: https://github.com/digdir/dialogporten/blob/main/.coderabbit.yaml
- 7: https://markfontenot.net/2021/09/21/adding-timeout-to-github-actions/
- 8: https://docs.coderabbit.ai/getting-started/configure-coderabbit
- 9: https://docs.coderabbit.ai/tools/pipeline-remediation/
- 10: https://buddy.works/blog/action-timeout-yaml
Correct root-level GitHub checks timeout configuration
The
.coderabbit.yaml
schema expects a root-levelgithub-checks
key withtimeout_ms
in milliseconds. Update your config accordingly:File:
.coderabbit.yaml
Lines: 1–10version: 1 # Disable automatic 'review_status' comments on pull requests review_status: false -# Increase GitHub check timeout to avoid premature reviews -github: - checks: - timeout: 180 +# Increase GitHub check timeout to avoid premature reviews +github-checks: + enabled: true + timeout_ms: 180000Replace the nested
github.checks.timeout
(in seconds) with the root-levelgithub-checks.timeout_ms
(in milliseconds).mesa/visualization/mpl_space_drawing.py (1)
660-715
: 🛠️ Refactor suggestionScatter omits size & color, defeating custom portrayal
ax.scatter
is called withouts=
(size) orc=
/color=
, so all agents appear with
Matplotlib defaults. The portrayal data you painstakingly collect never reaches the plot.Add the missing parameters and vectorise to avoid per-marker loops when not necessary:
ax.scatter( x[logical], y[logical], marker=mark, zorder=z_order, + s=np.array([a.size for a in arguments])[logical], + c=np.array([a.color for a in arguments])[logical], edgecolors=np.array(edgecolors)[logical], linewidths=np.array(linewidths)[logical], alpha=np.array(alpha)[logical], **kwargs, )Optionally, consider a single call to
scatter
when all markers are identical to improve performance.
🧹 Nitpick comments (3)
mesa/visualization/AgentPortrayalStyle.py (1)
1-29
: Add a module docstring to explain the purpose of this new class.This is a well-structured dataclass that encapsulates agent portrayal attributes in a more consistent way than using dictionaries. The
to_dict
method provides backward compatibility with existing code.Add a module-level docstring to explain the purpose of this file and how the
AgentPortrayalStyle
class fits into the visualization system.from dataclasses import dataclass + +""" +Standardized agent portrayal style definition for visualization components. + +This module provides a structured way to define agent visualization attributes +across Mesa's visualization components, replacing the previous dictionary-based approach. +"""🧰 Tools
🪛 Ruff (0.8.2)
1-1: Missing docstring in public module
(D100)
mesa/visualization/mpl_space_drawing.py (2)
485-530
: Redundant pre-allocation & unusedscatter_data
scatter_data
and the earliers, c, marker, …
lists are built but never consumed
(Ruff F841). After the fix in_scatter
, you can delete the whole pre-allocation block:- # Pre-allocate all needed fields in one pass - ... - linewidths.append(a.linewidths) - - # Convert data for plotting - scatter_data = { - "s": [a.size for a in agent_data_list], - ... - }Cleaner code, less memory churn.
🧰 Tools
🪛 Ruff (0.8.2)
492-495: Use
agent_style.loc = pos.get(node_id, (0, 0))
instead of anif
block(SIM401)
520-520: Local variable
scatter_data
is assigned to but never usedRemove assignment to unused variable
scatter_data
(F841)
492-495
: Tiny simplificationagent_style.loc = pos.get(node_id, (0, 0))expresses the same intent without branching.
🧰 Tools
🪛 Ruff (0.8.2)
492-495: Use
agent_style.loc = pos.get(node_id, (0, 0))
instead of anif
block(SIM401)
🛑 Comments failed to post (4)
mesa/examples/advanced/sugarscape_g1mt/app.py (1)
12-12:
⚠️ Potential issueFix type mismatch in size parameter.
The
size
parameter is provided as a string"10"
, but theAgentPortrayalStyle
class definessize
as an integer with default value30
.This type mismatch could cause errors when the visualization tries to use this value. Change the size parameter to an integer:
- return AgentPortrayalStyle(color="red", marker="o", size="10") + return AgentPortrayalStyle(color="red", marker="o", size=10)📝 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.return AgentPortrayalStyle(color="red", marker="o", size=10)
mesa/visualization/components/matplotlib_components.py (1)
38-45:
⚠️ Potential issueLambda wrapper introduces infinite recursion and type-mismatch
The lambda you pass to
SpaceMatplotlib
ignores itsagent
argument and immediately callscollect_agent_data(...)
, which itself callsagent_portrayal(agent)
again inside its loop.
Flow:
draw_orthogonal_grid()
→collect_agent_data(space, lambda)
collect_agent_data
loops over everyagent
- For each
agent
calls the lambda → secondcollect_agent_data(...)
- Inner call returns a list, not a single
AgentPortrayalStyle
, so the outer call tries to access.color
,.size
, … on a list ⇒AttributeError
.Besides the recursion, the return type now violates the expectation of
collect_agent_data
, breaking all downstream drawing functions.- return SpaceMatplotlib( - model, - lambda agent: collect_agent_data(model.space, agent_portrayal), + # pass the original callable – the drawing helpers will call + # collect_agent_data themselves + return SpaceMatplotlib( + model, + agent_portrayal,📝 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.def MakeSpaceMatplotlib(model): # pass the original callable – the drawing helpers will call # collect_agent_data themselves return SpaceMatplotlib( model, agent_portrayal, propertylayer_portrayal, post_process=post_process, **space_drawing_kwargs, )
mesa/visualization/mpl_space_drawing.py (2)
357-364:
⚠️ Potential issueInvalid argument
style=
crashescollect_agent_data
collect_agent_data
no longer accepts astyle
keyword, so this call raises
TypeError: collect_agent_data() got an unexpected keyword argument 'style'
.- style = AgentPortrayalStyle() - arguments = collect_agent_data(space, agent_portrayal, style=style) + arguments = collect_agent_data(space, agent_portrayal)Remove the now-unused
s_default
variable as well to silence Ruff F841.📝 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.# gather agent data s_default = (180 / max(space.width, space.height)) ** 2 - style = AgentPortrayalStyle() - arguments = collect_agent_data(space, agent_portrayal, style=style) + arguments = collect_agent_data(space, agent_portrayal) # plot the agents _scatter(ax, arguments, **kwargs)
🧰 Tools
🪛 Ruff (0.8.2)
358-358: Local variable
s_default
is assigned to but never usedRemove assignment to unused variable
s_default
(F841)
47-122: 🛠️ Refactor suggestion
collect_agent_data
should return a list ofAgentPortrayalStyle
, not a dictAll callers (
draw_*
helpers and_scatter
) treat the result as an iterable of objects.
Current implementation builds numpy arrays and finally returns a dict, producing:
TypeError
in_scatter
which asserts every element isAgentPortrayalStyle
.- Dead code (
color_list
,size_list
, …) that is never used elsewhere.- False Ruff warnings for unused variables.
Proposed minimal fix:
@@ - color_list = [] - ... - loc_list = [] + # we only need a single container + agent_data_list: list[AgentPortrayalStyle] = [] @@ - color_list.append(portrayal.color) - ... - loc_list.append(portrayal.loc) + agent_data_list.append(portrayal) - # Convert all to numpy arrays - return { - "color": np.array(color_list), - ... - "loc": np.array(loc_list), - } + return agent_data_listThis aligns the function with its advertised behaviour and the expectations of every caller.
📝 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.def collect_agent_data( space: OrthogonalGrid | HexGrid | Network | ContinuousSpace | VoronoiGrid, agent_portrayal: Callable, default_color="tab:blue", default_size=25, default_marker="o", default_zorder: int = 1, ) -> list[AgentPortrayalStyle]: """Collect agent portrayal data efficiently in one loop.""" # We only need a single container for the AgentPortrayalStyle instances. agent_data_list: list[AgentPortrayalStyle] = [] for agent in space.agents: portrayal = agent_portrayal(agent) if portrayal is None: portrayal = AgentPortrayalStyle( color=default_color, size=default_size, marker=default_marker, zorder=default_zorder, alpha=1.0, linewidths=1.0, edgecolors="black", loc=agent.pos if agent.pos is not None else (0, 0), ) elif isinstance(portrayal, dict): warnings.warn( "Agent portrayal returned a dictionary, automatically converting to AgentPortrayalStyle. " "Consider returning an AgentPortrayalStyle instance directly.", UserWarning, ) portrayal = AgentPortrayalStyle( color=portrayal.get("color", default_color), size=portrayal.get("size", default_size), marker=portrayal.get("marker", default_marker), zorder=portrayal.get("zorder", default_zorder), alpha=portrayal.get("alpha", 1.0), linewidths=portrayal.get("linewidths", 1.0), edgecolors=portrayal.get("edgecolors", "black"), loc=agent.pos if hasattr(agent, "pos") else getattr(agent, "cell", None) and agent.cell.coordinate, ) agent_data_list.append(portrayal) return agent_data_list
🧰 Tools
🪛 Ruff (0.8.2)
56-56: Local variable
agent_data_list
is assigned to but never usedRemove assignment to unused variable
agent_data_list
(F841)
85-85: No explicit
stacklevel
keyword argument found(B028)
Thanks for the PR, but I'm curious what this minimal approach would offer over #2761. |
Summary
This PR introduces a .coderabbit.yaml configuration file to improve transparency and control over automated CodeRabbit reviews.
Bug / Issue
There was no existing configuration file for CodeRabbit, which made it hard to understand or modify its default behavior. Additionally, repetitive review_status messages and premature check timeouts were causing disruption during PR reviews.
Issue reference : #2761
Implementation
Testing
As this is a configuration-only change for a GitHub bot, no unit tests are applicable. Successful merging and observing CodeRabbit's updated behavior will confirm correctness.
Additional Notes
No dependencies or downstream impact. Please feel free to suggest other default behaviors or formatting rules to include in the config.
Summary by CodeRabbit