Skip to content

Commit

Permalink
Merge branch 'master' into refactor_parser
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Aug 1, 2024
2 parents 5c5facb + a40652d commit c49fae1
Show file tree
Hide file tree
Showing 174 changed files with 29 additions and 33 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tests
on: [push, pull_request]

env:
RUN: docker run -v $GITHUB_WORKSPACE:/project/opendbc -w /project/opendbc -e PYTHONWARNINGS="error,default::DeprecationWarning" --shm-size 1G --rm opendbc /bin/bash -c
RUN: docker run -e PYTHONWARNINGS="error,default::DeprecationWarning" --shm-size 1G --rm opendbc /bin/bash -c
BUILD: docker buildx build --pull --load --cache-to type=inline --cache-from type=registry,ref=ghcr.io/commaai/opendbc:latest -t opendbc -f Dockerfile .
PYTHONWARNINGS: error

Expand All @@ -19,10 +19,8 @@ jobs:
- uses: actions/checkout@v4
- name: Build Docker image
run: eval "$BUILD"
- name: Build opendbc
run: ${{ env.RUN }} "cd ../ && scons -j$(nproc) --minimal"
- name: Unit tests
run: ${{ env.RUN }} "pytest -n logical"
run: ${{ env.RUN }} "pytest -n logical --durations=0"

static-analysis:
name: static analysis
Expand All @@ -31,13 +29,9 @@ jobs:
- uses: actions/checkout@v4
- name: Build Docker image
run: eval "$BUILD"
- name: Build opendbc
run: ${{ env.RUN }} "cd ../ && scons -j$(nproc) --minimal"
- name: pre-commit
# TODO: a package pre-commit installs has a warning, remove the unset once that's fixed
run: ${{ env.RUN }} "unset PYTHONWARNINGS && pre-commit run --all"
- name: Generator test
run: ${{ env.RUN }} "generator/test_generator.py"
run: ${{ env.RUN }} "git init && git add -A && unset PYTHONWARNINGS && pre-commit run --all"

docker-push:
name: docker push
Expand Down
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
.DS_Store
.sconsign.dblite

can/*.so
can/*.a
can/build/
can/obj/
can/packer_pyx.cpp
can/parser_pyx.cpp
can/packer_pyx.html
can/parser_pyx.html
opendbc/can/*.so
opendbc/can/*.a
opendbc/can/build/
opendbc/can/obj/
opendbc/can/packer_pyx.cpp
opendbc/can/parser_pyx.cpp
opendbc/can/packer_pyx.html
opendbc/can/parser_pyx.html
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ repos:
hooks:
- id: generator
name: dbc generator
entry: generator/test_generator.py
entry: opendbc/dbc/generator/test_generator.py
language: script
pass_filenames: false
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ COPY requirements.txt /tmp/
RUN pip3 install --break-system-packages --no-cache-dir -r /tmp/requirements.txt
RUN pip3 install --break-system-packages --no-cache-dir pre-commit==2.15.0 pylint==2.17.4

ENV PYTHONPATH=/project
WORKDIR /project/opendbc
ENV PYTHONPATH=/project/opendbc

RUN git config --global --add safe.directory '*'

WORKDIR /project

COPY SConstruct .
COPY ./site_scons /project/site_scons
COPY . .
RUN ls && rm -rf .git && \
scons -c && scons -j$(nproc) \
2 changes: 0 additions & 2 deletions __init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions opendbc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import os

DBC_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dbc')
2 changes: 1 addition & 1 deletion can/SConscript → opendbc/can/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Import('env', 'envCython', 'common', 'arch')
import os

envDBC = env.Clone()
dbc_file_path = '-DDBC_FILE_PATH=\'"%s"\'' % (envDBC.Dir("..").abspath)
dbc_file_path = '-DDBC_FILE_PATH=\'"%s"\'' % (envDBC.Dir("../dbc").abspath)
envDBC['CXXFLAGS'] += [dbc_file_path]
src = ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]
libs = [common, "zmq"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion can/dbc.cc → opendbc/can/dbc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ DBC* dbc_parse(const std::string& dbc_path) {
const std::string get_dbc_root_path() {
char *basedir = std::getenv("BASEDIR");
if (basedir != NULL) {
return std::string(basedir) + "/opendbc";
return std::string(basedir) + "/opendbc/dbc";
} else {
return DBC_FILE_PATH;
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added opendbc/dbc/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import os
from opendbc.generator.tesla.radar_common import get_radar_point_definition, get_val_definition
from opendbc.dbc.generator.tesla.radar_common import get_radar_point_definition, get_val_definition

if __name__ == "__main__":
dbc_name = os.path.basename(__file__).replace(".py", ".dbc")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

import os
from opendbc.generator.tesla.radar_common import get_radar_point_definition, get_val_definition
from opendbc.dbc.generator.tesla.radar_common import get_radar_point_definition, get_val_definition

if __name__ == "__main__":
dbc_name = os.path.basename(__file__).replace(".py", ".dbc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import filecmp
import tempfile
from opendbc.generator.generator import create_all, opendbc_root
from opendbc.dbc.generator.generator import create_all, opendbc_root


def test_generator():
Expand All @@ -14,7 +14,7 @@ def test_generator():

err = "Generated DBC mismatch\n\n"
err += f"Different files: {comp.diff_files}\n\n"
err += "Run opendbc/generator/generator.py to regenerate DBC files."
err += "Run opendbc/dbc/generator/generator.py to regenerate DBC files."
assert len(comp.diff_files) == 0, err


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ repository = "https://github.com/commaai/opendbc"
max-line-length = 120
ignore = ["E111", "E114"]

[tool.mypy]
explicit_package_bases=true

# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
select = ["E", "F", "W", "PIE", "C4", "ISC", "RUF100", "A"]
Expand Down

0 comments on commit c49fae1

Please sign in to comment.