From 85662fd6c3c1f2c1331b2ade0928210133704e4a Mon Sep 17 00:00:00 2001 From: hexbabe Date: Thu, 30 Nov 2023 17:55:18 -0500 Subject: [PATCH] Add clarifying code comments and improve README --- README.md | 18 ++++++++++-------- src/__init__.py | 2 +- src/main.py | 1 + src/module.py | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index ee9d6e5..104cbfa 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is an example of using AppImageBuilder to bundle a Python module as an AppImage (only supported on AArch64 for now), and then running it on a robot. Use this as a reference for: -- An alternative to managing Python version/dependencies directly +- An alternative to managing Python version/dependencies directly for your robot. ## Robot config @@ -15,13 +15,15 @@ TODO: add example config after the module is on the registry ## Quick tour of this repo -- `packaging/`: The directory containing the Dockerfile that configures the Docker image for the builder, the AppImageBuilder.yml config file, and the icon -- `src/`: Python code for the Viam module +- `packaging/`: the directory containing the Dockerfile that configures the Docker image to run the builder in, the AppImageBuilder.yml config file, and the icon +- `src/`: Python module code for the Viam module - `Makefile`: `make` commands to build the module in different ways -- `meta.json`: The metadata config file used when uploading/updating module info on the registry -- `requirements.txt`: List of Python dependencies -- `run.sh`: The entrypoint execution script that starts up the module process +- `meta.json`: the metadata config file used when uploading/updating module info on the registry +- `requirements.txt`: list of Python packages the module depends on +- `run.sh`: the entrypoint execution script that starts up the module process -## Forking this repo +## Using this repo as boilerplate -If you fork this and want to deploy to a robot, you'll need to change all placeholder variables, references to 'viam', and optionally set up secrets for CI. Follow the [fork instructions](https://github.com/viam-labs/python-example-module#forking-this-repo) from the Python example repo. +If you fork this and want to deploy to a robot, you'll need to change all placeholder names and references to the [viam namespace](https://docs.viam.com/appendix/glossary/#term-model-namespace-triplet). Follow the [fork instructions](https://github.com/viam-labs/python-example-module#forking-this-repo) from the Python example repo. + +If you aren't making a camera module, you may want to use a different component's repo along with this repo as boilerplate in place of the `src` folder. When doing this, make sure to maintain the structure of a Python module i.e. keeping the outermost `__init__.py` to ensure the build doesn't break. Moreover, in this case, be sure to update your `meta.json` with the updated models. diff --git a/src/__init__.py b/src/__init__.py index c28a2e9..f78584e 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1,7 +1,7 @@ """ This file registers the model with the Python SDK. """ - +# usage of camera type is arbitrary; refactor to your desired component/service from viam.components.camera import Camera from viam.resource.registry import Registry, ResourceCreatorRegistration diff --git a/src/main.py b/src/main.py index 171ab13..374fe72 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,6 @@ import asyncio +# usage of camera type is arbitrary; refactor to your desired component/service from viam.components.camera import Camera from viam.logging import getLogger from viam.module.module import Module diff --git a/src/module.py b/src/module.py index a2253b5..c476e05 100644 --- a/src/module.py +++ b/src/module.py @@ -15,7 +15,7 @@ from viam.resource.types import Model, ModelFamily LOGGER = getLogger(__name__) - +# usage of camera type is arbitrary; refactor to your desired component/service class MyModule(Camera, Reconfigurable): # use a better name than this """ Camera represents any physical hardware that can capture frames.