Part 4: Test your module locally Part 4 of 5 | ⏱️ 20 minutes
What you’ll do in this part Add your module to a test machine using hot reload Configure your camera component Test the camera in the Viam app Learn the iteration workflow Troubleshoot common issues You can test your module locally before uploading it to the registry .
Test with hot reload (recommended) Hot reload is the fastest way to test your module. It automatically builds your module and deploys it to your machine for testing.
Why hot reload? Hot reload handles cross-compilation automatically, so you can develop on your laptop (macOS/Windows) and test on a Raspberry Pi (Linux ARM) without any extra tools.
Add module to your machine Run the following command from your module directory to build and deploy your module:
If you’re developing on the same device where viam-server is running:
viam module reload-local --cloud-config /path/to/viam.json
Replace /path/to/viam.json with the path to your machine’s cloud config file (usually in /etc/viam/ on Linux or downloaded from the Viam app).
If you’re developing on a different device from where viam-server is running:
viam module reload --part-id 123abc45-1234-432c-aabc-z1y111x23a00
Replace the part ID with your machine’s part ID. Find it by:
Go to your machine’s page in the Viam app Click the Live indicator Click Part ID to copy it For more information, see the viam module CLI documentation .
The command will:
Build your module using your local architecture or the target machine’s architecture Package it with all dependencies Use the shell service to copy it to your machine Restart the module automatically Success! You may need to refresh your machine page in the Viam app for your module to appear.
Troubleshooting hot reload Error: Could not connect to machine part: context deadline exceeded
Try specifying the --part-id explicitly (find it on your machine’s page by clicking Live → Part ID ).
Error: Rpc error: code = Unknown desc = stat /root/.viam/packages-local: no such file or directory
Try specifying the --home directory:
viam module reload --part-id YOUR_PART_ID --home /Users/yourname/
Error: Error while refreshing token, logging out. Please log in again
Run viam login to reauthenticate the CLI.
Still having problems?
You can use manual testing (see below) as an alternative.
Alternative: Manual testing If hot reload isn’t working, you can manually add your module:
Navigate to your machine’s CONFIGURE page Click the + button, select Local module , then select Local module again Enter the path to the run.sh script, for example: /home/yourname/hello-world/run.sh Click Create Save the config For local modules, viam-server uses this path to start the module.
From your module directory, compile your module:
viam module build local
Navigate to your machine’s CONFIGURE page
Click the + button, select Local module , then select Local module again
Enter the path to the executable, for example: /home/yourname/hello-world/bin/hello-world
Click Create
Save the config
For local modules, viam-server uses this path to start the module.
Configure your component Now that your module is added to your machine, configure a component that uses it:
On your machine’s CONFIGURE page, click + Select Local module , then Local component Enter the model namespace triplet , for example: exampleorg:hello-world:hello-cameraYou can find this in the model field of your meta.json file Select Camera as the Type Enter a Name, such as camera-1 Click Create Add configuration attributes In the configuration panel that appears, add your model’s required attributes.
For the camera model, replace {} with:
{
"image_path": "/path/to/your/image.png"
}
Replace /path/to/your/image.png with an actual path to an image file on your machine.
Tip Make sure the image file exists and viam-server has permission to read it!
Save the config and wait a few seconds for it to apply.
Test your component Click the TEST section at the bottom of your camera’s configuration card.
If everything is working correctly, you should see your image displayed in the test panel!
If you see errors Errors will appear in:
The configuration panel (red banner) The LOGS tab (click LOGS in the top navigation) Common issues:
“Missing image_path attribute” : Add image_path to your config JSON“Error opening image” : Check that the file path is correct and readableModule not found : Refresh the page or restart the moduleIterate on your module Each time you make changes to your module code, update it on your machine:
Run the reload command again:
viam module reload-local --cloud-config /path/to/viam.json
viam module reload --part-id 123abc45-1234-432c-aabc-z1y111x23a00
Your machine may already have a previously published version of the module you’re iterating on. If so, you can toggle Hot Reloading on and off in the module’s configuration card in the Viam app:
On : Uses your local development versionOff : Uses the published registry versionSave your code changes, then restart the module in your machine’s CONFIGURE tab:
Find the module’s card Click the … menu in the upper-right corner Click Restart Rebuild your module:
viam module build local
Restart it in your machine’s CONFIGURE tab:
Find the module’s card Click the … menu Click Restart Development workflow The typical development cycle:
Edit code in your module filesReload/restart the module on your machineTest using the TEST panel or Viam appCheck logs if something doesn’t workRepeat until it works as expectedDebugging tip
Use logging in your module code to help debug. Logs appear in the LOGS tab in the Viam app.
Python: logger.info("Message")
Go: logger.Info("Message")
What you’ve accomplished ✅ Module deployed:
Used hot reload to build and deploy your module Module running on a real machine ✅ Component configured:
Added camera component with proper configuration Verified configuration validation works ✅ Testing complete:
Tested camera in Viam app Confirmed images are returned correctly ✅ Ready for more:
Understand the iteration workflow Know how to debug issues Next steps Your module works! Now you have two options:
Ready to deploy? Once you’ve thoroughly tested your module, continue to Package and deploy your module to upload it to the registryWant to add more models? Continue to Part 5: Multiple models to learn how to add the sensor model to your moduleTutorial navigation:
Ask AI
Was this page helpful?
Yes
No Glad to hear it! If you have any other feedback please let us know:
Send
We're sorry about that. To help us improve, please tell us what we can do better:
Send