Debugging your function

When developing a Hypar function, it's useful to try it out in the context of a real workflow, so that you're not developing in a vacuum. We've added some new features to make this process more streamlined.
Once you've set up your function definition — even before you've finished developing it — you may want to test it with inputs and elements from a live Hypar workflow. This is especially useful when building a function that depends on other functions, as described in
🔌
Connecting to other functions
.
To test your function in a workflow, choose Test Function on Hypar from the Hypar panel.
notion image
You'll have the option to specify either an existing workflow, or create a new one.

Option 1 - New Workflow

Most of the time, you'll want to create a new workflow to test with.
notion image
Choose a name and select Create and Open in Browser:
notion image
A new browser window should open with a new workflow containing your function.

Option 2 - Existing Workflow

If you already have a workflow you want to test with, choose Test in an existing workflow.
notion image
Open up your workflow on Hypar, and go to the menu in the upper right — select Test a Local Function
notion image
Click the button to copy the command:
notion image
Then return to Grasshopper to paste in the dialog:
notion image
Click Connect to Workflow to start a test session.

Testing your Function

While your local function is connected to the workflow, it will respond automatically to updates in the workflow, even if you have yet to publish the Grasshopper logic for your function. If you update a model dependency, or an input on your function, the Inputs component in your definition will feed those changes into your definition, so you can test with real data. You can stop testing at any time and return to "local" mode, where the Inputs component just feeds through whatever you provide it.
notion image
 
If you have model dependencies, you're likely to find that each dependency on your Inputs component contains multiple element types:
notion image
To make this easier to work with, use the Elements By Type component.
notion image
Then you can safely use Deconstruct Element to access the elements coming in from other functions. Just connect it and it will automatically add the relevant outputs.
notion image
When you're finished debugging your function, be sure to update it on Hypar by choosing "Publish function to Hypar" in the Hypar Panel.
notion image

Passing Error messages to the UI

By default, any components with an error message will pass that error message along to the Hypar UI, to help you debug.
You can also produce custom messages and feed them into the Output Messages component:
notion image
notion image
 
💡
If you want to suppress an error or warning from another component, you can cluster it to keep the message from being passed to the Hypar UI.