Skip to content

Commit 42fefc9

Browse files
Merge pull request #1 from AD-SDL/madsci
Deploy MADSci Beta 1 Version
2 parents 11e811d + 40936ef commit 42fefc9

10 files changed

Lines changed: 1265 additions & 2 deletions

File tree

.github/workflows/docker.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Docker Image Build and Publish
2+
3+
on:
4+
push: # * Run for every push
5+
branches: [ "*" ]
6+
tags: [ '*' ]
7+
schedule: # Run on Tuesday's at 12:00
8+
- cron: '0 12 * * 2'
9+
workflow_dispatch: # Run manually
10+
11+
env:
12+
# Use docker.io for Docker Hub if empty
13+
REGISTRY: ghcr.io
14+
# github.repository as <account>/<repo>
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
18+
jobs:
19+
build_and_publish:
20+
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v3
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v2
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v2
35+
36+
# Login against a Docker registry
37+
# https://github.com/docker/login-action
38+
- name: Log into registry ${{ env.REGISTRY }}
39+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
# Extract metadata (tags, labels) for Docker
46+
# https://github.com/docker/metadata-action
47+
- name: Extract Docker metadata
48+
id: meta
49+
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+
tags: |
53+
type=schedule
54+
type=ref,event=branch
55+
type=ref,event=tag
56+
type=ref,event=pr
57+
type=raw,value=latest,enable={{is_default_branch}}
58+
59+
# Build and push Docker image with Buildx
60+
# https://github.com/docker/build-push-action
61+
- name: Build and push Docker image
62+
id: build-and-push
63+
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
64+
with:
65+
context: .
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}
69+
platforms: linux/amd64,linux/arm64
70+
cache-from: type=gha
71+
cache-to: type=gha,mode=max

.github/workflows/pre-commit.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Pre-Commit Checks
2+
3+
on:
4+
push: # Run for every push
5+
branches: ["*"]
6+
tags: ["*"]
7+
workflow_dispatch: # Run manually
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
name: Checkout code
15+
- uses: actions/setup-python@v4
16+
name: Setup Python
17+
with:
18+
python-version: 3.9
19+
- uses: pre-commit/action@v3.0.1
20+
name: Run Pre-Commit Checks

.justfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# List available commands
2+
default:
3+
@just --list --justfile {{justfile()}}
4+
5+
# initialize the project
6+
init:
7+
@which pdm || echo "pdm not found, you'll need to install it: https://github.com/pdm-project/pdm"
8+
@pdm install -G:all
9+
@OSTYPE="" . .venv/bin/activate
10+
@which pre-commit && pre-commit install && pre-commit autoupdate || true
11+
12+
# Build the project
13+
build: init dcb
14+
15+
# Run the pre-commit checks
16+
checks:
17+
@pre-commit run --all-files || { echo "Checking fixes\n" ; pre-commit run --all-files; }
18+
check: checks
19+
20+
# Run automated tests
21+
test:
22+
@pytest
23+
tests: test
24+
pytest: test
25+
26+
# Build docker image
27+
dcb:
28+
@docker compose build

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
- id: nbstripout
1717
- repo: https://github.com/astral-sh/ruff-pre-commit
1818
# Ruff version.
19-
rev: v0.9.9
19+
rev: v0.11.5
2020
hooks:
2121
# Run the linter.
2222
- id: ruff

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM ghcr.io/ad-sdl/madsci
2+
3+
LABEL org.opencontainers.image.source=https://github.com/AD-SDL/hudson_platecrane_module
4+
LABEL org.opencontainers.image.description="Drivers and REST API's for the Hudson Platecrane and Sciclops robots"
5+
LABEL org.opencontainers.image.licenses=MIT
6+
7+
#########################################
8+
# Module specific logic goes below here #
9+
#########################################
10+
11+
RUN apt update && apt install -y libusb-1.0-0-dev && rm -rf /var/lib/apt/lists/*
12+
13+
RUN mkdir -p sciclops_module
14+
15+
COPY ./src sciclops_module/src
16+
COPY ./README.md sciclops_module/README.md
17+
COPY ./pyproject.toml sciclops_module/pyproject.toml
18+
19+
RUN --mount=type=cache,target=/root/.cache \
20+
pip install -e ./sciclops_module
21+
22+
RUN usermod -aG dialout madsci
23+
24+
CMD ["python", "-,", "sciclops_rest_node"]
25+
#########################################

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
11
# sciclops_module
2-
A MADSci node module for interfacing with the Hudson Robotics Sciclops Platecrane
2+
3+
A MADSci Node module for interfacing with the Hudson Robotics Sciclops Platecrane.
4+
5+
## Installation and Usage
6+
7+
### Python
8+
9+
```bash
10+
# Create a virtual environment named .venv
11+
python -m venv .venv
12+
# Activate the virtual environment on Linux or macOS
13+
source .venv/bin/activate
14+
# Alternatively, activate the virtual environment on Windows
15+
# .venv\Scripts\activate
16+
# Install the module and dependencies in the venv
17+
pip install .
18+
# Run the environment
19+
python -m sciclops_rest_node --host 127.0.0.1 --port 2000
20+
```
21+
22+
### Docker
23+
24+
- We provide a `Dockerfile` and example docker compose file (`compose.yaml`) to run this node dockerized.
25+
- There is also a pre-built image available as `ghcr.io/ad-sdl/sciclops_module`.
26+
- You can control the container user's id and group id by setting the `USER_ID` and `GROUP_ID`

compose.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: sciclops_node
2+
services:
3+
sciclops:
4+
container_name: sciclops
5+
image: ghcr.io/ad-sdl/sciclops_module
6+
build:
7+
context: .
8+
dockerfile: Dockerfile
9+
tags:
10+
- ghcr.io/ad-sdl/sciclops_module:latest
11+
- ghcr.io/ad-sdl/sciclops_module:dev
12+
command: python -m sciclops_rest_node
13+
privileged: true
14+
network_mode: host
15+
volumes:
16+
- ./definitions:/home/madsci/definitions

pyproject.toml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
[project]
2+
name = "hudson_platecrane_module"
3+
version = "1.5.0"
4+
description = "Driver for the Platecrane and Sciclops"
5+
authors = [
6+
{name = "Ryan D. Lewis", email="ryan.lewis@anl.gov"},
7+
{name = "Rafael Vescovi", email="ravescovi@anl.gov"},
8+
{name = "Doga Ozgulbas", email="dozgulbas@anl.gov"},
9+
{name = "Abe Stroka", email="astroka@anl.gov"},
10+
{name = "Kyle Hippe", email = "khippe@anl.gov"},
11+
{name = "Tobias Ginsburg", email = "tginsburg@anl.gov"},
12+
]
13+
dependencies = [
14+
"fastapi>=0.103",
15+
"uvicorn>=0.14.0",
16+
"pyusb",
17+
"libusb",
18+
"pyserial",
19+
"madsci.node_module>=0.1.9",
20+
"pydantic>=2.7",
21+
"pytest"
22+
]
23+
requires-python = ">=3.9.1"
24+
readme = "README.md"
25+
license = {text = "MIT"}
26+
27+
[project.urls]
28+
homepage = "https://github.com/AD-SDL/sciclops_module"
29+
30+
######################
31+
# Build Info + Tools #
32+
######################
33+
[build-system]
34+
requires = ["setuptools", "wheel"]
35+
build-backend = "setuptools.build_meta"
36+
37+
#####################
38+
# Development Tools #
39+
#####################
40+
41+
[tool.ruff]
42+
# https://docs.astral.sh/ruff/configuration/
43+
44+
# Exclude a variety of commonly ignored directories.
45+
exclude = [
46+
".bzr",
47+
".direnv",
48+
".eggs",
49+
".git",
50+
".git-rewrite",
51+
".hg",
52+
".mypy_cache",
53+
".nox",
54+
".pants.d",
55+
".pytype",
56+
".ruff_cache",
57+
".svn",
58+
".tox",
59+
".venv",
60+
"__pypackages__",
61+
"_build",
62+
"buck-out",
63+
"build",
64+
"dist",
65+
"node_modules",
66+
"venv",
67+
"docs",
68+
]
69+
70+
# Same as Black.
71+
line-length = 88
72+
indent-width = 4
73+
74+
# Assume Python 3.8
75+
target-version = "py38"
76+
77+
[tool.ruff.lint]
78+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
79+
select = [
80+
# pycodestyle
81+
"E",
82+
# Pyflakes
83+
"F",
84+
# pyupgrade
85+
# "UP",
86+
# flake8-bugbear
87+
"B",
88+
# flake8-simplify
89+
# "SIM",
90+
# isort
91+
"I",
92+
# Warning
93+
"W",
94+
# pydocstyle
95+
"D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107",
96+
# ruff
97+
# "RUF"
98+
]
99+
ignore = [
100+
"E501" # Line too long
101+
]
102+
103+
# Allow fix for all enabled rules (when `--fix`) is provided.
104+
fixable = ["ALL"]
105+
unfixable = []
106+
107+
# Allow unused variables when underscore-prefixed.
108+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
109+
110+
[tool.ruff.format]
111+
# Like Black, use double quotes for strings.
112+
quote-style = "double"
113+
114+
# Like Black, indent with spaces, rather than tabs.
115+
indent-style = "space"
116+
117+
# Like Black, respect magic trailing commas.
118+
skip-magic-trailing-comma = false
119+
120+
# Like Black, automatically detect the appropriate line ending.
121+
line-ending = "auto"
122+
123+
[tool.pytest.ini_options]
124+
# https://docs.pytest.org/en/stable/customize.html
125+
addopts = "-x"
126+
junit_family="xunit1"
127+
filterwarnings = [
128+
"ignore::DeprecationWarning",
129+
"ignore::pottery.exceptions.InefficientAccessWarning",
130+
]
131+
markers = [
132+
"hardware: marks test as requiring hardware (deselect with '-m \"not hardware\"')",
133+
]
134+
135+
[tool.mypy]
136+
# https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml
137+
show_error_codes = true
138+
check_untyped_defs = true
139+
follow_imports = "normal"
140+
strict_optional = true
141+
plugins = ["pydantic.mypy"]
142+
strict = true
143+
disallow_untyped_defs = true
144+
implicit_reexport = true

0 commit comments

Comments
 (0)