Skip to content

Commit 9950ed0

Browse files
committed
feat: initial working control module
0 parents  commit 9950ed0

File tree

9 files changed

+466
-0
lines changed

9 files changed

+466
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# see https://github.com/viamrobotics/build-action for help
2+
on:
3+
release:
4+
types:
5+
- released
6+
workflow_dispatch:
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Download viam-cli
14+
run: |
15+
curl -L -o ./viam-cli "https://storage.googleapis.com/packages.viam.com/apps/viam-cli/viam-cli-latest-linux-amd64"
16+
chmod +x ./viam-cli
17+
- name: Update module meta.json in registry
18+
env:
19+
API_KEY_ID: ${{ secrets.viam_key_id }}
20+
API_KEY: ${{ secrets.viam_key_value }}
21+
run: |
22+
./viam-cli login api-key --key-id "$API_KEY_ID" --key "$API_KEY"
23+
./viam-cli module update
24+
- uses: viamrobotics/build-action@v1
25+
with:
26+
# note: you can replace this line with 'version: ""' if
27+
# you want to test the build process without deploying
28+
version: ${{ github.ref_name }}
29+
ref: ${{ github.sha }}
30+
key-id: ${{ secrets.viam_key_id }}
31+
key-value: ${{ secrets.viam_key_value }}
32+
token: ${{ github.token }} # only required for private git repos

.gitignore

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# https://github.com/github/gitignore/blob/main/Python.gitignore
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# poetry
99+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100+
# This is especially recommended for binary packages to ensure reproducibility, and is more
101+
# commonly ignored for libraries.
102+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103+
#poetry.lock
104+
105+
# pdm
106+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107+
#pdm.lock
108+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109+
# in version control.
110+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111+
.pdm.toml
112+
.pdm-python
113+
.pdm-build/
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.venv
128+
env/
129+
venv/
130+
ENV/
131+
env.bak/
132+
venv.bak/
133+
.installed
134+
135+
# Spyder project settings
136+
.spyderproject
137+
.spyproject
138+
139+
# Rope project settings
140+
.ropeproject
141+
142+
# mkdocs documentation
143+
/site
144+
145+
# mypy
146+
.mypy_cache/
147+
.dmypy.json
148+
dmypy.json
149+
150+
# Pyre type checker
151+
.pyre/
152+
153+
# pytype static type analyzer
154+
.pytype/
155+
156+
# Cython debug symbols
157+
cython_debug/
158+
159+
# PyCharm
160+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162+
# and can be added to the global gitignore or merged into this file. For a more nuclear
163+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
164+
#.idea/

.viam-gen-info

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"module_name": "refill-controller",
3+
"namespace": "viam-demo",
4+
"language": "python",
5+
"resource_type": "service",
6+
"resource_subtype": "generic",
7+
"model_name": "refiller",
8+
"enable_cloud_build": true,
9+
"initialize_git": false,
10+
"generator_version": "0.1.0",
11+
"generated_on": "2025-01-29T21:41:12.10181Z"
12+
}

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
setup:
2+
./setup.sh
3+
4+
dist/archive.tar.gz: setup
5+
./build.sh

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
cd $(dirname $0)
3+
4+
# Create a virtual environment to run our code
5+
VENV_NAME=".venv"
6+
PYTHON="$VENV_NAME/bin/python"
7+
8+
export PATH=$PATH:$HOME/.local/bin
9+
10+
if ! uv pip install pyinstaller -Uq; then
11+
exit 1
12+
fi
13+
14+
uv run pyinstaller --onefile --hidden-import="googleapiclient" src/main.py
15+
tar -czvf dist/archive.tar.gz ./dist/main meta.json

meta.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://dl.viam.dev/module.schema.json",
3+
"module_id": "viam-demo:refill-controller",
4+
"visibility": "private",
5+
"url": "",
6+
"description": "Modular generic service: refiller",
7+
"models": [
8+
{
9+
"api": "rdk:service:generic",
10+
"model": "viam-demo:refill-controller:refiller"
11+
}
12+
],
13+
"entrypoint": "dist/main",
14+
"first_run": "",
15+
"build": {
16+
"build": "./build.sh",
17+
"setup": "./setup.sh",
18+
"path": "dist/archive.tar.gz",
19+
"arch": [
20+
"linux/amd64",
21+
"linux/arm64"
22+
]
23+
}
24+
}

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
viam-sdk==0.38.0
3+
4+
typing-extensions

setup.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
cd $(dirname $0)
3+
4+
# Create a virtual environment to run our code
5+
VENV_NAME=".venv"
6+
PYTHON="$VENV_NAME/bin/python"
7+
ENV_ERROR="This module requires Python >=3.8, pip, and virtualenv to be installed."
8+
9+
export PATH=$PATH:$HOME/.local/bin
10+
11+
if [ ! "$(command -v uv)" ]; then
12+
if [ ! "$(command -v curl)" ]; then
13+
echo "curl is required to install UV. please install curl on this system to continue."
14+
exit 1
15+
fi
16+
echo "Installing uv command"
17+
curl -LsSf https://astral.sh/uv/install.sh | sh
18+
fi
19+
20+
if ! uv venv $VENV_NAME; then
21+
echo "unable to create required virtual environment"
22+
exit 1
23+
fi
24+
25+
if ! uv pip install -r requirements.txt; then
26+
echo "unable to sync requirements to venv"
27+
exit 1
28+
fi

0 commit comments

Comments
 (0)