-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2c196fd
Showing
19 changed files
with
470 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[darglint] | ||
|
||
docstring_style=google |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish Python Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
concurrency: | ||
group: "publish" | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
publish: | ||
timeout-minutes: 10 | ||
name: Build and publish | ||
|
||
# We don't need to run on all platforms since this package is | ||
# platform-agnostic. The output wheel is something like | ||
# "kbrain-<version>-py3-none-any.whl". | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install build wheel | ||
- name: Build package | ||
run: python -m build --sdist --wheel --outdir dist/ . | ||
|
||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Python Checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
|
||
concurrency: | ||
group: tests-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run-base-tests: | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Restore cache | ||
id: restore-cache | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: | | ||
${{ env.pythonLocation }} | ||
.mypy_cache/ | ||
key: python-requirements-${{ env.pythonLocation }}-${{ github.event.pull_request.base.sha || github.sha }} | ||
restore-keys: | | ||
python-requirements-${{ env.pythonLocation }} | ||
python-requirements- | ||
- name: Install package | ||
run: | | ||
pip install --upgrade --upgrade-strategy eager --extra-index-url https://download.pytorch.org/whl/cpu -e '.[dev]' | ||
- name: Run static checks | ||
run: | | ||
mkdir -p .mypy_cache | ||
make static-checks | ||
- name: Run unit tests | ||
run: | | ||
make test | ||
- name: Save cache | ||
uses: actions/cache/save@v3 | ||
if: github.ref == 'refs/heads/master' | ||
with: | ||
path: | | ||
${{ env.pythonLocation }} | ||
.mypy_cache/ | ||
key: ${{ steps.restore-cache.outputs.cache-primary-key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# .gitignore | ||
|
||
# Python | ||
*.py[oc] | ||
__pycache__/ | ||
*.egg-info | ||
.eggs/ | ||
.mypy_cache/* | ||
.pyre/ | ||
.pytest_cache/ | ||
.ruff_cache/ | ||
.dmypy.json | ||
|
||
# Databases | ||
*.db | ||
|
||
# Build artifacts | ||
build/ | ||
dist/ | ||
*.so | ||
out*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"kbrain/bindings", | ||
"kbrain/rust", | ||
] | ||
resolver = "2" | ||
|
||
[workspace.package] | ||
|
||
version = "0.1.0" | ||
authors = ["Wesley Maa <[email protected]>", "Pawel Budzianowski <[email protected]>", "Benjamin Bolte <[email protected]>"] | ||
edition = "2021" | ||
license = "MIT" | ||
repository = "https://github.com/kscalelabs/kbrain" | ||
documentation = "https://docs.kscale.dev/software/actuators/overview" | ||
readme = "README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Benjamin Bolte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include kbrain/ *.py *.txt py.typed MANIFEST.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Makefile | ||
|
||
define HELP_MESSAGE | ||
k-brain | ||
|
||
# Installing | ||
|
||
1. Create a new Conda environment: `conda create --name k-brain python=3.11` | ||
2. Activate the environment: `conda activate k-brain` | ||
3. Install the package: `make install-dev` | ||
|
||
# Running Tests | ||
|
||
1. Run autoformatting: `make format` | ||
2. Run static checks: `make static-checks` | ||
3. Run unit tests: `make test` | ||
|
||
endef | ||
export HELP_MESSAGE | ||
|
||
all: | ||
@echo "$$HELP_MESSAGE" | ||
.PHONY: all | ||
|
||
# ------------------------ # | ||
# PyPI Build # | ||
# ------------------------ # | ||
|
||
build-for-pypi: | ||
@pip install --verbose build wheel twine | ||
@python -m build --sdist --wheel --outdir dist/ . | ||
@twine upload dist/* | ||
.PHONY: build-for-pypi | ||
|
||
push-to-pypi: build-for-pypi | ||
@twine upload dist/* | ||
.PHONY: push-to-pypi | ||
|
||
# ------------------------ # | ||
# Static Checks # | ||
# ------------------------ # | ||
|
||
py-files := $(shell find . -name '*.py') | ||
|
||
format: | ||
@black $(py-files) | ||
@ruff format $(py-files) | ||
.PHONY: format | ||
|
||
static-checks: | ||
@black --diff --check $(py-files) | ||
@ruff check $(py-files) | ||
@mypy --install-types --non-interactive $(py-files) | ||
.PHONY: lint | ||
|
||
# ------------------------ # | ||
# Unit tests # | ||
# ------------------------ # | ||
|
||
test: | ||
python -m pytest | ||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# k-brain | ||
|
||
Welcome to the k-brain project! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[package] | ||
|
||
name = "bindings" | ||
version.workspace = true | ||
edition.workspace = true | ||
description.workspace = true | ||
authors.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
|
||
[lib] | ||
|
||
name = "bindings" | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
|
||
pyo3 = { version = ">= 0.21.0", features = ["extension-module"] } | ||
pyo3-stub-gen = ">= 0.6.0" | ||
tokio = { version = "1.28.0", features = ["full"] } | ||
async-trait = "0.1.68" | ||
futures = "0.3" | ||
log = "0.4" | ||
env_logger = "0.11.5" | ||
serialport = "4.5.1" | ||
|
||
# Other packages in the workspace. | ||
kbrain = { path = "../rust" } |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# requirements-dev.txt | ||
|
||
black | ||
darglint | ||
mypy | ||
pytest | ||
ruff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# requirements.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[package] | ||
|
||
name = "kbrain" | ||
readme = "README.md" | ||
version = "0.0.1" | ||
description = "The brain for K-Scale's humanoid robots" | ||
|
||
authors.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
|
||
[lib] | ||
|
||
name = "kbrain" | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
|
||
serialport = "^4.5.1" | ||
ctrlc = "^3.4.5" | ||
lazy_static = "^1.4.0" | ||
spin_sleep = "^1.2.1" | ||
nix = "^0.26.2" | ||
log = "^0.4.22" | ||
|
||
[[bin]] | ||
|
||
name = "motors" | ||
path = "src/bin/motors.rs" | ||
|
||
[dependencies.clap] | ||
|
||
version = "4.3" | ||
features = ["derive"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
[tool.black] | ||
|
||
line-length = 120 | ||
target-version = ["py311"] | ||
include = '\.pyi?$' | ||
|
||
[tool.pytest.ini_options] | ||
|
||
addopts = "-rx -rf -x -q --full-trace" | ||
testpaths = ["tests"] | ||
|
||
markers = [ | ||
"slow: Marks test as being slow", | ||
] | ||
|
||
[tool.mypy] | ||
|
||
pretty = true | ||
show_column_numbers = true | ||
show_error_context = true | ||
show_error_codes = true | ||
show_traceback = true | ||
disallow_untyped_defs = true | ||
strict_equality = true | ||
allow_redefinition = true | ||
|
||
warn_unused_ignores = true | ||
warn_redundant_casts = true | ||
|
||
incremental = true | ||
namespace_packages = false | ||
|
||
# Uncomment to exclude modules from Mypy. | ||
# [[tool.mypy.overrides]] | ||
# module = [] | ||
# ignore_missing_imports = true | ||
|
||
[tool.isort] | ||
|
||
profile = "black" | ||
|
||
[tool.ruff] | ||
|
||
line-length = 120 | ||
target-version = "py310" | ||
|
||
[tool.ruff.lint] | ||
|
||
select = ["ANN", "D", "E", "F", "I", "N", "PGH", "PLC", "PLE", "PLR", "PLW", "W"] | ||
|
||
ignore = [ | ||
"ANN101", "ANN102", | ||
"D101", "D102", "D103", "D104", "D105", "D106", "D107", | ||
"N812", "N817", | ||
"PLR0911", "PLR0912", "PLR0913", "PLR0915", "PLR2004", | ||
"PLW0603", "PLW2901", | ||
] | ||
|
||
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
|
||
"__init__.py" = ["E402", "F401", "F403", "F811"] | ||
|
||
[tool.ruff.lint.isort] | ||
|
||
known-first-party = ["kbrain", "tests"] | ||
combine-as-imports = true | ||
|
||
[tool.ruff.lint.pydocstyle] | ||
|
||
convention = "google" |
Oops, something went wrong.