Skip to content

Conversation

@chenkasirer
Copy link
Member

  • Added functions warning, message, error and remark to compas_ghpython.

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@chenkasirer chenkasirer requested a review from Copilot November 4, 2025 14:15
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.25%. Comparing base (c0d480d) to head (e867244).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1501      +/-   ##
==========================================
- Coverage   62.26%   62.25%   -0.01%     
==========================================
  Files         208      208              
  Lines       22452    22452              
==========================================
- Hits        13979    13977       -2     
- Misses       8473     8475       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds utility functions for displaying messages in Grasshopper components. These functions provide a convenient API for adding warnings, errors, remarks, and custom messages to GH components across different Rhino versions.

  • Adds four new helper functions: warning, error, remark, and message to compas_ghpython
  • Imports the Grasshopper module at the package level in a try-except block
  • Updates the CHANGELOG to document the new additions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/compas_ghpython/init.py Adds Grasshopper import and four new message helper functions with documentation
CHANGELOG.md Documents the addition of the new message functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

message : str
The message to display.
"""
component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Warning, message)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.

Copilot uses AI. Check for mistakes.
message : str
The message to display.
"""
component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, message)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.

Copilot uses AI. Check for mistakes.
message : str
The message to display.
"""
component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Remark, message)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The function uses Grasshopper.Kernel.GH_RuntimeMessageLevel directly, but Grasshopper may be undefined if the import at line 12 failed. This will cause a NameError at runtime. Consider adding a check or raising a more informative error if Grasshopper is not available, or ensure these functions are only callable in Grasshopper contexts.

Copilot uses AI. Check for mistakes.

try:
import Grasshopper
except ImportError:
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except ImportError:
except ImportError:
# Grasshopper is not available in this environment; safe to ignore.

Copilot uses AI. Check for mistakes.
@tomvanmele
Copy link
Member

@chenkasirer what about the copilot suggestions?

@chenkasirer
Copy link
Member Author

@chenkasirer what about the copilot suggestions?

I added a comment in the except block.
shouldn't imports to Rhino/Grasshopper in root level modules just fail silently?
clearly calling any of these functions outside grasshopper will fail, or should i add some kind of error handling?

Copy link
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

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

LGTM

@chenkasirer chenkasirer merged commit 565586e into main Nov 6, 2025
17 of 18 checks passed
@chenkasirer chenkasirer deleted the gh_helpers branch November 6, 2025 09:02
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