diff --git a/.dapr/components/pubsub.yaml b/.dapr/components/pubsub.yaml
deleted file mode 100644
index fb32dcdb..00000000
--- a/.dapr/components/pubsub.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-apiVersion: dapr.io/v1alpha1
-kind: Component
-metadata:
- name: mqtt-pubsub
- namespace: default
-spec:
- type: pubsub.mqtt
- version: v1
- metadata:
- - name: url
- value: "mqtt://localhost:1883"
- - name: qos
- value: 1
- - name: retain
- value: "false"
- - name: cleanSession
- value: "false"
diff --git a/.dapr/config.yaml b/.dapr/config.yaml
deleted file mode 100644
index e881bc33..00000000
--- a/.dapr/config.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-apiVersion: dapr.io/v1alpha1
-kind: Configuration
-metadata:
- name: config
-spec:
- tracing:
- samplingRate: "1"
- zipkin:
- endpointAddress: http://localhost:9411/api/v2/spans
- features:
- - name: proxy.grpc
- enabled: true
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 3d695e7f..8b890c9a 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -12,12 +12,7 @@
#
# SPDX-License-Identifier: Apache-2.0
-FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.2
-
-# Force dapr to use localhost traffic
-ENV DAPR_HOST_IP="127.0.0.1"
-# Add daprd to the path for the VS Code Dapr extension.
-ENV PATH=$PATH:/home/vscode/.dapr/bin
+FROM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.3
ENV DOCKER_BUILDKIT=1
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 016bceda..b21df3c3 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -38,11 +38,9 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
- "ms-azuretools.vscode-dapr",
"ms-azuretools.vscode-docker",
"rpdswtk.vsmqtt",
"dotjoshjohnson.xml",
- "ms-kubernetes-tools.vscode-kubernetes-tools",
"matangover.mypy",
"anweber.vscode-httpyac",
"ms-python.mypy-type-checker",
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 657ea2c4..4ca6d162 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -59,11 +59,10 @@ jobs:
- name: Run Linters
uses: pre-commit/action@v3.0.0
- - name: Run the daparized databroker binary
+ - name: Run the databroker binary
run: |
- ./.vscode/scripts/ensure-dapr.sh DAPR --task
./.vscode/scripts/run-mosquitto.sh --task &
- ./.vscode/scripts/run-vehicledatabroker.sh DAPR --task &
+ ./.vscode/scripts/run-vehicledatabroker.sh --task &
sleep 10s
- name: Run unit and integration tests
diff --git a/.github/workflows/project-creation.yaml b/.github/workflows/project-creation.yaml
index 575368fa..28b5461d 100644
--- a/.github/workflows/project-creation.yaml
+++ b/.github/workflows/project-creation.yaml
@@ -47,7 +47,7 @@ jobs:
with:
repository: eclipse-velocitas/cli
path: cli
- ref: v0.6.3
+ ref: v0.7.0
- name: Checkout SDK repo
uses: actions/checkout@v4
@@ -60,6 +60,13 @@ jobs:
cd cli
npm i && npm run build && npx oclif manifest && npm i -g .
+ - name: Checkout vehicle-app-template
+ uses: actions/checkout@v4
+ with:
+ repository: eclipse-velocitas/vehicle-app-template
+ path: vehicle-app-template
+ ref: main
+
- name: Create project
shell: bash
run: |
@@ -76,12 +83,12 @@ jobs:
velocitas
# copy "full" package-index.json from CLI repo
- cp ../cli/testbench/test-create/vehicle-app-template/package-index.json ./package-index.json
+ cp ../vehicle-app-template/package-index.json ./package-index.json
CREATE_ARGS="-n MyApp"
if [ "${{ matrix.example }}" != "no-example" ]; then
CREATE_ARGS="-e ${{ matrix.example }}"
fi
- velocitas create -l python $CREATE_ARGS
+ velocitas create -c vapp-core-python $CREATE_ARGS
- name: Install dependencies
shell: bash
@@ -108,7 +115,6 @@ jobs:
pre-commit run --all-files && \
pip3 install -r .devcontainer/tests/automated_tests/requirements.txt && \
cat app/AppManifest.json && \
- velocitas exec grpc-interface-support generate-sdk && \
pytest -sx .devcontainer/tests/automated_tests
- name: Upload logs
diff --git a/.project-creation/.skeleton/Dockerfile b/.project-creation/.skeleton/Dockerfile
index 45705d06..cdb07bc2 100644
--- a/.project-creation/.skeleton/Dockerfile
+++ b/.project-creation/.skeleton/Dockerfile
@@ -15,18 +15,14 @@
# syntax=docker/dockerfile:1.2
# Build stage, to create the executable
-FROM --platform=$TARGETPLATFORM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.2 as builder
+FROM --platform=$TARGETPLATFORM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.3 as builder
ARG TARGETARCH
RUN apt-get update && apt-get install -y python3-dev
-COPY ./.velocitas.json /workspace/.velocitas_org.json
+COPY ./.velocitas.json /workspace/.velocitas.json
COPY ./app /workspace/app
-# FIXME: For build tooling we only need "devenv-devcontainer-setup", we should be able to
-# filter this without manual jq intervention...
-RUN cat ./workspace/.velocitas_org.json | jq 'del(.packages[] | select(.name|test(".*devenv-devcontainer-setup.*")|not))' > ./workspace/.velocitas.json
-
# Remove this installation for Arm64 once staticx has a prebuilt wheel for Arm64
RUN /bin/bash -c 'set -ex && \
ARCH=`uname -m` && \
@@ -44,7 +40,7 @@ RUN pip3 install --no-cache-dir pyinstaller==5.9.0 \
WORKDIR /workspace
-RUN velocitas init
+RUN velocitas init -v
WORKDIR /workspace/app
diff --git a/.project-creation/.skeleton/requirements-velocitas.txt b/.project-creation/.skeleton/requirements-velocitas.txt
index e5036b53..096499dd 100644
--- a/.project-creation/.skeleton/requirements-velocitas.txt
+++ b/.project-creation/.skeleton/requirements-velocitas.txt
@@ -1 +1 @@
-velocitas-sdk==0.13.1
+velocitas-sdk==0.14.0
diff --git a/.project-creation/.skeleton/requirements.in b/.project-creation/.skeleton/requirements.in
index e527f91c..625e19cd 100644
--- a/.project-creation/.skeleton/requirements.in
+++ b/.project-creation/.skeleton/requirements.in
@@ -14,6 +14,5 @@
grpcio==1.59.0
protobuf==4.24.4
-dapr==1.11.0
cloudevents==1.10.0
aiohttp==3.9.3
diff --git a/.project-creation/.skeleton/requirements.txt b/.project-creation/.skeleton/requirements.txt
index 3c99f4ca..7495d9b0 100644
--- a/.project-creation/.skeleton/requirements.txt
+++ b/.project-creation/.skeleton/requirements.txt
@@ -5,9 +5,7 @@
# pip-compile
#
aiohttp==3.9.3
- # via
- # -r requirements.in
- # dapr
+ # via -r requirements.in
aiosignal==1.3.1
# via aiohttp
async-timeout==4.0.3
@@ -16,8 +14,6 @@ attrs==23.1.0
# via aiohttp
cloudevents==1.10.0
# via -r requirements.in
-dapr==1.11.0
- # via -r requirements.in
deprecation==2.1.0
# via cloudevents
frozenlist==1.4.0
@@ -25,9 +21,7 @@ frozenlist==1.4.0
# aiohttp
# aiosignal
grpcio==1.59.0
- # via
- # -r requirements.in
- # dapr
+ # via -r requirements.in
idna==3.4
# via yarl
multidict==6.0.4
@@ -37,14 +31,6 @@ multidict==6.0.4
packaging==23.2
# via deprecation
protobuf==4.24.4
- # via
- # -r requirements.in
- # dapr
-python-dateutil==2.8.2
- # via dapr
-six==1.16.0
- # via python-dateutil
-typing-extensions==4.8.0
- # via dapr
+ # via -r requirements.in
yarl==1.9.2
# via aiohttp
diff --git a/.project-creation/templates/.devcontainer/tests/automated_tests/runtime_test.py b/.project-creation/templates/.devcontainer/tests/automated_tests/runtime_test.py
index 5f9e34a6..38175bba 100644
--- a/.project-creation/templates/.devcontainer/tests/automated_tests/runtime_test.py
+++ b/.project-creation/templates/.devcontainer/tests/automated_tests/runtime_test.py
@@ -31,10 +31,6 @@ def _set_env(self, runtime: str) -> None:
mqtt_port = 1883
vdb_port = 55555
- if runtime == "runtime_k3d":
- mqtt_port = 31883
- vdb_port = 30555
-
os.environ["MQTT_PORT"] = f"{mqtt_port}"
os.environ["VDB_PORT"] = f"{vdb_port}"
@@ -53,7 +49,7 @@ def _disable_mocking(self) -> None:
"""
)
- @parameterized.expand(["runtime_k3d", "runtime_kanto"])
+ @parameterized.expand(["runtime_kanto"])
def test_runtime(self, runtime):
self._set_env(runtime)
self._disable_mocking()
diff --git a/.project-creation/templates/.vscode/launch.json b/.project-creation/templates/.vscode/launch.json
index 5ebbfe93..7a593813 100644
--- a/.project-creation/templates/.vscode/launch.json
+++ b/.project-creation/templates/.vscode/launch.json
@@ -12,13 +12,10 @@
"name": "VehicleApp",
"program": "${workspaceFolder}/app/src/main.py",
"console": "integratedTerminal",
- "preLaunchTask": "dapr-sidecar-start",
- "postDebugTask": "dapr-sidecar-stop",
"env": {
- "APP_PORT": "50008",
- "DAPR_HTTP_PORT": "3500",
- "DAPR_GRPC_PORT": "50001",
- "VEHICLEDATABROKER_DAPR_APP_ID": "vehicledatabroker"
+ "SDV_MIDDLEWARE_TYPE": "native",
+ "SDV_VEHICLEDATABROKER_ADDRESS": "grpc://127.0.0.1:55555",
+ "SDV_MQTT_ADDRESS": "mqtt://127.0.0.1:1883"
}
}
]
diff --git a/.project-creation/templates/.vscode/tasks.json b/.project-creation/templates/.vscode/tasks.json
index 518ab01e..8f84b51e 100644
--- a/.project-creation/templates/.vscode/tasks.json
+++ b/.project-creation/templates/.vscode/tasks.json
@@ -2,68 +2,40 @@
"version": "2.0.0",
"tasks": [
{
- "label": "dapr-sidecar-start",
- "detail": "Start Dapr sidecar (with dapr run) to be present for debugging the VehicleApp (used by launch config).",
+ "label": "Local Runtime - Up",
+ "detail": "Starts up the local runtime",
"type": "shell",
- "command": "velocitas exec runtime-local run-dapr-sidecar vehicleapp --app-port 50008 --dapr-grpc-port 50001 --dapr-http-port 3500",
+ "command": "velocitas exec runtime-local up",
"group": "none",
- "isBackground": true,
- "presentation": {
- "close": true,
- "reveal": "never"
- },
- "problemMatcher": {
- "pattern": [
- {
- "regexp": ".",
- "file": 1,
- "location": 2,
- "message": 3
- }
- ],
- "background": {
- "activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
- "endsPattern": "."
- }
- },
- "hide": true
- },
- {
- "label": "dapr-sidecar-stop",
- "detail": "Stop Dapr sidecar after finish debugging the VehicleApp (used by launch config).",
- "type": "shell",
- "command": [
- "dapr stop --app-id vehicleapp"
- ],
"presentation": {
- "close": true,
- "reveal": "never"
+ "panel": "dedicated",
+ "clear": true,
},
- "hide": true
+ "problemMatcher": []
},
{
- "label": "Local Runtime - Up",
- "detail": "Starts up the local runtime",
+ "label": "Local Runtime - Down",
+ "detail": "Stops the local runtime",
"type": "shell",
- "command": "velocitas exec runtime-local up",
+ "command": "velocitas exec runtime-local down",
"group": "none",
"presentation": {
- "reveal": "always",
- "panel": "dedicated"
+ "panel": "dedicated",
+ "clear": true,
},
"problemMatcher": []
},
{
"label": "Local Runtime - Run VehicleApp",
- "detail": "Starts the VehicleApp under development (including Dapr sidecar if middleware type is Dapr)",
+ "detail": "Starts the VehicleApp under development",
"type": "shell",
"command": [
- "velocitas exec runtime-local run-vehicle-app --dapr-app-id vehicleapp --dapr-app-port 50008 python3 ${workspaceFolder}/app/src/main.py"
+ "velocitas exec runtime-local run-vehicle-app python3 ${workspaceFolder}/app/src/main.py"
],
"presentation": {
- "close": true,
- "reveal": "never"
+ "panel": "dedicated",
+ "close": false,
+ "reveal": "always"
},
"problemMatcher": []
},
@@ -85,82 +57,6 @@
"isBackground": false,
"problemMatcher": []
},
- {
- "label": "K3D Runtime - Up",
- "detail": "Starts up the K3D runtime.",
- "type": "shell",
- "command": "velocitas exec runtime-k3d up",
- "group": "none",
- "presentation": {
- "reveal": "always",
- "clear": true,
- "close": false
- },
- "problemMatcher": []
- },
- {
- "label": "K3D Runtime - Down",
- "detail": "Stops the K3D runtime",
- "type": "shell",
- "command": "velocitas exec runtime-k3d down",
- "group": "none",
- "presentation": {
- "reveal": "always",
- "clear": true,
- "close": false
- },
- "problemMatcher": []
- },
- {
- "label": "K3D Runtime - Build VehicleApp",
- "detail": "Builds the VehicleApp and pushes it to the local K3D registry.",
- "type": "shell",
- "command": "velocitas exec deployment-k3d build-vehicleapp",
- "group": "none",
- "presentation": {
- "reveal": "always",
- "panel": "dedicated",
- "clear": true,
- "close": false
- },
- "problemMatcher": []
- },
- {
- "label": "K3D Runtime - Deploy VehicleApp",
- "detail": "Builds and deploys the VehicleApp via Helm to the K3D cluster.",
- "type": "shell",
- "command": "velocitas exec deployment-k3d deploy-vehicleapp",
- "group": "none",
- "presentation": {
- "reveal": "always",
- "panel": "dedicated",
- "clear": true,
- "close": false
- },
- "dependsOn": [
- "K3D Runtime - Up",
- // not neccessary but is executed in parallel to Runtime - Up
- "K3D Runtime - Build VehicleApp"
- ],
- "problemMatcher": []
- },
- {
- "label": "K3D Runtime - Deploy VehicleApp (without rebuild)",
- "detail": "Deploys the VehicleApp via Helm to the K3D cluster (without rebuilding it)",
- "type": "shell",
- "command": "velocitas exec deployment-k3d deploy-vehicleapp",
- "group": "none",
- "presentation": {
- "reveal": "always",
- "panel": "dedicated",
- "clear": true,
- "close": false
- },
- "dependsOn": [
- "K3D Runtime - Up"
- ],
- "problemMatcher": []
- },
{
"label": "Import example app from SDK",
"detail": "Replace the app implementation in the app folder by an example app chosen from SDK repository",
diff --git a/.vscode/launch.json b/.vscode/launch.json
index c114b935..c8e5f6e9 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -20,25 +20,6 @@
"SDV_VEHICLEDATABROKER_ADDRESS": "grpc://localhost:55555",
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"
}
- },
- {
- "type": "python",
- "request": "launch",
- "name": "Example, Dapr middleware",
- "cwd": "${workspaceFolder}/examples/${input:example}",
- "program": "${workspaceFolder}/examples/${input:example}/src/main.py",
- "console": "integratedTerminal",
- "preLaunchTask": "dapr-VehicleApp-run",
- "postDebugTask": "dapr-VehicleApp-stop",
- "env": {
- "SDV_MIDDLEWARE_TYPE": "dapr",
- "DAPR_GRPC_PORT": "50001",
- "DAPR_HTTP_PORT": "3500",
- "HVACSERVICE_DAPR_APP_ID": "hvacservice",
- "SEATSERVICE_DAPR_APP_ID": "seatservice",
- "VEHICLEDATABROKER_DAPR_APP_ID": "vehicledatabroker",
- "PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": "python"
- }
}
],
"inputs": [
diff --git a/.vscode/scripts/ensure-dapr.sh b/.vscode/scripts/ensure-dapr.sh
deleted file mode 100755
index f32fb23e..00000000
--- a/.vscode/scripts/ensure-dapr.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-set -e
-
-if [ $1 != "DAPR" ]; then
- echo "Don't install dapr ..."
- exit 0
-fi
-
-echo "#######################################################"
-echo "### Ensure dapr ###"
-echo "#######################################################"
-
-# Function to initialize Dapr
-init_dapr()
-{
- echo "Initialize dapr runtime $DEFAULT_DAPR_RUNTIME_VERSION ..."
- dapr uninstall
- dapr init --runtime-version $DEFAULT_DAPR_RUNTIME_VERSION
- echo "=========================="
- dapr --version
- echo "=========================="
-}
-
-ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/../.." )
-source $ROOT_DIRECTORY/.vscode/scripts/exec-check.sh "$@" $(basename $BASH_SOURCE .sh)
-
-DEFAULT_DAPR_CLI_VERSION=$(cat $ROOT_DIRECTORY/prerequisite_settings.json | jq .dapr.cli.version | tr -d '"')
-DEFAULT_DAPR_RUNTIME_VERSION=$(cat $ROOT_DIRECTORY/prerequisite_settings.json | jq .dapr.runtime.version | tr -d '"')
-INSTALLED_DAPR_CLI_VERSION=$(dapr --version | grep "CLI version: " | sed 's/^.*: //' | sed 's/\s*//g')
-INSTALLED_DAPR_RUNTIME_VERSION=$(dapr --version | grep "Runtime version: " | sed 's/^.*: //' | sed 's/\s*//g')
-
-# Check dapr CLI
-if [ "${INSTALLED_DAPR_CLI_VERSION}" != "${DEFAULT_DAPR_CLI_VERSION}" ]; then
- echo "Install dapr CLI $DEFAULT_DAPR_CLI_VERSION"
- wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s $DEFAULT_DAPR_CLI_VERSION
-else
- echo "Dapr CLI $DEFAULT_DAPR_CLI_VERSION is already installed."
-fi
-
-# check dapr runtime
-if [ "${INSTALLED_DAPR_RUNTIME_VERSION}" != "${DEFAULT_DAPR_RUNTIME_VERSION}" ]; then
- init_dapr
-else
- echo "Dapr Runtime already Initialized."
- echo "=========================="
- dapr --version
- echo "=========================="
-fi
diff --git a/.vscode/scripts/run-feedercan.sh b/.vscode/scripts/run-feedercan.sh
index 686b7522..873b2aa1 100755
--- a/.vscode/scripts/run-feedercan.sh
+++ b/.vscode/scripts/run-feedercan.sh
@@ -30,12 +30,11 @@ then
docker container stop $RUNNING_CONTAINER
fi
-export VEHICLEDATABROKER_DAPR_APP_ID=vehicledatabroker
export DATABROKER_NATIVE_PORT=55555
export LOG_LEVEL=info,databroker=info,dbcfeeder.broker_client=debug,dbcfeeder=debug
export USECASE="databroker"
-if [ $2 == "DOGMODE" ]; then
+if [ $1 == "DOGMODE" ]; then
echo "Use DogMode feeder config ...!"
CONFIG_DIR="$ROOT_DIRECTORY/.vscode/scripts/feeder_config/dogmode"
export DBC_FILE="/data/DogMode.dbc"
@@ -49,38 +48,14 @@ else
export CANDUMP_FILE="/data/candump.log"
fi
-if [ $1 == "DAPR" ]; then
- echo "Run with Dapr ...!"
- dapr run \
- --app-id feedercan \
- --app-protocol grpc \
- --resources-path $ROOT_DIRECTORY/.dapr/components \
- --config $ROOT_DIRECTORY/.dapr/config.yaml \
- -- docker run \
- -v ${CONFIG_DIR}:/data \
- -e VEHICLEDATABROKER_DAPR_APP_ID \
- -e DAPR_GRPC_PORT \
- -e DAPR_HTTP_PORT \
- -e LOG_LEVEL \
- -e USECASE \
- -e CANDUMP_FILE \
- -e DBC_FILE \
- -e MAPPING_FILE \
- --network host \
- $FEEDERCAN_IMAGE:$FEEDERCAN_TAG
-elif [ $1 == "NATIVE" ]; then
- echo "Run native ...!"
- docker run \
- -v ${CONFIG_DIR}:/data \
- -e DAPR_GRPC_PORT=$DATABROKER_NATIVE_PORT \
- -e LOG_LEVEL \
- -e USECASE \
- -e CANDUMP_FILE \
- -e DBC_FILE \
- -e MAPPING_FILE \
- --network host \
- $FEEDERCAN_IMAGE:$FEEDERCAN_TAG
-else
- echo "Error: Unsupported middleware type ($1)!"
- exit 1
-fi
+echo "Run native ...!"
+docker run \
+ -v ${CONFIG_DIR}:/data \
+ -e VDB_ADDRESS="127.0.0.1:$DATABROKER_NATIVE_PORT" \
+ -e LOG_LEVEL \
+ -e USECASE \
+ -e CANDUMP_FILE \
+ -e DBC_FILE \
+ -e MAPPING_FILE \
+ --network host \
+ $FEEDERCAN_IMAGE:$FEEDERCAN_TAG
diff --git a/.vscode/scripts/run-hvacservice.sh b/.vscode/scripts/run-hvacservice.sh
index 2f7d1b25..e31b4067 100755
--- a/.vscode/scripts/run-hvacservice.sh
+++ b/.vscode/scripts/run-hvacservice.sh
@@ -30,33 +30,12 @@ then
docker container stop $RUNNING_CONTAINER
fi
-export VEHICLEDATABROKER_DAPR_APP_ID=vehicledatabroker
export VEHICLEDATABROKER_NATIVE_PORT=55555
export SERVICE_PORT=50052
-if [ $1 == "DAPR" ]; then
- echo "Run with Dapr ...!"
- dapr run \
- --app-id hvacservice \
- --app-protocol grpc \
- --app-port $SERVICE_PORT \
- --resources-path $ROOT_DIRECTORY/.dapr/components \
- --config $ROOT_DIRECTORY/.dapr/config.yaml \
- -- docker run \
- -e VEHICLEDATABROKER_DAPR_APP_ID \
- -e DAPR_GRPC_PORT \
- -e DAPR_HTTP_PORT \
- -e HVAC_ADDR="0.0.0.0:${SERVICE_PORT}" \
- --network host \
- $HVACSERVICE_IMAGE:$HVACSERVICE_TAG
-elif [ $1 == "NATIVE" ]; then
- echo "Run native ...!"
- docker run \
- -e DAPR_GRPC_PORT=$VEHICLEDATABROKER_NATIVE_PORT \
- -e HVAC_ADDR="0.0.0.0:${SERVICE_PORT}" \
- --network host \
- $HVACSERVICE_IMAGE:$HVACSERVICE_TAG
-else
- echo "Error: Unsupported middleware type ($1)!"
- exit 1
-fi
+echo "Run native ...!"
+docker run \
+ -e VDB_ADDRESS="127.0.0.1:$VEHICLEDATABROKER_NATIVE_PORT" \
+ -e HVAC_ADDR="0.0.0.0:${SERVICE_PORT}" \
+ --network host \
+ $HVACSERVICE_IMAGE:$HVACSERVICE_TAG
diff --git a/.vscode/scripts/run-seatservice.sh b/.vscode/scripts/run-seatservice.sh
index 41a67d3b..17f165b9 100755
--- a/.vscode/scripts/run-seatservice.sh
+++ b/.vscode/scripts/run-seatservice.sh
@@ -30,36 +30,14 @@ then
docker container stop $RUNNING_CONTAINER
fi
-export VEHICLEDATABROKER_DAPR_APP_ID=vehicledatabroker
export VEHICLEDATABROKER_NATIVE_PORT=55555
export SERVICE_PORT=50051
export CAN=cansim
-if [ $1 == "DAPR" ]; then
- echo "Run with Dapr ...!"
- dapr run \
- --app-id seatservice \
- --app-protocol grpc \
- --app-port $SERVICE_PORT \
- --resources-path $ROOT_DIRECTORY/.dapr/components \
- --config $ROOT_DIRECTORY/.dapr/config.yaml \
- -- docker run \
- -e VEHICLEDATABROKER_DAPR_APP_ID \
- -e DAPR_GRPC_PORT \
- -e DAPR_HTTP_PORT \
- -e SERVICE_PORT \
- -e CAN \
- --network host \
- $SEATSERVICE_IMAGE:$SEATSERVICE_TAG
-elif [ $1 == "NATIVE" ]; then
- echo "Run native ...!"
- docker run \
- -e DAPR_GRPC_PORT=$VEHICLEDATABROKER_NATIVE_PORT \
- -e SERVICE_PORT \
- -e CAN \
- --network host \
- $SEATSERVICE_IMAGE:$SEATSERVICE_TAG
-else
- echo "Error: Unsupported middleware type ($1)!"
- exit 1
-fi
+echo "Run native ...!"
+docker run \
+ -e VDB_ADDRESS="127.0.0.1:$VEHICLEDATABROKER_NATIVE_PORT" \
+ -e SERVICE_PORT \
+ -e CAN \
+ --network host \
+ $SEATSERVICE_IMAGE:$SEATSERVICE_TAG
diff --git a/.vscode/scripts/run-vehicledatabroker.sh b/.vscode/scripts/run-vehicledatabroker.sh
index 0e05c3e2..1e98d042 100755
--- a/.vscode/scripts/run-vehicledatabroker.sh
+++ b/.vscode/scripts/run-vehicledatabroker.sh
@@ -34,36 +34,11 @@ VSPEC_FILE_PATH=$ROOT_DIRECTORY/.vscode/scripts/broker_config/vss_rel_3.0.json
KUKSA_DATA_BROKER_PORT='55555'
#export RUST_LOG="info,databroker=debug,vehicle_data_broker=debug"
-if [ $1 == "DAPR" ]; then
- echo "Run with Dapr ...!"
- dapr run \
- --app-id vehicledatabroker \
- --app-protocol grpc \
- --app-port $KUKSA_DATA_BROKER_PORT \
- --resources-path $ROOT_DIRECTORY/.dapr/components \
- --config $ROOT_DIRECTORY/.dapr/config.yaml \
- -- docker run \
- --rm \
- --init \
- --name vehicledatabroker \
- -v $VSPEC_FILE_PATH:$VSPEC_FILE_PATH \
- -e KUKSA_DATA_BROKER_METADATA_FILE=$VSPEC_FILE_PATH \
- -e KUKSA_DATA_BROKER_PORT=$KUKSA_DATA_BROKER_PORT \
- -e DAPR_GRPC_PORT \
- -e DAPR_HTTP_PORT \
- -e RUST_LOG \
- --network host \
- $DATABROKER_IMAGE:$DATABROKER_TAG
-elif [ $1 == "NATIVE" ]; then
- echo "Run native ...!"
- docker run \
- -v $VSPEC_FILE_PATH:$VSPEC_FILE_PATH \
- -e KUKSA_DATA_BROKER_METADATA_FILE=$VSPEC_FILE_PATH \
- -e KUKSA_DATA_BROKER_PORT \
- -e RUST_LOG \
- --network host \
- $DATABROKER_IMAGE:$DATABROKER_TAG
-else
- echo "Error: Unsupported middleware type ($1)!"
- exit 1
-fi
+echo "Run native ...!"
+docker run \
+ -v $VSPEC_FILE_PATH:$VSPEC_FILE_PATH \
+ -e KUKSA_DATA_BROKER_METADATA_FILE=$VSPEC_FILE_PATH \
+ -e KUKSA_DATA_BROKER_PORT \
+ -e RUST_LOG \
+ --network host \
+ $DATABROKER_IMAGE:$DATABROKER_TAG
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index b72e45c0..055683c8 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -1,44 +1,6 @@
{
"version": "2.0.0",
"tasks": [
- {
- "label": "dapr-VehicleApp-run",
- "appId": "vehicleapp",
- "appPort": 50008,
- "componentsPath": "./.dapr/components",
- "config": "./.dapr/config.yaml",
- "appProtocol": "grpc",
- "grpcPort": 50001,
- "httpPort": 3500,
- "type": "dapr",
- "presentation": {
- "close": true,
- "reveal": "never"
- },
- "hide": true
- },
- {
- "label": "dapr-VehicleApp-stop",
- "type": "shell",
- "command": [
- "dapr stop --app-id vehicleapp"
- ],
- "presentation": {
- "close": true,
- "reveal": "never"
- },
- "hide": true
- },
- {
- "label": "ensure-dapr",
- "type": "shell",
- "command": "./.vscode/scripts/ensure-dapr.sh ${input:middleware} --task",
- "group": "none",
- "presentation": {
- "close": true
- },
- "problemMatcher": []
- },
{
"label": "run-mosquitto",
"type": "shell",
@@ -68,7 +30,7 @@
{
"label": "run-vehicledatabroker",
"type": "shell",
- "command": "./.vscode/scripts/run-vehicledatabroker.sh ${input:middleware} --task",
+ "command": "./.vscode/scripts/run-vehicledatabroker.sh --task",
"group": "none",
"presentation": {
"reveal": "always",
@@ -86,7 +48,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "Listening on",
"endsPattern": "."
}
}
@@ -102,7 +64,7 @@
{
"label": "run-seatservice",
"type": "shell",
- "command": "./.vscode/scripts/run-seatservice.sh ${input:middleware} --task",
+ "command": "./.vscode/scripts/run-seatservice.sh --task",
"group": "none",
"presentation": {
"reveal": "always",
@@ -120,7 +82,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "connected to data broker.",
"endsPattern": "."
}
}
@@ -128,7 +90,7 @@
{
"label": "run-hvacservice",
"type": "shell",
- "command": "./.vscode/scripts/run-hvacservice.sh ${input:middleware} --task",
+ "command": "./.vscode/scripts/run-hvacservice.sh --task",
"group": "none",
"presentation": {
"reveal": "always",
@@ -146,7 +108,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "datapoints are registered.",
"endsPattern": "."
}
}
@@ -154,14 +116,13 @@
{
"label": "run-hvacservice (Runtime)",
"type": "shell",
- "command": "./.vscode/scripts/run-hvacservice.sh ${input:middleware} --task",
+ "command": "./.vscode/scripts/run-hvacservice.sh --task",
"group": "none",
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"dependsOn": [
- "ensure-dapr",
"run-mosquitto",
"run-vehicledatabroker",
"run-feedercan (DogMode)"
@@ -179,7 +140,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "datapoints are registered.",
"endsPattern": "."
}
}
@@ -187,7 +148,7 @@
{
"label": "run-feedercan",
"type": "shell",
- "command": "./.vscode/scripts/run-feedercan.sh ${input:middleware} --task",
+ "command": "./.vscode/scripts/run-feedercan.sh --task",
"group": "none",
"presentation": {
"reveal": "always",
@@ -205,7 +166,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "Connected to data broker",
"endsPattern": "."
}
}
@@ -213,7 +174,7 @@
{
"label": "run-feedercan (DogMode)",
"type": "shell",
- "command": "./.vscode/scripts/run-feedercan.sh ${input:middleware} DOGMODE --task",
+ "command": "./.vscode/scripts/run-feedercan.sh DOGMODE --task",
"group": "none",
"presentation": {
"reveal": "always",
@@ -231,7 +192,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Dapr logs will appear here.",
+ "beginsPattern": "Connected to data broker",
"endsPattern": "."
}
}
@@ -239,7 +200,6 @@
{
"label": "Start VehicleApp runtime",
"dependsOn": [
- "ensure-dapr",
"run-mosquitto",
"run-vehicledatabroker",
"run-seatservice",
@@ -249,17 +209,9 @@
"problemMatcher": []
},
{
- "label": "SeatAdjuster (Dapr run)",
+ "label": "Run SeatAdjuster example",
"type": "shell",
- "command": [
- "dapr run",
- "--app-id seatadjuster",
- "--app-protocol grpc",
- "--app-port 50008",
- "--config ./.dapr/config.yaml",
- "--resources-path ./.dapr/components",
- "python3 ./examples/seat-adjuster/src/main.py"
- ],
+ "command": ["python3 ./examples/seat-adjuster/src/main.py"],
"group": "none",
"isBackground": true,
"problemMatcher": {
@@ -273,23 +225,20 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Both Dapr and your app logs will appear here.",
+ "beginsPattern": "Starting seat adjuster app...",
"endsPattern": "."
}
}
},
{
- "label": "DogMode (Dapr run)",
+ "label": "Run DogMode example",
"type": "shell",
- "command": [
- "dapr run",
- "--app-id dogmode",
- "--app-protocol grpc",
- "--app-port 50008",
- "--config ./.dapr/config.yaml",
- "--resources-path ./.dapr/components",
- "python3 ./examples/dog-mode/src/main.py"
- ],
+ "command": ["python3 ./examples/dog-mode/src/main.py"],
+ "options": {
+ "env": {
+ "SDV_HVACSERVICE_ADDRESS": "grpc://127.0.0.1:50052"
+ }
+ },
"group": "none",
"isBackground": true,
"problemMatcher": {
@@ -303,7 +252,7 @@
],
"background": {
"activeOnStart": true,
- "beginsPattern": "^You're up and running! Both Dapr and your app logs will appear here.",
+ "beginsPattern": "VehicleApp Started ...",
"endsPattern": "."
}
}
@@ -326,16 +275,5 @@
"isBackground": false,
"problemMatcher": []
}
- ],
- "inputs": [
- {
- "description": "Options for selecting the type middleware",
- "id": "middleware",
- "type": "pickString",
- "options": [
- "DAPR",
- "NATIVE"
- ],
- }
]
}
diff --git a/NOTICE-3RD-PARTY-CONTENT.md b/NOTICE-3RD-PARTY-CONTENT.md
index 4a48f7f6..29d4e29e 100644
--- a/NOTICE-3RD-PARTY-CONTENT.md
+++ b/NOTICE-3RD-PARTY-CONTENT.md
@@ -16,7 +16,6 @@
|cloudevents|1.10.1|Apache 2.0|
|colorama|0.4.6|BSD|
|coverage|7.4.1|Apache 2.0|
-|dapr|1.10.0|Apache 2.0|
|Deprecated|1.2.14|MIT|
|deprecation|2.1.0|Apache 2.0|
|distlib|0.3.8|Python Software Foundation License|
@@ -53,7 +52,6 @@
|pytest|7.4.4|MIT|
|pytest-asyncio|0.23.4|Apache 2.0|
|pytest-cov|4.1.0|MIT|
-|python-dateutil|2.8.2|Apache 2.0
BSD|
|pytz|2024.1|MIT|
|PyYAML|6.0.1|MIT|
|setuptools|58.1.0|MIT|
diff --git a/NOTICE.md b/NOTICE.md
index 57b5e3b1..a2ae1c93 100644
--- a/NOTICE.md
+++ b/NOTICE.md
@@ -14,19 +14,13 @@ SPDX-License-Identifier: Apache-2.0
| Software | License |
| :------------------ | :--------------------------------------------------------------------------------------------------------------- |
-| Dapr | https://github.com/dapr/dapr/blob/master/LICENSE |
| Python | https://docs.python.org/3/license.html |
-| Helm | https://github.com/helm/helm/blob/main/LICENSE |
-| K3d | https://github.com/rancher/k3d/blob/main/LICENSE |
-| Kubectl | https://github.com/kubernetes/kubectl/blob/master/LICENSE |
-| K9S | https://github.com/derailed/k9s/blob/master/LICENSE |
-| Redis | https://redis.com/legal/licenses/ |
| Mosquitto | https://github.com/eclipse/mosquitto/blob/master/LICENSE.txt |
### Development
| Software | License |
| :------: | :------------------------------------------------------------------: |
-| GRPC | https://github.com/grpc/grpc/blob/master/LICENSE |
+| GRPC | https://github.com/grpc/grpc/blob/master/LICENSE |
| Pre-Commit | https://github.com/pre-commit/pre-commit/blob/main/LICENSE |
| Mypy | https://github.com/python/mypy/blob/master/LICENSE |
| Ruff | https://raw.githubusercontent.com/astral-sh/ruff/main/LICENSE |
diff --git a/README.md b/README.md
index 55888cae..c8926b80 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,6 @@ This includes the following packages:
* [velocitas_sdk.model](./velocitas_sdk/model.py) - Vehicle Model ontology
* [velocitas_sdk.config](./velocitas_sdk/config.py) - Vehicle App configuration
* [velocitas_sdk.base](./velocitas_sdk/base.py) - Base classes for middleware abstraction
-* [velocitas_sdk.dapr](./velocitas_sdk/dapr) - Dapr middleware integration
* [velocitas_sdk.native](./velocitas_sdk/native) - Native middleware definition
* [velocitas_sdk.vdb](./velocitas_sdk/vdb) - Vehicle Data Broker integration
* [velocitas_sdk.test](./velocitas_sdk/test) - Integration test support
@@ -58,7 +57,7 @@ All examples (except the Seat Adjuster) can be run via
cd examples
./run-app.sh -a
```
-By default the examples are started using the Dapr middleware. If specifying the `-n` flag they are started with native middleware, instead.
+By default the examples are started using the native middleware. Dapr middleware support was recently removed.
## Contribution
- [GitHub Issues](https://github.com/eclipse-velocitas/vehicle-app-python-sdk/issues)
diff --git a/examples/dog-mode/README.md b/examples/dog-mode/README.md
index 6651c492..9673c8cd 100644
--- a/examples/dog-mode/README.md
+++ b/examples/dog-mode/README.md
@@ -23,18 +23,7 @@ In order to launch the Heating, Ventilation, and Air Conditioning (HVAC) Service
* Run the dog mode sample app
-Please use the script below to launch the dog mode sample app.
-
-```bash
- dapr run \
- --app-id dogmode \
- --app-protocol grpc \
- --app-port 50008 \
- --config ../.dapr/config.yaml \
- --resources-path ../.dapr/components python3 dog-mode/src/main.py
-```
-
-Alternative, run the Visual Studio Code task `"DogMode (Dapr run)"` or use the script [run-app.sh](./../run-app.sh) as below:
+Use the Visual Studio Code task `"Run DogMode example"` or use the script [run-app.sh](./../run-app.sh) as below:
```bash
./run-app.sh -a dog-mode
```
diff --git a/examples/dog-mode/src/main.py b/examples/dog-mode/src/main.py
index 26c1bc26..a68ddefe 100644
--- a/examples/dog-mode/src/main.py
+++ b/examples/dog-mode/src/main.py
@@ -17,7 +17,6 @@
import asyncio
import json
import logging
-import os
import signal
from apscheduler.schedulers.asyncio import AsyncIOScheduler
@@ -27,8 +26,6 @@
from velocitas_sdk.vdb.subscriptions import DataPointReply
from velocitas_sdk.vehicle_app import VehicleApp, subscribe_data_points
-os.environ["HVACSERVICE_DAPR_APP_ID"] = "hvacservice"
-
logging.basicConfig(format=get_default_log_format(), datefmt=get_default_date_format())
logging.getLogger().setLevel("INFO")
logger = logging.getLogger(__name__)
diff --git a/examples/dynamic-rule/README.md b/examples/dynamic-rule/README.md
index 9eed64b7..75f9046d 100644
--- a/examples/dynamic-rule/README.md
+++ b/examples/dynamic-rule/README.md
@@ -6,14 +6,6 @@
```bash
cd examples/dynamic-rule/src
-# with dapr enabled
-dapr run --app-id speedlimitwarner --app-protocol grpc --app-port 50008 --config ../../.dapr/config.yaml --resources-path ../../.dapr/components -- python3 main.py -e
-```
-
-```bash
-cd examples/dynamic-rule/src
-
-# without dapr enabled
python3 main.py
```
@@ -21,4 +13,3 @@ python3 main.py
| Flag | Description | Usage |
|---------|-------------|-------|
| -l or --limit | Pass speed limit dynamically (defaults to 130) | python3 main.py -l 120
python3 main.py --limit 120
-|-e or --enable-dapr | Pass flag to enable dapr | python3 main.py -e
python3 main.py --enable-dapr
diff --git a/examples/dynamic-rule/src/main.py b/examples/dynamic-rule/src/main.py
index 3c692393..53ba31ea 100644
--- a/examples/dynamic-rule/src/main.py
+++ b/examples/dynamic-rule/src/main.py
@@ -78,12 +78,8 @@ async def main():
"""Main function"""
logging.basicConfig()
args = parser.parse_args()
- if not args.enable_dapr:
- logger.debug("Init native middleware")
- config._config = Config(MiddlewareType.NATIVE)
- else:
- logger.debug("Init dapr middleware")
- config._config = Config(MiddlewareType.DAPR)
+ logger.debug("Init native middleware")
+ config._config = Config(MiddlewareType.NATIVE)
print("Starting speed limit warner...", flush=True)
@@ -93,7 +89,6 @@ async def main():
parser = argparse.ArgumentParser()
parser.add_argument("-l", "--limit", help="Speed limit", default=130.0)
-parser.add_argument("-e", "--enable-dapr", help="Enable dapr", action="store_true")
LOOP = asyncio.get_event_loop()
LOOP.add_signal_handler(signal.SIGTERM, LOOP.stop)
diff --git a/examples/run-app.sh b/examples/run-app.sh
index 361522d7..4609eed6 100755
--- a/examples/run-app.sh
+++ b/examples/run-app.sh
@@ -22,27 +22,22 @@ Help()
# Display Help
echo "Simple script that run the example applications."
echo
- echo "Syntax: ./run-app.sh -a APP_NAME [-d|-n] [-p APP_PORT=50008]"
+ echo "Syntax: ./run-app.sh -a APP_NAME [-n]"
echo "options:"
echo "-a Option to set the application name from the list of examples directory, the name must match the directory name."
- echo "-d Run with Dapr middleware (default)."
- echo "-n Run with native middleware."
- echo "-p Option to set the application's gRPC port. Default is 50008"
+ echo "-n Run with native middleware (default)."
echo "-h/--help Help."
echo
}
ROOT_DIRECTORY=$( realpath "$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/.." )
# Get App attributes (Name and Port Number)
-APP_PORT=50008
-export SDV_MIDDLEWARE_TYPE=dapr
+export SDV_MIDDLEWARE_TYPE=native
while getopts a:dnp:h flag
do
case "${flag}" in
a) APP_NAME=${OPTARG};;
- d) export SDV_MIDDLEWARE_TYPE=dapr;;
n) export SDV_MIDDLEWARE_TYPE=native;;
- p) APP_PORT=${OPTARG};;
h) Help
exit;;
esac
@@ -54,17 +49,7 @@ if [ ! -d "$APP_NAME" ]; then
exit 0;
fi
-if [ $SDV_MIDDLEWARE_TYPE == "dapr" ]; then
- echo "Run with Dapr ...!"
- DAPR_APP_ID="${APP_NAME//[.,\-,_,' ']/}"
- dapr run \
- --app-id $DAPR_APP_ID \
- --app-protocol grpc \
- --app-port $APP_PORT \
- --config $ROOT_DIRECTORY/.dapr/config.yaml \
- --resources-path $ROOT_DIRECTORY/.dapr/components \
- -- python3 $APP_NAME/src/main.py
-elif [ $SDV_MIDDLEWARE_TYPE == "native" ]; then
+if [ $SDV_MIDDLEWARE_TYPE == "native" ]; then
echo "Run native ...!"
export SDV_MQTT_ADDRESS="mqtt://localhost:1883"
export SDV_VEHICLEDATABROKER_ADDRESS="grpc://localhost:55555"
diff --git a/examples/seat-adjuster/Dockerfile b/examples/seat-adjuster/Dockerfile
index be0b5f1b..cd064ba2 100644
--- a/examples/seat-adjuster/Dockerfile
+++ b/examples/seat-adjuster/Dockerfile
@@ -15,18 +15,14 @@
# syntax=docker/dockerfile:1.2
# Build stage, to create the executable
-FROM --platform=$TARGETPLATFORM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.2 as builder
+FROM --platform=$TARGETPLATFORM ghcr.io/eclipse-velocitas/devcontainer-base-images/python:v0.3 as builder
ARG TARGETARCH
RUN apt-get update && apt-get install -y python3-dev
-COPY ./.velocitas.json /workspace/.velocitas_org.json
+COPY ./.velocitas.json /workspace/.velocitas.json
COPY ./app /workspace/app
-# FIXME: For build tooling we only need "devenv-devcontainer-setup", we should be able to
-# filter this without manual jq intervention...
-RUN cat ./workspace/.velocitas_org.json | jq 'del(.packages[] | select(.name|test(".*devenv-devcontainer-setup.*")|not))' > ./workspace/.velocitas.json
-
# Remove this installation for Arm64 once staticx has a prebuilt wheel for Arm64
RUN /bin/bash -c 'set -ex && \
ARCH=`uname -m` && \
@@ -44,7 +40,7 @@ RUN pip3 install --no-cache-dir pyinstaller==5.9.0 \
WORKDIR /workspace
-RUN velocitas init
+RUN velocitas init -v
WORKDIR /workspace/app
diff --git a/examples/seat-adjuster/README.md b/examples/seat-adjuster/README.md
index c8cd8387..3f2dc941 100644
--- a/examples/seat-adjuster/README.md
+++ b/examples/seat-adjuster/README.md
@@ -13,20 +13,20 @@ It is possible to import and run this example from your app development reposito
:warning: Make sure you have commited or stash all your possible changes within the `app` folder, because the files of that folder will be overwritten by the files of this example.
-2. Running this example with Dapr middleware
+2. Running this example with default middleware
Use the VS Code tasks `Local Runtime - Up` and `Local Runtime - Run VehicleApp` to start the necessary runtime components and this app itself.
- Alternatively, the app can also be deployed in a k3d runtime - use task `K3D Runtime - Deploy VehicleApp`.
+ Alternatively, the app can also be deployed in a [Eclipse Kanto](https://eclipse.dev/kanto) runtime - use task `Kanto Runtime - Deploy VehicleApp`.
-## Executing with "native" middleware (without Dapr runtime)
+## Executing with "native" middleware
-If you like to run this example without using Dapr as middleware, you may need to provide some environment variables to the seat-adjuster process, which define the middleware type being _native_ and where to find the required runtime components:
+If you like to run this example using services located at other addresses than the pre-configured default, you need to provide the following environment variables:
| Variable name | Default value | Description
|---------------------------------|----------------------------|-------------
-| `SDV_MIDDLEWARE_TYPE` | `"dapr"` | Defines the middleware type -> set to `"native"`
+| `SDV_MIDDLEWARE_TYPE` | `"native"` | Defines the middleware type
| `SDV_MQTT_ADDRESS` | `"mqtt://localhost:1883"` | Address (and port) of the MQTT broker
| `SDV_VEHICLEDATABROKER_ADDRESS` | `"grpc://localhost:55555"` | Address (and port) of the KUKSA Data Broker
diff --git a/examples/seat-adjuster/requirements-velocitas.txt b/examples/seat-adjuster/requirements-velocitas.txt
index e5036b53..096499dd 100644
--- a/examples/seat-adjuster/requirements-velocitas.txt
+++ b/examples/seat-adjuster/requirements-velocitas.txt
@@ -1 +1 @@
-velocitas-sdk==0.13.1
+velocitas-sdk==0.14.0
diff --git a/examples/seat-adjuster/requirements.in b/examples/seat-adjuster/requirements.in
index 4ac3a963..bb691a8d 100644
--- a/examples/seat-adjuster/requirements.in
+++ b/examples/seat-adjuster/requirements.in
@@ -14,7 +14,6 @@
grpcio==1.59.0
protobuf==4.24.4
-dapr==1.11.0
cloudevents==1.10.0
aiohttp==3.9.3
packaging==23.0
diff --git a/examples/seat-adjuster/requirements.txt b/examples/seat-adjuster/requirements.txt
index 2bf5ec34..e1c10490 100644
--- a/examples/seat-adjuster/requirements.txt
+++ b/examples/seat-adjuster/requirements.txt
@@ -5,9 +5,7 @@
# pip-compile
#
aiohttp==3.9.3
- # via
- # -r requirements.in
- # dapr
+ # via -r requirements.in
aiosignal==1.3.1
# via aiohttp
async-timeout==4.0.3
@@ -16,8 +14,6 @@ attrs==23.1.0
# via aiohttp
cloudevents==1.10.0
# via -r requirements.in
-dapr==1.11.0
- # via -r requirements.in
deprecation==2.1.0
# via cloudevents
frozenlist==1.4.0
@@ -25,9 +21,7 @@ frozenlist==1.4.0
# aiohttp
# aiosignal
grpcio==1.59.0
- # via
- # -r requirements.in
- # dapr
+ # via -r requirements.in
idna==3.4
# via yarl
multidict==6.0.4
@@ -39,14 +33,6 @@ packaging==23.0
# -r requirements.in
# deprecation
protobuf==4.24.4
- # via
- # -r requirements.in
- # dapr
-python-dateutil==2.8.2
- # via dapr
-six==1.16.0
- # via python-dateutil
-typing-extensions==4.8.0
- # via dapr
+ # via -r requirements.in
yarl==1.9.2
# via aiohttp
diff --git a/prerequisite_settings.json b/prerequisite_settings.json
index 31b82d33..152ed8ba 100644
--- a/prerequisite_settings.json
+++ b/prerequisite_settings.json
@@ -21,13 +21,5 @@
},
"python": {
"version": "3.10"
- },
- "dapr": {
- "cli": {
- "version": "1.10.0"
- },
- "runtime": {
- "version": "1.10.3"
- }
}
}
diff --git a/requirements.txt b/requirements.txt
index d2eba1cd..67a0530e 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,9 +5,7 @@
# pip-compile --extra=dev
#
aiohttp==3.9.3
- # via
- # dapr
- # velocitas_sdk (setup.py)
+ # via velocitas_sdk (setup.py)
aiosignal==1.3.1
# via aiohttp
apscheduler==3.10.4
@@ -34,8 +32,6 @@ coverage[toml]==7.4.1
# via
# coverage
# pytest-cov
-dapr==1.10.0
- # via velocitas_sdk (setup.py)
deprecated==1.2.14
# via
# opentelemetry-api
@@ -58,7 +54,6 @@ grpc-stubs==1.53.0.5
# via velocitas_sdk (setup.py)
grpcio==1.59.0
# via
- # dapr
# grpc-stubs
# grpcio-tools
# velocitas_sdk (setup.py)
@@ -126,7 +121,6 @@ pre-commit==3.6.0
# via velocitas_sdk (setup.py)
protobuf==4.21.12
# via
- # dapr
# grpcio-tools
# mypy-protobuf
# velocitas_sdk (setup.py)
@@ -143,8 +137,6 @@ pytest-asyncio==0.23.4
# via velocitas_sdk (setup.py)
pytest-cov==4.1.0
# via velocitas_sdk (setup.py)
-python-dateutil==2.8.2
- # via dapr
pytz==2024.1
# via apscheduler
pyyaml==6.0.1
@@ -152,7 +144,6 @@ pyyaml==6.0.1
six==1.16.0
# via
# apscheduler
- # python-dateutil
tomli==2.0.1
# via
# build
@@ -173,7 +164,6 @@ types-protobuf==4.24.0.20240129
# via mypy-protobuf
typing-extensions==4.7.1
# via
- # dapr
# mypy
# opentelemetry-sdk
tzlocal==5.2
diff --git a/setup.cfg b/setup.cfg
index b32c7967..8169dea2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -12,10 +12,6 @@ namespace_packages = True
[mypy-velocitas_sdk.proto.*]
ignore_errors = True
-[mypy-velocitas_sdk.dapr.*]
-ignore_errors = True
-
-
[tool:pytest]
asyncio_mode = auto
norecursedirs = examples/* build/* dist/*
diff --git a/setup.py b/setup.py
index 78412b6b..196674c1 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,6 @@
"grpcio>=1.59.0",
"protobuf>=3.19.4",
"cloudevents>=1.10.0",
- "dapr",
"aiohttp==3.9.3",
"paho-mqtt>=1.6.1,<2",
"opentelemetry-distro<=0.36b0",
@@ -34,7 +33,6 @@
##########################################
"protobuf",
"grpcio>=1.59.0",
- "dapr",
"grpcio-tools",
"grpc-stubs",
"mypy-protobuf",
@@ -63,7 +61,7 @@
setup(
name="velocitas_sdk",
- version="0.13.1",
+ version="0.14.0",
description="A Python SDK for Vehicle app",
long_description=long_description,
long_description_content_type="text/markdown",
@@ -71,7 +69,6 @@
packages=[
"velocitas_sdk",
"velocitas_sdk.util",
- "velocitas_sdk.dapr",
"velocitas_sdk.native",
"velocitas_sdk.proto",
"velocitas_sdk.vdb",
diff --git a/tests/integration/databroker_test.py b/tests/integration/databroker_test.py
index c8a0e3a2..fa85db0a 100755
--- a/tests/integration/databroker_test.py
+++ b/tests/integration/databroker_test.py
@@ -14,12 +14,11 @@
# ruff: noqa: E402
-""" Tests for methods in VehicleDataBrokerClient """
+"""Tests for methods in VehicleDataBrokerClient"""
import os
os.environ["SDV_MIDDLEWARE_TYPE"] = "native"
-from unittest import mock
import grpc
import pytest
@@ -130,7 +129,6 @@ async def test_for_subscribe_join_where():
@pytest.mark.asyncio
async def test_for_fluent_get():
- # with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
response = await vehicle.Speed.get()
@@ -139,8 +137,7 @@ async def test_for_fluent_get():
@pytest.mark.asyncio
async def test_for_fluent_unsubscribe():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
rule = await vehicle.Speed.subscribe(callback_fluent)
task = await rule.unsubscribe()
@@ -149,8 +146,7 @@ async def test_for_fluent_unsubscribe():
@pytest.mark.asyncio
async def test_for_fluent_resubscribe():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
task = None
try:
@@ -165,8 +161,7 @@ async def test_for_fluent_resubscribe():
@pytest.mark.asyncio
async def test_for_fluent_subscribe():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
try:
await vehicle.Speed.subscribe(callback_fluent)
@@ -181,8 +176,7 @@ def callback_fluent(data):
@pytest.mark.asyncio
async def test_for_fluent_join():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
await change_datapoint(vehicle.ThisIsAFloat.get_path(), 50.0)
try:
@@ -195,8 +189,7 @@ async def test_for_fluent_join():
@pytest.mark.asyncio
async def test_for_fluent_where():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
try:
await vehicle.Speed.where("Vehicle.Speed < 60.0").subscribe(callback_fluent)
@@ -207,7 +200,6 @@ async def test_for_fluent_where():
@pytest.mark.asyncio
async def test_for_fluent_where_join():
- # with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
await change_datapoint(vehicle.ThisIsAFloat.get_path(), 50.0)
@@ -225,8 +217,7 @@ async def test_for_fluent_where_join():
@pytest.mark.asyncio
async def test_for_subscribe_exception():
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- vehicle = get_vehicle_instance()
+ vehicle = get_vehicle_instance()
await change_datapoint(vehicle.Speed.get_path(), 0.0)
try:
await vehicle.Speed.where("GIVE ERROR").subscribe(callback_fluent)
diff --git a/tests/integration/pubsub_test.py b/tests/integration/pubsub_test.py
index cd39fffd..bcdaa5c7 100644
--- a/tests/integration/pubsub_test.py
+++ b/tests/integration/pubsub_test.py
@@ -14,11 +14,11 @@
# ruff: noqa: E402
-""" Tests for methods in VehicleDataBrokerClient """
+"""Tests for methods in VehicleDataBrokerClient"""
import os
-os.environ["SDV_MIDDLEWARE_TYPE"] = "dapr"
+os.environ["SDV_MIDDLEWARE_TYPE"] = "native"
import pytest
diff --git a/tests/unit/client_test.py b/tests/unit/client_test.py
index ab3b28b3..8b484a86 100644
--- a/tests/unit/client_test.py
+++ b/tests/unit/client_test.py
@@ -13,7 +13,7 @@
# SPDX-License-Identifier: Apache-2.0
-""" Tests for methods in VehicleClient """
+"""Tests for methods in VehicleClient"""
import os
import sys
@@ -38,7 +38,7 @@
@pytest.fixture(autouse=True)
def reset():
- config._config = Config("dapr")
+ config._config = Config("native")
config.middleware = config._config.middleware
diff --git a/tests/unit/dapr_locator_test.py b/tests/unit/dapr_locator_test.py
deleted file mode 100644
index 7a1314c6..00000000
--- a/tests/unit/dapr_locator_test.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-""" Tests for methods in locator """
-
-
-import os
-from unittest import mock
-
-import pytest
-
-from velocitas_sdk import config
-from velocitas_sdk.config import Config
-from velocitas_sdk.dapr.middleware import DaprMiddleware
-from velocitas_sdk.model import Service, VehicleDataBrokerClient
-
-
-@pytest.fixture(autouse=True)
-def reset():
- VehicleDataBrokerClient._instance = None
- config._config = Config("dapr")
- config.middleware = DaprMiddleware()
-
-
-@pytest.mark.asyncio
-async def test_for_get_metadata():
- service = CustomService()
- response = service.metadata
- assert response == (("dapr-app-id", str(service.name).lower()),)
-
-
-@pytest.mark.asyncio
-async def test_for_get_location():
- service = CustomService()
- _address = service.address
- assert _address == "localhost:51001"
- with mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "55555"}):
- service = CustomService()
- response = service.address
- assert response == "localhost:55555"
-
-
-class CustomService(Service):
- "Custom model"
-
- def __init__(self):
- super().__init__()
diff --git a/tests/unit/dapr_pusbub_client_test.py b/tests/unit/dapr_pusbub_client_test.py
deleted file mode 100644
index 978c5387..00000000
--- a/tests/unit/dapr_pusbub_client_test.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-""" Tests for methods in PubSubClient """
-import os
-import sys
-from unittest import mock
-
-import pytest
-
-from velocitas_sdk import config
-from velocitas_sdk.base import Middleware
-from velocitas_sdk.config import Config
-from velocitas_sdk.dapr.pubsub import DaprClient
-
-sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))
-
-
-@pytest.fixture(autouse=True)
-def reset():
- config._config = Config("dapr")
- config.middleware = config._config.middleware
-
-
-@pytest.mark.asyncio
-async def test_for_subscribe_topic():
- middleware = get_middleware_instance()
- with mock.patch.object(
- middleware.pubsub_client,
- "subscribe_topic",
- new_callable=mock.AsyncMock,
- ) as mocked_client:
- await middleware.pubsub_client.subscribe_topic("/test/dapr", None)
- assert isinstance(middleware.pubsub_client, DaprClient)
- mocked_client.assert_called_once_with("/test/dapr", None)
-
-
-@pytest.mark.asyncio
-async def test_for_get_publish_event():
- middleware = get_middleware_instance()
- with mock.patch.object(
- middleware.pubsub_client,
- "publish_event",
- new_callable=mock.AsyncMock,
- ) as mocked_client:
- await middleware.pubsub_client.publish_event("/test/dapr", "message")
- mocked_client.assert_called_once_with("/test/dapr", "message")
-
-
-def get_middleware_instance() -> Middleware:
- return config.middleware
diff --git a/tests/unit/vehicle_app_test.py b/tests/unit/vehicle_app_test.py
index b469bf83..3b86bb38 100644
--- a/tests/unit/vehicle_app_test.py
+++ b/tests/unit/vehicle_app_test.py
@@ -12,10 +12,9 @@
#
# SPDX-License-Identifier: Apache-2.0
-""" Tests for methods in VehicleClient """
+"""Tests for methods in VehicleClient"""
import inspect
-import os
from typing import Mapping, Text
from unittest import mock
@@ -72,7 +71,6 @@ def getattr(self):
assert "SELECT Vehicle.ADAS.CruiseControl.SpeedSet WHERE Vehicle.Speed > 0" in query
-@mock.patch.dict(os.environ, {"DAPR_GRPC_PORT": "50051"}, clear=True)
def get_vehicle_app_instance() -> VehicleApp:
vehicle_app = VehicleApp()
return vehicle_app
diff --git a/velocitas_sdk/base.py b/velocitas_sdk/base.py
index 8285f603..435a4e99 100644
--- a/velocitas_sdk/base.py
+++ b/velocitas_sdk/base.py
@@ -22,7 +22,6 @@ class MiddlewareType(str, Enum):
"""Enumerator for the supported Velocitas Middlewares."""
NATIVE = "native"
- DAPR = "dapr"
class ServiceLocator(ABC):
diff --git a/velocitas_sdk/config.py b/velocitas_sdk/config.py
index 5e5fc689..dca7d48f 100644
--- a/velocitas_sdk/config.py
+++ b/velocitas_sdk/config.py
@@ -15,7 +15,6 @@
import os
from velocitas_sdk.base import Middleware, MiddlewareType
-from velocitas_sdk.dapr.middleware import DaprMiddleware
from velocitas_sdk.native.middleware import NativeMiddleware
@@ -39,13 +38,11 @@ def __create_middleware(self, middleware_type: str) -> Middleware:
_middleware: Middleware
if middleware_type == MiddlewareType.NATIVE.value:
_middleware = NativeMiddleware()
- if middleware_type == MiddlewareType.DAPR.value:
- _middleware = DaprMiddleware()
return _middleware
-__middleware_type = os.getenv("SDV_MIDDLEWARE_TYPE", MiddlewareType.DAPR.value)
+__middleware_type = os.getenv("SDV_MIDDLEWARE_TYPE", MiddlewareType.NATIVE.value)
_config = Config(__middleware_type)
middleware = _config.middleware
diff --git a/velocitas_sdk/dapr/__init__.py b/velocitas_sdk/dapr/__init__.py
deleted file mode 100644
index 22999bbb..00000000
--- a/velocitas_sdk/dapr/__init__.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
diff --git a/velocitas_sdk/dapr/_servicier.py b/velocitas_sdk/dapr/_servicier.py
deleted file mode 100644
index 17beef96..00000000
--- a/velocitas_sdk/dapr/_servicier.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-import asyncio
-import logging
-from typing import Callable, Dict, List, Optional, Tuple
-
-import grpc
-from cloudevents.sdk.event import v1 # type: ignore
-from dapr.proto import appcallback_service_v1, appcallback_v1 # type: ignore
-from google.protobuf import empty_pb2
-
-logger = logging.getLogger(__name__)
-
-TopicSubscribeCallable = Callable[[object, v1.Event], None]
-
-DELIMITER = ":"
-
-
-class Rule:
- """A rule for a subscription."""
-
- def __init__(self, match: str, priority: int) -> None:
- self.match = match
- self.priority = priority
-
-
-class _RegisteredSubscription:
- def __init__(
- self,
- subscription: appcallback_v1.TopicSubscription,
- rules: List[Tuple[int, appcallback_v1.TopicRule]],
- ):
- self.subscription = subscription
- self.rules = rules
-
-
-class _CallbackServicer(appcallback_service_v1.AppCallbackServicer):
- def __init__(self):
- self._topic_map: Dict[str, TopicSubscribeCallable] = {}
-
- self._registered_topics_map: Dict[str, _RegisteredSubscription] = {}
- self._registered_topics: List[appcallback_v1.TopicSubscription] = []
- self._main_event_loop = asyncio.get_event_loop()
-
- def register_topic(
- self,
- pubsub_name: str,
- topic: str,
- callback: TopicSubscribeCallable,
- metadata: Optional[Dict[str, str]],
- rule: Optional[Rule] = None,
- ) -> None:
- """Registers topic subscription for pubsub."""
- logger.debug("Registering topic '%s'", topic)
- topic_key = pubsub_name + DELIMITER + topic
- pubsub_topic = topic_key + DELIMITER
- if rule is not None:
- path = getattr(callback, "__name__", rule.match)
- pubsub_topic = pubsub_topic + path
- if pubsub_topic in self._topic_map:
- raise ValueError(f"{topic} is already registered with {pubsub_name}")
- self._topic_map[pubsub_topic] = callback
-
- registered_topic = self._registered_topics_map.get(topic_key)
- sub: appcallback_v1.TopicSubscription = appcallback_v1.TopicSubscription()
- rules: List[Tuple[int, appcallback_v1.TopicRule]] = []
- if not registered_topic:
- sub = appcallback_v1.TopicSubscription(
- pubsub_name=pubsub_name,
- topic=topic,
- metadata=metadata,
- routes=appcallback_v1.TopicRoutes(),
- )
- registered_topic = _RegisteredSubscription(sub, rules)
- self._registered_topics_map[topic_key] = registered_topic
- self._registered_topics.append(sub)
-
- sub = registered_topic.subscription
- rules = registered_topic.rules
-
- if rule:
- path = getattr(callback, "__name__", rule.match)
- rules.append(
- (rule.priority, appcallback_v1.TopicRule(match=rule.match, path=path))
- )
- rules.sort(key=lambda x: x[0])
- topic_rules = [rule for id, rule in rules]
- del sub.routes.rules[:]
- sub.routes.rules.extend(topic_rules)
-
- def ListTopicSubscriptions(self, request, context):
- return appcallback_v1.ListTopicSubscriptionsResponse(
- subscriptions=self._registered_topics
- )
-
- def OnTopicEvent(self, request, context):
- pubsub_topic = (
- request.pubsub_name + DELIMITER + request.topic + DELIMITER + request.path
- )
- if pubsub_topic not in self._topic_map:
- context.set_code(grpc.StatusCode.UNIMPLEMENTED) # type: ignore
- logger.error(
- "topic %s is not implemented allowed topics are %s",
- request.topic,
- self._topic_map,
- )
- raise NotImplementedError(f"topic {request.topic} is not implemented!")
-
- method: TopicSubscribeCallable = self._topic_map[pubsub_topic]
- if asyncio.iscoroutinefunction(method):
- asyncio.run_coroutine_threadsafe(
- coro=method(request.data), # type: ignore
- loop=self._main_event_loop,
- )
- else:
- # This calls the method on the worker_thread rather than the main thread
- method(request.data) # type: ignore
-
- return empty_pb2.Empty()
diff --git a/velocitas_sdk/dapr/client.py b/velocitas_sdk/dapr/client.py
deleted file mode 100644
index 5a142835..00000000
--- a/velocitas_sdk/dapr/client.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-"""" dapr gateway"""
-
-import asyncio
-import logging
-import os
-import urllib.request
-from http import HTTPStatus
-from urllib.error import HTTPError
-
-import grpc
-from dapr.proto import api_service_v1, api_v1 # type: ignore
-
-from velocitas_sdk.dapr.locator import DAPR_PUB_SUB_NAME_VALUE
-
-logger = logging.getLogger(__name__)
-
-
-def publish_mqtt_event(topic: str, data: str) -> None:
- """Publishes an event to the specified MQTT topic over dapr pub/sub."""
- port = int(str(os.getenv("DAPR_GRPC_PORT")))
- address = f"localhost:{port}"
- channel = grpc.insecure_channel(address)
- dapr_stub = api_service_v1.DaprStub(channel)
- req = api_v1.PublishEventRequest(
- pubsub_name=DAPR_PUB_SUB_NAME_VALUE,
- topic=topic,
- data=bytes(data, "utf-8"),
- metadata={"rawPayload": "true"},
- )
- dapr_stub.PublishEvent(req)
- logger.debug(
- "Published an event data :%s to the specified MQTT topic: %s", data, topic
- )
-
-
-async def wait_for_sidecar() -> None:
- """Poll dapr sidecar health check endpoint until it returns 204 NO_CONTENT.
- GRPC proxy requests are only allowed after dapr sidecar is ready."""
-
- success = False
- while not success:
- port = os.getenv("DAPR_HTTP_PORT")
- if port is not None:
- target_port = int(str(os.getenv("DAPR_HTTP_PORT")))
- try:
- response = urllib.request.urlopen( # nosec
- f"http://localhost:{target_port}/v1.0/healthz"
- )
- response.read()
- success = response.status == HTTPStatus.NO_CONTENT
- logger.debug(
- "dapr: Health endpoint returned status code: %s", response.status
- )
- except HTTPError as error:
- if error.code == HTTPStatus.INTERNAL_SERVER_ERROR:
- logger.info("Waiting for dapr sidecar...")
- else:
- logger.error("Unexpected error from dapr sidecar: %d", error.code)
- await asyncio.sleep(0.1)
- except BaseException as error:
- logger.error("%s", str(error))
- await asyncio.sleep(0.1)
- else:
- await asyncio.sleep(0.1)
diff --git a/velocitas_sdk/dapr/locator.py b/velocitas_sdk/dapr/locator.py
deleted file mode 100644
index 3d350133..00000000
--- a/velocitas_sdk/dapr/locator.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-import os
-from typing import Optional
-
-from velocitas_sdk.base import ServiceLocator
-
-DAPR_APP_ID_KEY = "dapr-app-id"
-DAPR_APP_PORT_KEY = "dapr-app-port"
-DAPR_APP_PORT_VALUE = 50008
-
-DAPR_PUB_SUB_NAME_VALUE = "mqtt-pubsub"
-
-
-class DaprServiceLocator(ServiceLocator):
- """Middleware descriptor abstract base class."""
-
- def get_service_location(self, service_name: str) -> str:
- env_var = os.getenv("DAPR_GRPC_PORT")
- if env_var is None:
- port = 51001
- else:
- port = int(str(os.getenv("DAPR_GRPC_PORT")))
-
- address = f"grpc://localhost:{port}"
- return address
-
- def get_metadata(self, service_name: Optional[str] = None):
- if service_name is None:
- service_name = ""
-
- app_id = os.getenv(service_name.upper() + "_DAPR_APP_ID")
- if app_id is None:
- app_id = service_name.lower()
-
- return ((DAPR_APP_ID_KEY, str(app_id)),)
diff --git a/velocitas_sdk/dapr/middleware.py b/velocitas_sdk/dapr/middleware.py
deleted file mode 100644
index 9eb00d62..00000000
--- a/velocitas_sdk/dapr/middleware.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-from velocitas_sdk.base import Middleware, MiddlewareType
-from velocitas_sdk.dapr.client import wait_for_sidecar
-from velocitas_sdk.dapr.locator import DaprServiceLocator
-from velocitas_sdk.dapr.pubsub import DaprClient
-from velocitas_sdk.dapr.server import run_server
-
-
-class DaprMiddleware(Middleware):
- """Dapr middleware implementation."""
-
- def __init__(self) -> None:
- super().__init__()
- self.type = MiddlewareType.DAPR
- self.pubsub_client = DaprClient()
- self.service_locator = DaprServiceLocator()
-
- async def start(self):
- await run_server()
-
- async def wait_until_ready(self):
- await wait_for_sidecar()
-
- async def stop(self):
- pass
diff --git a/velocitas_sdk/dapr/pubsub.py b/velocitas_sdk/dapr/pubsub.py
deleted file mode 100644
index 1a76bdb7..00000000
--- a/velocitas_sdk/dapr/pubsub.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-from velocitas_sdk.base import PubSubClient
-from velocitas_sdk.dapr.client import publish_mqtt_event, wait_for_sidecar
-from velocitas_sdk.dapr.server import register_topic, run_server
-
-
-class DaprClient(PubSubClient):
- """This class is a wrapper for the on_message callback of the MQTT broker."""
-
- def __init__(self):
- """Nothing to do"""
-
- async def init(self):
- """Disabled, run_server is not only pubsub specfic for dapr."""
- await run_server()
-
- async def run(self):
- await wait_for_sidecar()
-
- async def subscribe_topic(self, topic: str, coro):
- register_topic(topic, coro)
-
- async def publish_event(self, topic: str, data: str):
- return publish_mqtt_event(topic, data)
diff --git a/velocitas_sdk/dapr/server.py b/velocitas_sdk/dapr/server.py
deleted file mode 100644
index 5bd42b9d..00000000
--- a/velocitas_sdk/dapr/server.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright (c) 2022-2024 Contributors to the Eclipse Foundation
-#
-# This program and the accompanying materials are made available under the
-# terms of the Apache License, Version 2.0 which is available at
-# https://www.apache.org/licenses/LICENSE-2.0.
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-#
-# SPDX-License-Identifier: Apache-2.0
-
-"""" dapr gateway"""
-
-from concurrent.futures import ThreadPoolExecutor
-from threading import Thread
-
-import grpc
-from dapr.proto import appcallback_service_v1 # type: ignore
-
-from velocitas_sdk.dapr._servicier import TopicSubscribeCallable, _CallbackServicer
-from velocitas_sdk.dapr.locator import DAPR_APP_PORT_VALUE, DAPR_PUB_SUB_NAME_VALUE
-
-
-class _DaprServer:
- def __init__(self):
- self._port = DAPR_APP_PORT_VALUE
- self._worker_thread = Thread(target=self._start_server_loop)
- self._worker_thread.daemon = True
- self._is_running = False
-
- def start(self):
- """Starts the server."""
- if self._is_running is False:
- self._worker_thread.start()
- self._is_running = True
-
- def _start_server_loop(self):
- server = grpc.server(ThreadPoolExecutor(max_workers=10))
- appcallback_service_v1.add_AppCallbackServicer_to_server(_servicer, server)
- server.add_insecure_port(f"[::]:{self._port}")
- server.start()
- server.wait_for_termination()
-
-
-_dapr_server = _DaprServer()
-
-
-async def run_server():
- _dapr_server.start()
-
-
-_servicer = _CallbackServicer()
-
-
-def register_topic(topic: str, callback: TopicSubscribeCallable) -> None:
- """Register a callback method as a MQTT topic subscriber over dapr pub/sub.
-
- Args:
- topic (str): MQTT topic name
- callback (TopicSubscribeCallable): method to be be called on incoming messages
- """
- _servicer.register_topic(
- DAPR_PUB_SUB_NAME_VALUE, topic, callback, metadata={"rawPayload": "true"}
- )