From 93e6beac5ceaf5a4fbb127ba1b22a5a2019d5324 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Tue, 22 Jul 2025 12:37:34 +0200 Subject: [PATCH 1/3] Remove python/cpp build infrastructure Signed-off-by: Pierre R. Mai --- CMakeLists.txt | 278 --------- MANIFEST.in | 1 - convert-to-proto3.sh | 19 - ...mulation_interface-config-version.cmake.in | 21 - open_simulation_interface-config.cmake.in | 10 - pyproject.toml | 35 -- setup.py | 165 ----- tests/test_osi_trace.py | 589 ------------------ 8 files changed, 1118 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 MANIFEST.in delete mode 100644 convert-to-proto3.sh delete mode 100644 open_simulation_interface-config-version.cmake.in delete mode 100644 open_simulation_interface-config.cmake.in delete mode 100644 pyproject.toml delete mode 100644 setup.py delete mode 100644 tests/test_osi_trace.py diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 6057fddf8..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,278 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(open_simulation_interface) - -# Toplevel check -set(OSI_IS_TOP_LEVEL OFF) -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(OSI_IS_TOP_LEVEL ON) -endif() - -# Set the C++ standard -set(CMAKE_CXX_STANDARD 11 CACHE STRING "C++ standard to be used") -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# Optional Flatbuffer support -option(OSI_BUILD_FLATBUFFER "Build flatbuffer versions of libraries" OFF) -option(OSI_BUILD_DOCUMENTATION "Build flatbuffer versions of libraries" ${OSI_IS_TOP_LEVEL}) - -# Set a default build type if none was specified -set(default_build_type "Release") -if(EXISTS "${CMAKE_SOURCE_DIR}/.git") - set(default_build_type "Debug") -endif() - -# read the version number from the file "VERSION" -file(STRINGS "VERSION" VERSION_CONTENTS) -foreach(LINE ${VERSION_CONTENTS}) - string(REGEX REPLACE " |\t" "" LINE ${LINE}) - string(REGEX MATCH "^[^=]+" VERSION_NAME ${LINE}) - string(REPLACE "${VERSION_NAME}=" "" VERSION_VALUE ${LINE}) - set(${VERSION_NAME} "${VERSION_VALUE}") -endforeach() -set(OPEN_SIMULATION_INTERFACE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(${PROJECT_NAME}_SOVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") -set(${PROJECT_NAME}_LIBVERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") - -# configure build version -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE - STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -# Offer the user the choice of overriding the installation directories -set(OSI_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") -set(OSI_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") - -if(WIN32 AND NOT CYGWIN) - set(DEF_INSTALL_CMAKE_DIR CMake/${PROJECT_NAME}-${VERSION_MAJOR}) -else() - set(DEF_INSTALL_CMAKE_DIR lib/cmake/${PROJECT_NAME}-${VERSION_MAJOR}) -endif() -set(OSI_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") - -set(OSI_INSTALL_LIB_DIR ${OSI_INSTALL_LIB_DIR}/osi${VERSION_MAJOR}) -set(OSI_INSTALL_INCLUDE_DIR ${OSI_INSTALL_INCLUDE_DIR}/osi${VERSION_MAJOR}) - -configure_file(osi_version.proto.in osi_version.proto) - -find_package(Protobuf 2.6.1 REQUIRED) -set(PROTOBUF_IMPORT_DIRS ${PROTOBUF_INCLUDE_DIRS}) - -set(OSI_PROTO_FILES - ${CMAKE_CURRENT_BINARY_DIR}/osi_version.proto - osi_common.proto - osi_datarecording.proto - osi_detectedtrafficsign.proto - osi_detectedtrafficlight.proto - osi_detectedroadmarking.proto - osi_detectedlane.proto - osi_detectedobject.proto - osi_detectedoccupant.proto - osi_environment.proto - osi_groundtruth.proto - osi_hostvehicledata.proto - osi_motionrequest.proto - osi_trafficsign.proto - osi_trafficlight.proto - osi_trafficupdate.proto - osi_trafficcommand.proto - osi_trafficcommandupdate.proto - osi_referenceline.proto - osi_roadmarking.proto - osi_route.proto - osi_lane.proto - osi_logicallane.proto - osi_featuredata.proto - osi_logicaldetectiondata.proto - osi_object.proto - osi_occupant.proto - osi_sensordata.proto - osi_sensorviewconfiguration.proto - osi_sensorspecific.proto - osi_sensorview.proto - osi_streamingupdate.proto -) - -protobuf_generate_cpp(PROTO_SRCS PROTO_HEADERS ${OSI_PROTO_FILES}) -set(FLAT_HEADERS "") -if(OSI_BUILD_FLATBUFFER) - set(FLAT_FBS "") - find_package(flatbuffers REQUIRED) - if(NOT FLATBUFFERS_FLATC_EXECUTABLE) - set(FLATBUFFERS_FLATC_EXECUTABLE ${flatbuffers_DIR}/../../tools/flatbuffers/flatc) - endif() - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs" "namespace osi3;") - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") - list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/descriptor.fbs") - foreach (proto ${OSI_PROTO_FILES}) - get_filename_component(proto_base ${proto} NAME_WE) - set(fbs "${proto_base}.fbs") - add_custom_command( - OUTPUT "${fbs}" - COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -I "${PROTOBUF_IMPORT_DIRS}" -I "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}" --proto "${proto}" - DEPENDS "${proto}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Convert ${proto} to ${fbs} using flatc" - ) - list(APPEND FLAT_FBS "${CMAKE_CURRENT_BINARY_DIR}/${fbs}") - endforeach() - - foreach (flat ${FLAT_FBS}) - get_filename_component(flat_base ${flat} NAME_WE) - set(fbs "${flat_base}.fbs") - set(fbh "${flat_base}_generated.h") - add_custom_command( - OUTPUT "include/${fbh}" - COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -o "${CMAKE_CURRENT_BINARY_DIR}/include" --cpp --gen-mutable --gen-name-strings --scoped-enums "${fbs}" - DEPENDS "${FLAT_FBS}" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" - COMMENT "Process ${fbs} to ${fbh} using flatc" - ) - list(APPEND FLAT_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/include/${fbh}") - endforeach() - - add_custom_target(${PROJECT_NAME}_fbs_build ALL DEPENDS "${FLAT_HEADERS}") - add_library(${PROJECT_NAME}_fbs INTERFACE) - add_library(${PROJECT_NAME}::${PROJECT_NAME}_fbs ALIAS ${PROJECT_NAME}_fbs) - target_include_directories(${PROJECT_NAME}_fbs INTERFACE $) - target_include_directories(${PROJECT_NAME}_fbs SYSTEM INTERFACE $/include>) - target_link_libraries(${PROJECT_NAME}_fbs INTERFACE flatbuffers::flatbuffers) -endif() - -add_library(${PROJECT_NAME}_static STATIC ${PROTO_SRCS} ${PROTO_HEADERS}) -add_library(${PROJECT_NAME}::${PROJECT_NAME}_static ALIAS ${PROJECT_NAME}_static) -target_include_directories(${PROJECT_NAME}_static - PUBLIC - ${PROTOBUF_INCLUDE_DIR} - $ - $ -) -target_link_libraries(${PROJECT_NAME}_static PUBLIC ${PROTOBUF_LIBRARY}) -install(TARGETS ${PROJECT_NAME}_static - EXPORT ${PROJECT_NAME}_targets - ARCHIVE DESTINATION "${OSI_INSTALL_LIB_DIR}" COMPONENT lib) - - -add_library(${PROJECT_NAME}_obj OBJECT ${PROTO_SRCS} ${PROTO_HEADERS}) -add_library(${PROJECT_NAME}::${PROJECT_NAME}_obj ALIAS ${PROJECT_NAME}_obj) -target_include_directories(${PROJECT_NAME}_obj - PUBLIC - ${PROTOBUF_INCLUDE_DIR} - $ - $ -) -set_property(TARGET ${PROJECT_NAME}_obj PROPERTY POSITION_INDEPENDENT_CODE ON) - - -add_library(${PROJECT_NAME}_pic STATIC $) -add_library(${PROJECT_NAME}::${PROJECT_NAME}_pic ALIAS ${PROJECT_NAME}_pic) -target_include_directories(${PROJECT_NAME}_pic - PUBLIC - ${PROTOBUF_INCLUDE_DIR} - $ - $ -) -target_link_libraries(${PROJECT_NAME}_pic PUBLIC ${PROTOBUF_LIBRARY}) - -set_property(TARGET ${PROJECT_NAME}_pic PROPERTY POSITION_INDEPENDENT_CODE ON) - -install(TARGETS ${PROJECT_NAME}_pic - EXPORT ${PROJECT_NAME}_targets - ARCHIVE DESTINATION "${OSI_INSTALL_LIB_DIR}" COMPONENT lib) - -add_library(${PROJECT_NAME} SHARED $) -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} - PUBLIC - ${PROTOBUF_INCLUDE_DIR} - $ - $ -) - -set_property( - TARGET ${PROJECT_NAME} - PROPERTY SOVERSION ${${PROJECT_NAME}_SOVERSION} -) -set_property( - TARGET ${PROJECT_NAME} - PROPERTY VERSION ${${PROJECT_NAME}_LIBVERSION} -) - -target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY}) -install(TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}_targets - DESTINATION "${OSI_INSTALL_LIB_DIR}" COMPONENT lib) - -# Copy proto headers to where they are expected by the package config file -add_custom_command( - TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory - ${CMAKE_CURRENT_BINARY_DIR}/${OSI_INSTALL_INCLUDE_DIR} - COMMAND ${CMAKE_COMMAND} -E copy - ${PROTO_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/${OSI_INSTALL_INCLUDE_DIR}) - -# Create the package config files -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/open_simulation_interface-config-version.cmake" - VERSION ${OPEN_SIMULATION_INTERFACE_VERSION} - COMPATIBILITY SameMajorVersion -) - -export(EXPORT ${PROJECT_NAME}_targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/open_simulation_interface-targets.cmake" - NAMESPACE ${PROJECT_NAME}:: -) - -configure_package_config_file(open_simulation_interface-config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/open_simulation_interface-config.cmake" - INSTALL_DESTINATION ${OSI_INSTALL_CMAKE_DIR} - PATH_VARS OSI_INSTALL_INCLUDE_DIR - NO_CHECK_REQUIRED_COMPONENTS_MACRO -) - -# Install the *cmake files -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/open_simulation_interface-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/open_simulation_interface-config-version.cmake" - DESTINATION "${OSI_INSTALL_CMAKE_DIR}" - COMPONENT dev) - -# Header files -install(FILES ${PROTO_HEADERS} ${FLAT_HEADERS} - DESTINATION "${OSI_INSTALL_INCLUDE_DIR}") - -# Install the export set for use with the install-tree -install(EXPORT ${PROJECT_NAME}_targets - FILE open_simulation_interface-targets.cmake - NAMESPACE ${PROJECT_NAME}:: - DESTINATION "${OSI_INSTALL_CMAKE_DIR}" - COMPONENT dev) - -if(OSI_BUILD_DOCUMENTATION) - # add a target to generate API documentation with Doxygen - # Dependencies: Doxygen and proto2cpp.py - find_package(Doxygen) - if(Doxygen_FOUND) - set(FILTER_PROTO2CPP_PY_PATH CACHE PATH "directory to the filter proto2cpp.py") - if(NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py) - message(WARNING "${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py could not be found.") - else() - set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/doxygen_config.cmake.in) - set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - configure_file(${doxyfile_in} ${doxyfile} @ONLY) - - add_custom_target(api_doc ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - endif() - endif() -endif() diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ceeea233f..000000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include VERSION diff --git a/convert-to-proto3.sh b/convert-to-proto3.sh deleted file mode 100644 index 6cda582e9..000000000 --- a/convert-to-proto3.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# This shell script converts all proto files to proto3 syntax, which can -# then be used as a stand in for the proto2 syntax files. The resulting -# on-the-wire format should be compatible with the proto2-based formats -# in all respects. -# -# Call this script prior to building normally if you want/need to use -# proto3 syntax, e.g. for language bindings that do not support proto2, -# like C#. - -test -f osi_version.proto && rm osi_version.proto - -for f in osi_version.proto.in osi_*.proto -do - mv $f $f.pb2 && sed -e 's/syntax *= *"proto2";/syntax = "proto3";/' -e 's/^\([ \t]*\)optional /\1/' $f.pb2 > $f -done - -mv CMakeLists.txt CMakeLists.txt.pb2 && sed -e 's/find_package(Protobuf 2.6.1 REQUIRED)/find_package(Protobuf 3.0.0 REQUIRED)/' CMakeLists.txt.pb2 > CMakeLists.txt diff --git a/open_simulation_interface-config-version.cmake.in b/open_simulation_interface-config-version.cmake.in deleted file mode 100644 index 2f6ae95e7..000000000 --- a/open_simulation_interface-config-version.cmake.in +++ /dev/null @@ -1,21 +0,0 @@ - -set(PACKAGE_VERSION_MAJOR "@VERSION_MAJOR@") - -set(PACKAGE_VERSION "@OPEN_SIMULATION_INTERFACE_VERSION@") -if("${PACKAGE_FIND_VERSION}" VERSION_EQUAL "0") - message(FATAL_ERROR "Please select at least the major version you want to use!") -else() - # Check whether the requested PACKAGE_FIND_VERSION is compatible - if("${PACKAGE_VERSION_MAJOR}" VERSION_EQUAL "${PACKAGE_FIND_VERSION_MAJOR}") - if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_COMPATIBLE FALSE) - else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") - set(PACKAGE_VERSION_EXACT TRUE) - endif() - endif() - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() -endif() diff --git a/open_simulation_interface-config.cmake.in b/open_simulation_interface-config.cmake.in deleted file mode 100644 index a285246e2..000000000 --- a/open_simulation_interface-config.cmake.in +++ /dev/null @@ -1,10 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -find_dependency(Protobuf) - -if(NOT TARGET @PROJECT_NAME@ AND NOT @PROJECT_NAME@_BINARY_DIR) - set_and_check(OPEN_SIMULATION_INTERFACE_INCLUDE_DIRS "@PACKAGE_OSI_INSTALL_INCLUDE_DIR@") - set(OPEN_SIMULATION_INTERFACE_LIBRARIES "@PROJECT_NAME@") - include("${CMAKE_CURRENT_LIST_DIR}/open_simulation_interface-targets.cmake") -endif() diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 6627fa881..000000000 --- a/pyproject.toml +++ /dev/null @@ -1,35 +0,0 @@ -[build-system] -requires = [ - "setuptools", - "wheel", - "protoc-wheel-0==24.4", -] -build-backend = "setuptools.build_meta" - -[project] -name = "open-simulation-interface" -description = "ASAM Open Simulation Interface Python Bindings." -authors = [ - {name = "ASAM Open Simulation Interface Project", email = "osi@asam.net"}, -] -maintainers = [ - {name = "ASAM Open Simulation Interface Project", email = "osi@asam.net"}, -] -dependencies = [ - "protobuf>=4.24.4", -] - -license = {file = "LICENSE"} -readme = "README.md" -classifiers = [ - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", -] -dynamic = ["version"] - -[project.urls] -Homepage = "https://github.com/OpenSimulationInterface/open-simulation-interface" -Repository = "https://github.com/OpenSimulationInterface/open-simulation-interface.git" -"Bug Tracker" = "https://github.com/OpenSimulationInterface/open-simulation-interface/issues" - -[project.scripts] -osi2read = "osi3trace.osi2read:main" diff --git a/setup.py b/setup.py deleted file mode 100644 index ea0e93eba..000000000 --- a/setup.py +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/local/env python3 -# -*- coding: UTF-8 -*- - -import os -import subprocess -import sys -import re -from distutils.spawn import find_executable - -from setuptools import setup -from setuptools.command.sdist import sdist -from setuptools.command.build_py import build_py - -# protoc -from protoc import PROTOC_EXE - -# configure the version number -VERSION_MAJOR = None -VERSION_MINOR = None -VERSION_PATCH = None -VERSION_SUFFIX = None -with open("VERSION", "rt") as versionin: - for line in versionin: - if line.startswith("VERSION_MAJOR"): - VERSION_MAJOR = int(line.split("=")[1].strip()) - if line.startswith("VERSION_MINOR"): - VERSION_MINOR = int(line.split("=")[1].strip()) - if line.startswith("VERSION_PATCH"): - VERSION_PATCH = int(line.split("=")[1].strip()) - if line.startswith("VERSION_SUFFIX"): - VERSION_SUFFIX = line.split("=")[1].strip() - -package_name = "osi3" -package_path = os.path.join(os.getcwd(), package_name) - - -class ProtobufGenerator: - @staticmethod - def find_protoc(): - """Locates protoc executable""" - - if os.path.exists(PROTOC_EXE): - protoc = PROTOC_EXE - elif "PROTOC" in os.environ and os.path.exists(os.environ["PROTOC"]): - protoc = os.environ["PROTOC"] - else: - protoc = find_executable("protoc") - - if protoc is None: - sys.stderr.write( - "protoc not found. Is protobuf-compiler installed? \n" - "Alternatively, you can point the PROTOC environment variable " - "to a local version." - ) - sys.exit(1) - return protoc - - osi_files = ( - "osi_common.proto", - "osi_datarecording.proto", - "osi_detectedlane.proto", - "osi_detectedobject.proto", - "osi_detectedoccupant.proto", - "osi_detectedroadmarking.proto", - "osi_detectedtrafficlight.proto", - "osi_detectedtrafficsign.proto", - "osi_environment.proto", - "osi_featuredata.proto", - "osi_groundtruth.proto", - "osi_hostvehicledata.proto", - "osi_lane.proto", - "osi_logicaldetectiondata.proto", - "osi_logicallane.proto", - "osi_motionrequest.proto", - "osi_object.proto", - "osi_occupant.proto", - "osi_referenceline.proto", - "osi_roadmarking.proto", - "osi_route.proto", - "osi_sensordata.proto", - "osi_sensorspecific.proto", - "osi_sensorview.proto", - "osi_sensorviewconfiguration.proto", - "osi_streamingupdate.proto", - "osi_trafficcommand.proto", - "osi_trafficcommandupdate.proto", - "osi_trafficlight.proto", - "osi_trafficsign.proto", - "osi_trafficupdate.proto", - "osi_version.proto", - ) - - """ Generate Protobuf Messages """ - - def generate(self): - sys.stdout.write("Generating Protobuf Version Message\n") - with open("osi_version.proto.in", "rt") as fin: - with open("osi_version.proto", "wt") as fout: - for line in fin: - lineConfigured = line.replace("@VERSION_MAJOR@", str(VERSION_MAJOR)) - lineConfigured = lineConfigured.replace( - "@VERSION_MINOR@", str(VERSION_MINOR) - ) - lineConfigured = lineConfigured.replace( - "@VERSION_PATCH@", str(VERSION_PATCH) - ) - fout.write(lineConfigured) - pattern = re.compile('^import "osi_') - for source in self.osi_files: - with open(source) as src_file: - with open(os.path.join(package_path, source), "w") as dst_file: - for line in src_file: - dst_file.write( - pattern.sub('import "' + package_name + "/osi_", line) - ) - for source in self.osi_files: - sys.stdout.write("Protobuf-compiling " + source + "\n") - source_path = os.path.join(package_name, source) - subprocess.check_call( - [self.find_protoc(), "--python_out=.", "--pyi_out=.", source_path] - ) - - def maybe_generate(self): - if os.path.exists("osi_version.proto.in"): - self.generate() - - -class CustomBuildPyCommand(build_py): - def run(self): - ProtobufGenerator().maybe_generate() - build_py.run(self) - - -class CustomSDistCommand(sdist): - def run(self): - ProtobufGenerator().generate() - sdist.run(self) - - -try: - os.mkdir(package_path) -except Exception: - pass - -try: - with open(os.path.join(package_path, "__init__.py"), "wt") as init_file: - init_file.write( - f"__version__ = '{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_PATCH}{VERSION_SUFFIX or ''}'\n" - ) -except Exception: - pass - -setup( - version=str(VERSION_MAJOR) - + "." - + str(VERSION_MINOR) - + "." - + str(VERSION_PATCH) - + (VERSION_SUFFIX or ""), - packages=[package_name, "osi3trace"], - cmdclass={ - "sdist": CustomSDistCommand, - "build_py": CustomBuildPyCommand, - }, -) diff --git a/tests/test_osi_trace.py b/tests/test_osi_trace.py deleted file mode 100644 index 9d74f5a9d..000000000 --- a/tests/test_osi_trace.py +++ /dev/null @@ -1,589 +0,0 @@ -import os -import tempfile -import unittest - -from osi3trace.osi_trace import OSITrace -from osi3.osi_sensorview_pb2 import SensorView -from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration -from osi3.osi_groundtruth_pb2 import GroundTruth -from osi3.osi_hostvehicledata_pb2 import HostVehicleData -from osi3.osi_sensordata_pb2 import SensorData -from osi3.osi_trafficcommand_pb2 import TrafficCommand -from osi3.osi_trafficcommandupdate_pb2 import TrafficCommandUpdate -from osi3.osi_trafficupdate_pb2 import TrafficUpdate -from osi3.osi_motionrequest_pb2 import MotionRequest -from osi3.osi_streamingupdate_pb2 import StreamingUpdate - -import struct - - -class TestOSITrace(unittest.TestCase): - def test_osi_trace_sv(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_sv.txth") - path_input = os.path.join(tmpdirname, "input_sv.osi") - create_sample_sv(path_input) - - trace = OSITrace(path_input) - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, SensorView) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_svc(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_svc.txth") - path_input = os.path.join(tmpdirname, "input_svc.osi") - create_sample_svc(path_input) - - trace = OSITrace(path_input, "SensorViewConfiguration") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, SensorViewConfiguration) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 1) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_gt(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_gt.txth") - path_input = os.path.join(tmpdirname, "input_gt.osi") - create_sample_gt(path_input) - - trace = OSITrace(path_input, "GroundTruth") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, GroundTruth) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_hvd(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_hvd.txth") - path_input = os.path.join(tmpdirname, "input_hvd.osi") - create_sample_hvd(path_input) - - trace = OSITrace(path_input, "HostVehicleData") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, HostVehicleData) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_sd(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_sd.txth") - path_input = os.path.join(tmpdirname, "input_sd.osi") - create_sample_sd(path_input) - - trace = OSITrace(path_input, "SensorData") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, SensorData) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_tc(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_tc.txth") - path_input = os.path.join(tmpdirname, "input_tc.osi") - create_sample_tc(path_input) - - trace = OSITrace(path_input, "TrafficCommand") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, TrafficCommand) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_tcu(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_tcu.txth") - path_input = os.path.join(tmpdirname, "input_tcu.osi") - create_sample_tcu(path_input) - - trace = OSITrace(path_input, "TrafficCommandUpdate") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, TrafficCommandUpdate) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_tu(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_tu.txth") - path_input = os.path.join(tmpdirname, "input_tu.osi") - create_sample_tu(path_input) - - trace = OSITrace(path_input, "TrafficUpdate") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, TrafficUpdate) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_mr(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_mr.txth") - path_input = os.path.join(tmpdirname, "input_mr.osi") - create_sample_mr(path_input) - - trace = OSITrace(path_input, "MotionRequest") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, MotionRequest) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_su(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_output = os.path.join(tmpdirname, "output_su.txth") - path_input = os.path.join(tmpdirname, "input_su.osi") - create_sample_su(path_input) - - trace = OSITrace(path_input, "StreamingUpdate") - with open(path_output, "wt") as f: - for message in trace: - self.assertIsInstance(message, StreamingUpdate) - f.write(str(message)) - - self.assertEqual(len(trace.retrieve_offsets()), 10) - trace.close() - - self.assertTrue(os.path.exists(path_output)) - - def test_osi_trace_offsets_robustness(self): - with tempfile.TemporaryDirectory() as tmpdirname: - path_input = os.path.join(tmpdirname, "input_robust.osi") - create_sample_sv(path_input) - - trace = OSITrace(path_input) - # Test whether the function can handle be run multiple times safely - offsets = trace.retrieve_offsets(None) - offsets2 = trace.retrieve_offsets(None) - trace.close() - - self.assertEqual(len(offsets), 10) - self.assertEqual(offsets, offsets2) - - -def create_sample_sv(path): - f = open(path, "ab") - sensorview = SensorView() - - sensorview.version.version_major = 3 - sensorview.version.version_minor = 0 - sensorview.version.version_patch = 0 - - sensorview.timestamp.seconds = 0 - sensorview.timestamp.nanos = 0 - - sensorview.sensor_id.value = 42 - - sv_ground_truth = sensorview.global_ground_truth - sv_ground_truth.version.version_major = 3 - sv_ground_truth.version.version_minor = 0 - sv_ground_truth.version.version_patch = 0 - - sv_ground_truth.timestamp.seconds = 0 - sv_ground_truth.timestamp.nanos = 0 - - moving_object = sv_ground_truth.moving_object.add() - moving_object.id.value = 114 - - # Generate 10 OSI messages for 9 seconds - for i in range(10): - # Increment the time - sensorview.timestamp.seconds += 1 - sensorview.timestamp.nanos += 100000 - - sv_ground_truth.timestamp.seconds += 1 - sv_ground_truth.timestamp.nanos += 100000 - - moving_object.vehicle_classification.type = 2 - - moving_object.base.dimension.length = 5 - moving_object.base.dimension.width = 2 - moving_object.base.dimension.height = 1 - - moving_object.base.position.x = 0.0 + i - moving_object.base.position.y = 0.0 - moving_object.base.position.z = 0.0 - - moving_object.base.orientation.roll = 0.0 - moving_object.base.orientation.pitch = 0.0 - moving_object.base.orientation.yaw = 0.0 - - """Serialize""" - bytes_buffer = sensorview.SerializeToString() - f.write(struct.pack(" Date: Tue, 22 Jul 2025 16:16:16 +0200 Subject: [PATCH 2/3] Rework workflow, remove obsolete python files Signed-off-by: Pierre R. Mai --- .github/workflows/protobuf.yml | 179 ++----------------------------- CMakeLists.txt | 33 ++++++ osi3trace/osi2read.py | 66 ------------ osi3trace/osi_trace.py | 188 --------------------------------- 4 files changed, 42 insertions(+), 424 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 osi3trace/osi2read.py delete mode 100644 osi3trace/osi_trace.py diff --git a/.github/workflows/protobuf.yml b/.github/workflows/protobuf.yml index 050c9a212..b4718a086 100644 --- a/.github/workflows/protobuf.yml +++ b/.github/workflows/protobuf.yml @@ -1,10 +1,5 @@ name: ProtoBuf CI Builds -env: - PROTOBUF_VERSION: 3.20.1 - PROTOBUF_VARIANT: '-all' # Use '-all' prior to 22.0, '' after - ABSEIL_VERSION: 20230802.1 - on: push: pull_request: @@ -21,8 +16,8 @@ jobs: with: config_path: .github/.pyspelling.yml - build-proto2-linux64: - name: Build Proto2 Linux 64 + run-tests: + name: Run tests and build docs runs-on: ubuntu-22.04 @@ -32,11 +27,6 @@ jobs: with: submodules: true - - name: Check Build Setup - run: | - ( result=0 ; for f in *.proto ; do grep -wq "$f" CMakeLists.txt || { echo "Missing $f in CMakeLists.txt" && let "result++"; } ; done ; exit $result ) - ( result=0 ; for f in *.proto ; do grep -q '"'$f'"' setup.py || { echo "Missing $f in setup.py" && let "result++"; } ; done ; exit $result ) - - name: Setup Python uses: actions/setup-python@v5 with: @@ -45,49 +35,15 @@ jobs: - name: Install Python Dependencies run: | python -m pip install --upgrade pip - python -m pip install build python -m pip install -r requirements_tests.txt - - name: Check black format - run: | - black --check --diff . - - name: Install Doxygen run: sudo apt-get install doxygen graphviz - - name: Cache Dependencies - id: cache-depends - uses: actions/cache@v4 - with: - path: protobuf-${{ env.PROTOBUF_VERSION }} - key: ${{ runner.os }}-v2-depends - - - name: Download ProtoBuf ${{ env.PROTOBUF_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' - run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${{env.PROTOBUF_VERSION}}/protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz && tar xzvf protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz - - - name: Download Abseil ${{ env.ABSEIL_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - run: curl -OL https://github.com/abseil/abseil-cpp/archive/refs/tags/${{env.ABSEIL_VERSION}}.tar.gz && tar xzvf ${{env.ABSEIL_VERSION}}.tar.gz && rm -rf protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp && mv abseil-cpp-${{env.ABSEIL_VERSION}} protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via autotools - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '-all' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: ./configure DIST_LANG=cpp --prefix=/usr && make - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via cmake - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: cmake -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF . && cmake --build . --config Release -j 4 - - - name: Install ProtoBuf ${{ env.PROTOBUF_VERSION }} - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: sudo make install && sudo ldconfig - - name: Install proto2cpp run: git clone --depth 1 https://github.com/OpenSimulationInterface/proto2cpp.git - - name: Prepare C++ Build + - name: Prepare Build run: mkdir build - name: Add Development Version Suffix @@ -105,136 +61,19 @@ jobs: echo "EXCLUDE_PATTERNS = */osi3/* */protobuf-*/* */proto2cpp/* */flatbuffers/*" >> doxygen_config.cmake.in echo "GENERATE_TREEVIEW = YES" >> doxygen_config.cmake.in - - name: Configure C++ Build + - name: Configure Build working-directory: build - run: cmake -D FILTER_PROTO2CPP_PY_PATH=$GITHUB_WORKSPACE/proto2cpp ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} .. + run: cmake -D FILTER_PROTO2CPP_PY_PATH=$GITHUB_WORKSPACE/proto2cpp .. - - name: Build C++ + - name: Build working-directory: build run: cmake --build . --config Release -j 4 - - name: Build Python - run: python -m build - - - name: Install Python - run: python -m pip install . - - name: Run Python Tests run: python -m unittest discover tests - - name: Upload Python Distribution - if: ${{ github.event_name == 'pull_request' || ( github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') ) ) }} + - name: Upload documentation uses: actions/upload-artifact@v4 with: - name: python-dist - path: dist/ - - build-proto3-linux64: - name: Build Proto3 Linux 64 - - runs-on: ubuntu-22.04 - - steps: - - name: Checkout OSI - uses: actions/checkout@v4 - with: - submodules: true - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.8' - - - name: Install Python Dependencies - run: | - python -m pip install --upgrade pip - python -m pip install build - python -m pip install -r requirements_tests.txt - - - name: Cache Dependencies - id: cache-depends - uses: actions/cache@v4 - with: - path: protobuf-${{ env.PROTOBUF_VERSION }} - key: ${{ runner.os }}-v2-depends - - - name: Download ProtoBuf ${{ env.PROTOBUF_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' - run: curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v${{env.PROTOBUF_VERSION}}/protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz && tar xzvf protobuf${{env.PROTOBUF_VARIANT}}-${{env.PROTOBUF_VERSION}}.tar.gz - - - name: Download Abseil ${{ env.ABSEIL_VERSION }} - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - run: curl -OL https://github.com/abseil/abseil-cpp/archive/refs/tags/${{env.ABSEIL_VERSION}}.tar.gz && tar xzvf ${{env.ABSEIL_VERSION}}.tar.gz && rm -rf protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp && mv abseil-cpp-${{env.ABSEIL_VERSION}} protobuf-${{env.PROTOBUF_VERSION}}/third_party/abseil-cpp - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via autotools - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '-all' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: ./configure DIST_LANG=cpp --prefix=/usr && make - - - name: Build ProtoBuf ${{ env.PROTOBUF_VERSION }} via cmake - if: steps.cache-depends.outputs.cache-hit != 'true' && env.PROTOBUF_VARIANT == '' - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: cmake -DCMAKE_CXX_STANDARD=17 -Dprotobuf_BUILD_SHARED_LIBS=ON -Dprotobuf_BUILD_TESTS=OFF . && cmake --build . --config Release -j 4 - - - name: Install ProtoBuf ${{ env.PROTOBUF_VERSION }} - working-directory: protobuf-${{ env.PROTOBUF_VERSION }} - run: sudo make install && sudo ldconfig - - - name: Prepare C++ Build - run: mkdir build - - - name: Switch to Proto3 Syntax - run: | - bash convert-to-proto3.sh - rm *.pb2 - - - name: Add Development Version Suffix - if: ${{ !startsWith(github.ref, 'refs/tags') }} - run: | - echo "VERSION_SUFFIX = .dev`date -u '+%Y%m%d%H%M%S'`" >> VERSION - - - name: Configure C++ Build - working-directory: build - run: cmake ${{ env.PROTOBUF_VARIANT =='' && '-DCMAKE_CXX_STANDARD=17' }} .. - - - name: Build C++ - working-directory: build - run: cmake --build . --config Release -j 4 - - - name: Build Python - run: python -m build - - - name: Install Python - run: python -m pip install . - - - name: Run Python Tests - run: python -m unittest discover tests - - publish-python-dist: - name: Publish Python Distribution - - runs-on: ubuntu-22.04 - - permissions: - id-token: write - - needs: [build-proto2-linux64, build-proto3-linux64] - - if: ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') ) }} - - steps: - - name: Download Distribution - uses: actions/download-artifact@v4 - with: - name: python-dist - path: dist/ - - - name: Publish Snapshot Release on TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - continue-on-error: true - with: - repository-url: https://test.pypi.org/legacy/ - - - name: Publish Full Release on PyPI - if: startsWith(github.ref, 'refs/tags/v') && ( ! contains(github.ref, '-') ) - uses: pypa/gh-action-pypi-publish@release/v1 + name: doxygen-doc + path: doc/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..3cf21e062 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.10) + +project(open_simulation_interface_doc) + +# read the version number from the file "VERSION" +file(STRINGS "VERSION" VERSION_CONTENTS) +foreach(LINE ${VERSION_CONTENTS}) + string(REGEX REPLACE " |\t" "" LINE ${LINE}) + string(REGEX MATCH "^[^=]+" VERSION_NAME ${LINE}) + string(REPLACE "${VERSION_NAME}=" "" VERSION_VALUE ${LINE}) + set(${VERSION_NAME} "${VERSION_VALUE}") +endforeach() + +configure_file(osi_version.proto.in osi_version.proto) + +# add a target to generate API documentation with Doxygen +# Dependencies: Doxygen and proto2cpp.py +find_package(Doxygen) +if(Doxygen_FOUND) + set(FILTER_PROTO2CPP_PY_PATH CACHE PATH "directory to the filter proto2cpp.py") + if(NOT EXISTS ${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py) + message(WARNING "${FILTER_PROTO2CPP_PY_PATH}/proto2cpp.py could not be found.") + else() + set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/doxygen_config.cmake.in) + set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + + configure_file(${doxyfile_in} ${doxyfile} @ONLY) + + add_custom_target(api_doc ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + endif() +endif() diff --git a/osi3trace/osi2read.py b/osi3trace/osi2read.py deleted file mode 100644 index a75bb9a76..000000000 --- a/osi3trace/osi2read.py +++ /dev/null @@ -1,66 +0,0 @@ -""" -This program converts serialized osi trace files into a human readable txth file. - -Example usage: - python3 osi2read.py -d trace.osi -o myreadableosifile -""" - -from osi3trace.osi_trace import OSITrace -import argparse -import pathlib - - -def command_line_arguments(): - """Define and handle command line interface""" - - parser = argparse.ArgumentParser( - description="Convert a serialized osi trace file to a readable txth output.", - prog="osi2read", - ) - parser.add_argument( - "--data", - "-d", - help="Path to the file with serialized data.", - type=str, - required=True, - ) - parser.add_argument( - "--type", - "-t", - help="Name of the type used to serialize data.", - choices=OSITrace.message_types(), - default="SensorView", - type=str, - required=False, - ) - parser.add_argument( - "--output", - "-o", - help="Output name of the file.", - type=str, - required=False, - ) - - return parser.parse_args() - - -def main(): - # Handling of command line arguments - args = command_line_arguments() - - # Initialize the OSI trace class - trace = OSITrace(args.data, args.type) - - if not args.output: - path = pathlib.Path(args.data).with_suffix(".txth") - args.output = str(path) - - with open(args.output, "wt") as f: - for message in trace: - f.write(str(message)) - - trace.close() - - -if __name__ == "__main__": - main() diff --git a/osi3trace/osi_trace.py b/osi3trace/osi_trace.py deleted file mode 100644 index 3c0577023..000000000 --- a/osi3trace/osi_trace.py +++ /dev/null @@ -1,188 +0,0 @@ -""" -Module to handle and manage OSI trace files. -""" - -import lzma -import struct - -from osi3.osi_sensorview_pb2 import SensorView -from osi3.osi_sensorviewconfiguration_pb2 import SensorViewConfiguration -from osi3.osi_groundtruth_pb2 import GroundTruth -from osi3.osi_hostvehicledata_pb2 import HostVehicleData -from osi3.osi_sensordata_pb2 import SensorData -from osi3.osi_trafficcommand_pb2 import TrafficCommand -from osi3.osi_trafficcommandupdate_pb2 import TrafficCommandUpdate -from osi3.osi_trafficupdate_pb2 import TrafficUpdate -from osi3.osi_motionrequest_pb2 import MotionRequest -from osi3.osi_streamingupdate_pb2 import StreamingUpdate - - -MESSAGES_TYPE = { - "SensorView": SensorView, - "SensorViewConfiguration": SensorViewConfiguration, - "GroundTruth": GroundTruth, - "HostVehicleData": HostVehicleData, - "SensorData": SensorData, - "TrafficCommand": TrafficCommand, - "TrafficCommandUpdate": TrafficCommandUpdate, - "TrafficUpdate": TrafficUpdate, - "MotionRequest": MotionRequest, - "StreamingUpdate": StreamingUpdate, -} - - -class OSITrace: - """This class can import and decode OSI trace files.""" - - @staticmethod - def map_message_type(type_name): - """Map the type name to the protobuf message type.""" - return MESSAGES_TYPE[type_name] - - @staticmethod - def message_types(): - """Message types that OSITrace supports.""" - return list(MESSAGES_TYPE.keys()) - - def __init__(self, path=None, type_name="SensorView", cache_messages=False): - self.type = self.map_message_type(type_name) - self.file = None - self.current_index = None - self.message_offsets = None - self.read_complete = False - self.message_cache = {} if cache_messages else None - self._header_length = 4 - if path: - self.from_file(path, type_name, cache_messages) - - def from_file(self, path, type_name="SensorView", cache_messages=False): - """Import a trace from a file""" - self.type = self.map_message_type(type_name) - - if path.lower().endswith((".lzma", ".xz")): - self.file = lzma.open(path, "rb") - else: - self.file = open(path, "rb") - - self.read_complete = False - self.current_index = 0 - self.message_offsets = [0] - self.message_cache = {} if cache_messages else None - - def retrieve_offsets(self, limit=None): - """Retrieve the offsets of the messages from the file.""" - if not self.read_complete: - self.current_index = len(self.message_offsets) - 1 - self.file.seek(self.message_offsets[-1], 0) - while not self.read_complete and ( - not limit or len(self.message_offsets) <= limit - ): - self.retrieve_message(skip=True) - return self.message_offsets - - def retrieve_message(self, index=None, skip=False): - """Retrieve the next message from the file at the current position or given index, or skip it if skip is true.""" - if index is not None: - self.current_index = index - self.file.seek(self.message_offsets[index], 0) - if self.message_cache is not None and self.current_index in self.message_cache: - message = self.message_cache[self.current_index] - self.current_index += 1 - if self.current_index == len(self.message_offsets): - self.file.seek(0, 2) - else: - self.file.seek(self.message_offsets[self.current_index], 0) - if skip: - return self.message_offsets[self.current_index] - else: - return message - start = self.file.tell() - header = self.file.read(self._header_length) - if len(header) < self._header_length: - if start == self.message_offsets[-1]: - self.message_offsets.pop() - self.read_complete = True - self.file.seek(start, 0) - return None - message_length = struct.unpack("= len(self.message_offsets): - self.retrieve_offsets(index) - if self.message_cache is not None and index in self.message_cache: - return self.message_cache[index] - return self.retrieve_message(index=index) - - def get_messages(self): - """ - Yield an iterator over all messages in the file. - """ - return self.get_messages_in_index_range(0, None) - - def get_messages_in_index_range(self, begin, end): - """ - Yield an iterator over messages of indexes between begin and end included. - """ - if begin >= len(self.message_offsets): - self.retrieve_offsets(begin) - self.restart(begin) - current = begin - while end is None or current < end: - if self.message_cache is not None and current in self.message_cache: - yield self.message_cache[current] - else: - message = self.retrieve_message() - if message is None: - break - yield message - current += 1 - - def close(self): - if self.file: - self.file.close() - self.file = None - self.current_index = None - self.message_cache = None - self.message_offsets = None - self.read_complete = False - self.read_limit = None - self.type = None From 960d23d99d20257578be3eb79ff3ac67ac88b7e2 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Tue, 22 Jul 2025 17:01:16 +0200 Subject: [PATCH 3/3] Further workflow adjustments Signed-off-by: Pierre R. Mai --- .github/workflows/protobuf.yml | 29 +++++++++++++++++++---------- requirements_tests.txt | 1 - 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/protobuf.yml b/.github/workflows/protobuf.yml index b4718a086..0c323f8a3 100644 --- a/.github/workflows/protobuf.yml +++ b/.github/workflows/protobuf.yml @@ -1,4 +1,4 @@ -name: ProtoBuf CI Builds +name: OSI CI Builds on: push: @@ -8,7 +8,7 @@ on: jobs: spellcheck: name: Spellcheck - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: rojopolis/spellcheck-github-actions@0.36.0 @@ -17,15 +17,13 @@ jobs: config_path: .github/.pyspelling.yml run-tests: - name: Run tests and build docs + name: Run tests - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - name: Checkout OSI uses: actions/checkout@v4 - with: - submodules: true - name: Setup Python uses: actions/setup-python@v5 @@ -37,6 +35,18 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements_tests.txt + - name: Run Python Tests + run: python -m unittest discover tests + + build-docs: + name: Build docs + + runs-on: ubuntu-24.04 + + steps: + - name: Checkout OSI + uses: actions/checkout@v4 + - name: Install Doxygen run: sudo apt-get install doxygen graphviz @@ -69,11 +79,10 @@ jobs: working-directory: build run: cmake --build . --config Release -j 4 - - name: Run Python Tests - run: python -m unittest discover tests - - name: Upload documentation uses: actions/upload-artifact@v4 with: name: doxygen-doc - path: doc/ + path: | + doc/html/ + doc/images/ diff --git a/requirements_tests.txt b/requirements_tests.txt index 4872aecca..c3726e8bf 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,2 +1 @@ pyyaml -black==24.3.0