add openpilot prefix to imports (#29498)

* add openpilot prefix to imports

* more

* more

* fix docs

* fix linter

* bump submodules

* fix patched tests

* update dynamic imports

* debug

* Revert "debug"

This reverts commit db5e13b9911cc74438bee123bc3430da6c31b24b.

* fix pm test
old-commit-hash: a9626f95b69af19306143fc4def02fb5769405d2
This commit is contained in:
Adeeb Shihadeh
2023-08-20 20:49:55 -07:00
committed by GitHub
parent 51634f52dc
commit 16ec56398c
337 changed files with 1153 additions and 1142 deletions

View File

@@ -15,8 +15,8 @@ from aiohttp import web
from aiortc import RTCPeerConnection, RTCSessionDescription
import cereal.messaging as messaging
from common.basedir import BASEDIR
from tools.bodyteleop.bodyav import BodyMic, WebClientSpeaker, force_codec, play_sound, MediaBlackhole, EncodedBodyVideo
from openpilot.common.basedir import BASEDIR
from openpilot.tools.bodyteleop.bodyav import BodyMic, WebClientSpeaker, force_codec, play_sound, MediaBlackhole, EncodedBodyVideo
logger = logging.getLogger("pc")
logging.basicConfig(level=logging.INFO)

View File

@@ -2,7 +2,7 @@
import argparse
import json
from selfdrive.car.car_helpers import get_interface_attr
from openpilot.selfdrive.car.car_helpers import get_interface_attr
def generate_dbc_json() -> str:

View File

@@ -4,7 +4,7 @@ import sys
import numpy as np
os.environ['ZMQ'] = '1'
from common.window import Window
from openpilot.common.window import Window
import cereal.messaging as messaging
# start camerad with 'SEND_ROAD=1 SEND_DRIVER=1 SEND_WIDE_ROAD=1 XMIN=771 XMAX=1156 YMIN=483 YMAX=724 ./camerad'

View File

@@ -7,9 +7,9 @@ from collections import defaultdict
import rpyc # pylint: disable=import-error
from rpyc.utils.server import ThreadedServer # pylint: disable=import-error
#from common.params import Params
#from openpilot.common.params import Params
import cereal.messaging as messaging
from selfdrive.manager.process_config import managed_processes
from openpilot.selfdrive.manager.process_config import managed_processes
from laika.lib.coordinates import ecef2geodetic
DELTA = 0.001

View File

@@ -3,11 +3,11 @@ import time
import unittest
import struct
from common.params import Params
from openpilot.common.params import Params
import cereal.messaging as messaging
import system.sensord.pigeond as pd
from system.hardware import TICI
from selfdrive.test.helpers import with_processes
import openpilot.system.sensord.pigeond as pd
from openpilot.system.hardware import TICI
from openpilot.selfdrive.test.helpers import with_processes
def read_events(service, duration_sec):

View File

@@ -3,10 +3,10 @@ import time
import unittest
import subprocess as sp
from common.params import Params
from system.hardware import TICI
from openpilot.common.params import Params
from openpilot.system.hardware import TICI
import cereal.messaging as messaging
from selfdrive.manager.process_config import managed_processes
from openpilot.selfdrive.manager.process_config import managed_processes
def exec_mmcli(cmd):

View File

@@ -4,12 +4,12 @@ import time
import unittest
import cereal.messaging as messaging
import system.sensord.pigeond as pd
import openpilot.system.sensord.pigeond as pd
from common.params import Params
from system.hardware import TICI
from selfdrive.manager.process_config import managed_processes
from selfdrive.test.helpers import with_processes
from openpilot.common.params import Params
from openpilot.system.hardware import TICI
from openpilot.selfdrive.manager.process_config import managed_processes
from openpilot.selfdrive.test.helpers import with_processes
def wait_for_location(sm, timeout, con=10):

View File

@@ -5,10 +5,10 @@ import threading
from inputs import get_gamepad
import cereal.messaging as messaging
from common.realtime import Ratekeeper
from common.numpy_fast import interp, clip
from common.params import Params
from tools.lib.kbhit import KBHit
from openpilot.common.realtime import Ratekeeper
from openpilot.common.numpy_fast import interp, clip
from openpilot.common.params import Params
from openpilot.tools.lib.kbhit import KBHit
class Keyboard:

View File

@@ -8,7 +8,7 @@ import sys
from bisect import bisect_left, bisect_right
from collections import defaultdict
from tools.lib.logreader import logreader_from_route_or_segment
from openpilot.tools.lib.logreader import logreader_from_route_or_segment
DEMO_ROUTE = "9f583b1d93915c31|2022-05-18--10-49-51--0"

View File

@@ -3,8 +3,8 @@
Route is a class for conveniently accessing all the [logs](/system/loggerd/) from your routes. The LogReader class reads the non-video logs, i.e. rlog.bz2 and qlog.bz2. There's also a matching FrameReader class for reading the videos.
```python
from tools.lib.route import Route
from tools.lib.logreader import LogReader
from openpilot.tools.lib.route import Route
from openpilot.tools.lib.logreader import LogReader
r = Route("a2a0ccea32023010|2023-07-27--13-01-19")
@@ -37,8 +37,8 @@ for msg in lr:
`MultiLogIterator` is similar to `LogReader`, but reads multiple logs.
```python
from tools.lib.route import Route
from tools.lib.logreader import MultiLogIterator
from openpilot.tools.lib.route import Route
from openpilot.tools.lib.logreader import MultiLogIterator
# setup a MultiLogIterator to read all the logs in the route
r = Route("a2a0ccea32023010|2023-07-27--13-01-19")

View File

@@ -29,8 +29,8 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Any, Dict
from urllib.parse import parse_qs, urlencode
from tools.lib.api import APIError, CommaApi, UnauthorizedError
from tools.lib.auth_config import set_token, get_token
from openpilot.tools.lib.api import APIError, CommaApi, UnauthorizedError
from openpilot.tools.lib.auth_config import set_token, get_token
PORT = 3000

View File

@@ -1,7 +1,7 @@
import json
import os
from common.file_helpers import mkdirs_exists_ok
from system.hardware import PC
from openpilot.common.file_helpers import mkdirs_exists_ok
from openpilot.system.hardware import PC
class MissingAuthConfigError(Exception):

View File

@@ -3,9 +3,9 @@ import functools
import re
from typing import List, Optional
from tools.lib.auth_config import get_token
from tools.lib.api import CommaApi
from tools.lib.helpers import RE, timestamp_to_datetime
from openpilot.tools.lib.auth_config import get_token
from openpilot.tools.lib.api import CommaApi
from openpilot.tools.lib.helpers import RE, timestamp_to_datetime
@functools.total_ordering

View File

@@ -1,6 +1,6 @@
import os
import urllib.parse
from common.file_helpers import mkdirs_exists_ok
from openpilot.common.file_helpers import mkdirs_exists_ok
DEFAULT_CACHE_DIR = os.path.expanduser("~/.commacache")

View File

@@ -1,5 +1,5 @@
import os
from tools.lib.url_file import URLFile
from openpilot.tools.lib.url_file import URLFile
DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")

View File

@@ -13,11 +13,11 @@ import numpy as np
from lru import LRU
import _io
from tools.lib.cache import cache_path_for_file_path
from tools.lib.exceptions import DataUnreadableError
from common.file_helpers import atomic_write_in_dir
from openpilot.tools.lib.cache import cache_path_for_file_path
from openpilot.tools.lib.exceptions import DataUnreadableError
from openpilot.common.file_helpers import atomic_write_in_dir
from tools.lib.filereader import FileReader
from openpilot.tools.lib.filereader import FileReader
HEVC_SLICE_B = 0
HEVC_SLICE_P = 1

View File

@@ -8,8 +8,8 @@ import warnings
from cereal import log as capnp_log
from tools.lib.filereader import FileReader
from tools.lib.route import Route, SegmentName
from openpilot.tools.lib.filereader import FileReader
from openpilot.tools.lib.route import Route, SegmentName
# this is an iterator itself, and uses private variables from LogReader
class MultiLogIterator:

View File

@@ -5,9 +5,9 @@ from collections import defaultdict
from itertools import chain
from typing import Optional
from tools.lib.auth_config import get_token
from tools.lib.api import CommaApi
from tools.lib.helpers import RE
from openpilot.tools.lib.auth_config import get_token
from openpilot.tools.lib.api import CommaApi
from openpilot.tools.lib.helpers import RE
QLOG_FILENAMES = ['qlog', 'qlog.bz2']
QCAMERA_FILENAMES = ['qcamera.ts']

View File

@@ -4,7 +4,7 @@ import shutil
import unittest
os.environ["COMMA_CACHE"] = "/tmp/__test_cache__"
from tools.lib.url_file import URLFile, CACHE_DIR
from openpilot.tools.lib.url_file import URLFile, CACHE_DIR
class TestFileDownload(unittest.TestCase):

View File

@@ -5,8 +5,8 @@ import tempfile
from collections import defaultdict
import numpy as np
from tools.lib.framereader import FrameReader
from tools.lib.logreader import LogReader
from openpilot.tools.lib.framereader import FrameReader
from openpilot.tools.lib.logreader import LogReader
class TestReaders(unittest.TestCase):

View File

@@ -2,7 +2,7 @@
import unittest
from collections import namedtuple
from tools.lib.route import SegmentName
from openpilot.tools.lib.route import SegmentName
class TestRouteLibrary(unittest.TestCase):
def test_segment_name_formats(self):

View File

@@ -9,7 +9,7 @@ import pycurl
from hashlib import sha256
from io import BytesIO
from tenacity import retry, wait_random_exponential, stop_after_attempt
from common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir
from openpilot.common.file_helpers import mkdirs_exists_ok, atomic_write_in_dir
# Cache chunk size
K = 1000
CHUNK_SIZE = 1000 * K

View File

@@ -10,11 +10,11 @@ import tempfile
import requests
import argparse
from common.basedir import BASEDIR
from selfdrive.test.openpilotci import get_url
from tools.lib.logreader import LogReader
from tools.lib.route import Route, SegmentName
from tools.lib.helpers import save_log
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.test.openpilotci import get_url
from openpilot.tools.lib.logreader import LogReader
from openpilot.tools.lib.route import Route, SegmentName
from openpilot.tools.lib.helpers import save_log
from urllib.parse import urlparse, parse_qs
juggle_dir = os.path.dirname(os.path.realpath(__file__))
@@ -129,7 +129,7 @@ def juggle_route(route_or_segment_name, segment_count, qlog, can, layout, dbc=No
if dbc is None:
for cp in [m for m in all_data if m.which() == 'carParams']:
try:
DBC = __import__(f"selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC
DBC = __import__(f"openpilot.selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC
dbc = DBC[cp.carParams.carFingerprint]['pt']
except Exception:
pass

View File

@@ -6,9 +6,9 @@ import subprocess
import time
import unittest
from common.basedir import BASEDIR
from common.timeout import Timeout
from tools.plotjuggler.juggle import install
from openpilot.common.basedir import BASEDIR
from openpilot.common.timeout import Timeout
from openpilot.tools.plotjuggler.juggle import install
PJ_DIR = os.path.join(BASEDIR, "tools/plotjuggler")

View File

@@ -8,10 +8,10 @@ from tqdm import tqdm
os.environ['FILEREADER_CACHE'] = '1'
from common.realtime import config_realtime_process, Ratekeeper, DT_CTRL
from selfdrive.boardd.boardd import can_capnp_to_can_list
from tools.plotjuggler.juggle import load_segment
from tools.lib.logreader import logreader_from_route_or_segment
from openpilot.common.realtime import config_realtime_process, Ratekeeper, DT_CTRL
from openpilot.selfdrive.boardd.boardd import can_capnp_to_can_list
from openpilot.tools.plotjuggler.juggle import load_segment
from openpilot.tools.lib.logreader import logreader_from_route_or_segment
from panda import Panda, PandaJungle
def send_thread(s, flock):

View File

@@ -7,10 +7,10 @@ import pygame # pylint: disable=import-error
from matplotlib.backends.backend_agg import FigureCanvasAgg
from common.transformations.camera import (eon_f_frame_size, eon_f_focal_length,
from openpilot.common.transformations.camera import (eon_f_frame_size, eon_f_focal_length,
tici_f_frame_size, tici_f_focal_length,
get_view_frame_from_calib_frame)
from selfdrive.controls.radard import RADAR_TO_CAMERA
from openpilot.selfdrive.controls.radard import RADAR_TO_CAMERA
RED = (255, 0, 0)

View File

@@ -8,9 +8,9 @@ import numpy as np
import pygame # pylint: disable=import-error
import cereal.messaging as messaging
from common.numpy_fast import clip
from common.basedir import BASEDIR
from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP,
from openpilot.common.numpy_fast import clip
from openpilot.common.basedir import BASEDIR
from openpilot.tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP,
_INTRINSICS, BLACK, GREEN,
YELLOW, Calibration,
get_blank_lid_overlay, init_plots,

View File

@@ -11,9 +11,9 @@ import tty
from collections import defaultdict
import cereal.messaging as messaging
from tools.lib.framereader import FrameReader
from tools.lib.logreader import LogReader
from selfdrive.test.openpilotci import get_url
from openpilot.tools.lib.framereader import FrameReader
from openpilot.tools.lib.logreader import LogReader
from openpilot.selfdrive.test.openpilotci import get_url
IGNORE = ['initData', 'sentinel']

View File

@@ -8,8 +8,8 @@ if len(sys.argv) < 4:
import requests
from PIL import Image
from tools.lib.auth_config import get_token
from tools.lib.framereader import FrameReader
from openpilot.tools.lib.auth_config import get_token
from openpilot.tools.lib.framereader import FrameReader
jwt = get_token()

View File

@@ -2,9 +2,9 @@
import argparse
import os
import sys
from common.basedir import BASEDIR
from tools.lib.logreader import MultiLogIterator
from tools.lib.route import Route
from openpilot.common.basedir import BASEDIR
from openpilot.tools.lib.logreader import MultiLogIterator
from openpilot.tools.lib.route import Route
os.environ['BASEDIR'] = BASEDIR

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import requests
from common.params import Params
from openpilot.common.params import Params
import sys

View File

@@ -14,6 +14,7 @@ RUN mkdir -p $HOME/openpilot
COPY SConstruct $HOME/openpilot/
COPY ./openpilot $HOME/openpilot/openpilot
COPY ./body $HOME/openpilot/body
COPY ./third_party $HOME/openpilot/third_party
COPY ./site_scons $HOME/openpilot/site_scons
@@ -30,4 +31,4 @@ COPY ./tools $HOME/openpilot/tools
WORKDIR $HOME/openpilot
RUN scons --cache-readonly -j12
RUN python -c "from selfdrive.test.helpers import set_params_enabled; set_params_enabled()"
RUN python -c "from openpilot.selfdrive.test.helpers import set_params_enabled; set_params_enabled()"

View File

@@ -16,13 +16,13 @@ import pyopencl.array as cl_array
import cereal.messaging as messaging
from cereal import log
from cereal.visionipc import VisionIpcServer, VisionStreamType
from common.basedir import BASEDIR
from common.numpy_fast import clip
from common.params import Params
from common.realtime import DT_DMON, Ratekeeper
from selfdrive.car.honda.values import CruiseButtons
from selfdrive.test.helpers import set_params_enabled
from tools.sim.lib.can import can_function
from openpilot.common.basedir import BASEDIR
from openpilot.common.numpy_fast import clip
from openpilot.common.params import Params
from openpilot.common.realtime import DT_DMON, Ratekeeper
from openpilot.selfdrive.car.honda.values import CruiseButtons
from openpilot.selfdrive.test.helpers import set_params_enabled
from openpilot.tools.sim.lib.can import can_function
W, H = 1928, 1208
REPEAT_COUNTER = 5
@@ -550,12 +550,12 @@ if __name__ == "__main__":
if args.joystick:
# start input poll for joystick
from tools.sim.lib.manual_ctrl import wheel_poll_thread
from openpilot.tools.sim.lib.manual_ctrl import wheel_poll_thread
wheel_poll_thread(q)
else:
# start input poll for keyboard
from tools.sim.lib.keyboard_ctrl import keyboard_poll_thread
from openpilot.tools.sim.lib.keyboard_ctrl import keyboard_poll_thread
keyboard_poll_thread(q)
p.join()

View File

@@ -2,8 +2,8 @@
import cereal.messaging as messaging
from opendbc.can.packer import CANPacker
from opendbc.can.parser import CANParser
from selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error
from selfdrive.car import crc8_pedal
from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp # pylint: disable=no-name-in-module,import-error
from openpilot.selfdrive.car import crc8_pedal
packer = CANPacker("honda_civic_touring_2016_can_generated")
rpacker = CANPacker("acura_ilx_2016_nidec")

View File

@@ -6,10 +6,10 @@ import os
from multiprocessing import Queue
from cereal import messaging
from common.basedir import BASEDIR
from selfdrive.manager.helpers import unblock_stdout
from tools.sim import bridge
from tools.sim.bridge import CarlaBridge
from openpilot.common.basedir import BASEDIR
from openpilot.selfdrive.manager.helpers import unblock_stdout
from openpilot.tools.sim import bridge
from openpilot.tools.sim.bridge import CarlaBridge
CI = "CI" in os.environ

View File

@@ -8,7 +8,7 @@ import signal
from collections import defaultdict
import cereal.messaging as messaging
from tools.lib.logreader import logreader_from_route_or_segment
from openpilot.tools.lib.logreader import logreader_from_route_or_segment
def sigint_handler(signal, frame):
exit(0)

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
import numpy as np
# copied from common.transformations/camera.py
# copied from openpilot.common.transformations/camera.py
eon_dcam_focal_length = 860.0 # pixels
webcam_focal_length = 908.0 # pixels

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
import numpy as np
# copied from common.transformations/camera.py
# copied from openpilot.common.transformations/camera.py
eon_focal_length = 910.0 # pixels
eon_dcam_focal_length = 860.0 # pixels

View File

@@ -2,7 +2,7 @@
import sys
import time
from tools.zookeeper import Zookeeper
from openpilot.tools.zookeeper import Zookeeper
# Usage: check_consumption.py <averaging_time_sec> <max_average_power_W>
# Exit code: 0 -> passed

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from tools.zookeeper import Zookeeper
from openpilot.tools.zookeeper import Zookeeper
if __name__ == "__main__":
z = Zookeeper()

View File

@@ -3,7 +3,7 @@ import os
import sys
import time
from socket import gethostbyname, gaierror
from tools.zookeeper import Zookeeper
from openpilot.tools.zookeeper import Zookeeper
def is_online(ip):
try:

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys
from tools.zookeeper import Zookeeper
from openpilot.tools.zookeeper import Zookeeper
if __name__ == "__main__":

View File

@@ -3,9 +3,9 @@ import sys
import time
import datetime
from common.realtime import Ratekeeper
from common.filter_simple import FirstOrderFilter
from tools.zookeeper import Zookeeper
from openpilot.common.realtime import Ratekeeper
from openpilot.common.filter_simple import FirstOrderFilter
from openpilot.tools.zookeeper import Zookeeper
if __name__ == "__main__":
z = Zookeeper()

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python3
import time
from tools.zookeeper import Zookeeper
from openpilot.tools.zookeeper import Zookeeper
if __name__ == "__main__":