Skip to content

Commit

Permalink
Revert "[] Mqtt cpp and build improvements (#61)" (#62)
Browse files Browse the repository at this point in the history
This reverts commit 7569495.
  • Loading branch information
Pedrobc89 authored Jan 15, 2025
1 parent 7569495 commit 554ee71
Show file tree
Hide file tree
Showing 22 changed files with 717 additions and 1,166 deletions.
15 changes: 5 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ find_package(nanobind CONFIG REQUIRED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets
${CMAKE_CURRENT_SOURCE_DIR}/src/commons
${CMAKE_CURRENT_SOURCE_DIR}/src/distributed_algorithm_node
${CMAKE_CURRENT_SOURCE_DIR}/src/mqtt
)
${CMAKE_CURRENT_SOURCE_DIR}/src/distributed_algorithm_node)

file(GLOB_RECURSE headers
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/commons/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/distributed_algorithm_node/*.h
${CMAKE_CURRENT_SOURCE_DIR}/src/mqtt/*.h
)
${CMAKE_CURRENT_SOURCE_DIR}/src/distributed_algorithm_node/*.h)

nanobind_add_module(
${EXTENSION_NAME}
${EXTENSION_NAME}
# Target the stable ABI for Python 3.12+, which reduces
# the number of binary wheels that must be built. This
# does nothing on older Python versions
Expand All @@ -89,9 +85,8 @@ target_link_libraries(
${EXTENSION_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libinternal.a
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libexternal.a
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libpaho-mqtt3a.a
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libpaho-mqtt3c.a
${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libpaho-mqttpp3.a
# ${CMAKE_CURRENT_SOURCE_DIR}/bazel_assets/libenvoy_api.a

)

# Install directive for scikit-build-core
Expand Down
Binary file removed deps/bazel-7.4.1-installer-linux-x86_64.sh
Binary file not shown.
Binary file removed deps/paho.mqtt.c.tar.gz
Binary file not shown.
Binary file removed deps/paho.mqtt.cpp.tar.gz
Binary file not shown.
56 changes: 26 additions & 30 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,46 @@ ARG TMP_DIR="/tmp"

ARG DAS_NODE_DIR="${BASE_DIR}/hyperon_das_node"
ARG DATA_DIR="${BASE_DIR}/data"
ARG GRPC_DIR="${BASE_DIR}/grpc"
ARG PROTO_DIR="${BASE_DIR}/proto"
ARG BAZEL_DIR="${BASE_DIR}/bazel"
ARG THIRDPARTY="${BASE_DIR}/3rd-party"

ENV CPLUS_INCLUDE_PATH="/opt/3rd-party/mbedcrypto/include/"
ENV CC=/usr/bin/gcc

RUN mkdir -p ${DAS_NODE_DIR} ${DATA_DIR} \
${BAZEL_DIR} ${PROTO_DIR} ${THIRDPARTY}
RUN mkdir -p ${DAS_NODE_DIR} && mkdir -p ${DATA_DIR} && mkdir -p ${GRPC_DIR}\
&& mkdir -p ${BAZEL_DIR} && mkdir -p ${PROTO_DIR} && mkdir -p ${THIRDPARTY}

VOLUME ${DAS_NODE_DIR}

RUN apt-get update &&\
apt-get install -y git build-essential autoconf libtool pkg-config curl gcc g++ \
protobuf-compiler libmbedcrypto7 python3 pip cmake make python3 pip libssl-dev unzip
apt-get install -y git build-essential autoconf libtool pkg-config curl gcc \
protobuf-compiler libmbedcrypto7 python3 pip cmake python3 pip

RUN pip install --no-cache-dir nanobind==2.1.0

WORKDIR ${THIRDPARTY}
COPY assets/3rd-party.tgz .
RUN --mount=type=cache,target=/root/.cache/bazel \
tar xzvf 3rd-party.tgz &&\
rm -f 3rd-party.tgz &&\
mkdir -p ${DAS_NODE_DIR}/src/3rd-party &&\
ln -s ${THIRDPARTY} ${DAS_NODE_DIR}/src/3rd-party

WORKDIR ${TMP_DIR}

COPY deps/* .

RUN chmod +x bazel-7.4.1-installer-linux-x86_64.sh \
&& ./bazel-7.4.1-installer-linux-x86_64.sh

RUN tar -xzf paho.mqtt.c.tar.gz \
&& tar -xzf paho.mqtt.cpp.tar.gz
RUN cd ${GRPC_DIR} &&\
git clone https://github.com/grpc/grpc &&\
cd grpc &&\
git submodule update --init

COPY assets/3rd-party.tgz ${THIRDPARTY}
RUN --mount=type=cache,target=/root/.cache/bazel cd ${THIRDPARTY} &&\
tar xzvf 3rd-party.tgz &&\
rm -f 3rd-party.tgz &&\
mkdir -p ${DAS_NODE_DIR}}/src/3rd-party &&\
ln -s ${THIRDPARTY} ${DAS_NODE_DIR}}/src/3rd-party &&\
mv bazelisk ${BAZEL_DIR}

ENV CPLUS_INCLUDE_PATH="/opt/3rd-party/mbedcrypto/include/"

WORKDIR ${TMP_DIR}/paho.mqtt.c-1.3.9
RUN cmake -Bbuild -H. -DPAHO_ENABLE_TESTING=OFF -DPAHO_WITH_SSL=OFF -DPAHO_HIGH_PERFORMANCE=ON -DPAHO_BUILD_STATIC=ON \
&& cmake --build build/ --target install
ENV CC=/usr/bin/gcc
RUN ln -s ${BAZEL_DIR}/bazelisk /usr/bin/bazel
RUN cd ${GRPC_DIR}/grpc &&\
${BAZEL_DIR}/bazelisk build :all

WORKDIR ${TMP_DIR}/paho.mqtt.cpp-1.2.0
RUN cmake -Bbuild -H. -DPAHO_WITH_MQTT_C=ON -DPAHO_BUILD_EXAMPLES=OFF -DPAHO_WITH_SSL=FALSE -DPAHO_BUILD_STATIC=ON \
&& cmake --build build/ --target install
ADD https://raw.githubusercontent.com/singnet/das-query-engine/master/proto/common.proto ${PROTO_DIR}
ADD https://raw.githubusercontent.com/singnet/das-query-engine/master/proto/echo.proto ${PROTO_DIR}

WORKDIR "${DAS_NODE_DIR}"

#COPY source code and relevant info
COPY . .
2 changes: 1 addition & 1 deletion docker/Dockerfile.wheel
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ENV PYTHON_EXECUTABLE=${PYTHON_PATH}/bin/python3.10
RUN ${PYTHON_EXECUTABLE} -m pip install wheel auditwheel

# Set the working directory
WORKDIR /opt/hyperon_das_node
WORKDIR /hyperon_das_node
2 changes: 1 addition & 1 deletion examples/simple_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, node_id: str, is_server: bool) -> None:
super().__init__(
node_id,
LeadershipBrokerType.SINGLE_MASTER_SERVER,
MessageBrokerType.MQTT,
MessageBrokerType.GRPC,
)

self.is_server = is_server
Expand Down
25 changes: 13 additions & 12 deletions scripts/container_tty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
CONTAINER_NAME="das-node-bash"

if [ -n "$1" ]; then
CMD="$1"
INTERACTIVE="-i"
CMD="$1"
INTERACTIVE="-i"
else
CMD="bash"
INTERACTIVE="-it"
CMD="bash"
INTERACTIVE="-it"
fi

docker run \
--rm \
--net="host" \
--name=$CONTAINER_NAME \
--volume .:/opt/hyperon_das_node \
--volume ./docker/volumes/bazel_cache:/root/.cache/bazel \
--volume /tmp:/tmp \
$INTERACTIVE das-node-builder \
bash -c "$CMD"
--net="host" \
--name=$CONTAINER_NAME \
--volume .:/opt/hyperon_das_node \
--volume /tmp:/tmp \
$INTERACTIVE das-node-builder \
bash -c "$CMD"

sleep 1
docker rm $CONTAINER_NAME >& /dev/null
9 changes: 3 additions & 6 deletions scripts/cpp_build_cmd.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/bin/bash

set -euo pipefail

echo "===================================================================================================="
output="../bazel_assets"
bazel build --jobs 16 --noenable_bzlmod //:hyperon_das_node
/opt/bazel/bazelisk build --jobs 16 --noenable_bzlmod //:hyperon_das_node

##### Workaround to build nanobind with CMake ######
# removes folder if exists
if [ -d "$output" ]; then
rm -rf $output
if [ -d "$output" ]; then
rm -rf $output
fi

# Recreates folders
Expand All @@ -29,7 +27,6 @@ cp -r bazel-src/external/com_github_grpc_grpc/include/grpc $output/
cp -r bazel-src/external/com_github_grpc_grpc/include/grpcpp/ $output/
cp -r bazel-src/external/com_google_absl/absl/ $output/
cp -r bazel-src/external/com_google_protobuf/src/google/ $output/
cp $(find /usr/local/lib -name "*paho-mqtt*.a") $output

# TODO: Once das-proto is updated, update atom_space_node to distributed_algorithm_node

Expand Down
1 change: 0 additions & 1 deletion scripts/wheeler_build_cmd.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

# This script is used to build a wheel for the current package.
set -euo pipefail

TMP_DEST_DIR="tmp_dist"
DEST_DIR="dist"
Expand Down
1 change: 0 additions & 1 deletion src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ cc_binary(
"//distributed_algorithm_node:distributed_algorithm_node_lib",
"//main:main_lib",
"//commons:commons_lib",
"//mqtt:mqtt_client_lib",
"@com_github_singnet_das_proto//:atom_space_node_cc_grpc",
# "@com_github_singnet_das_proto//:distributed_algorithm_node_cc_grpc",
"@com_github_grpc_grpc//:grpc++",
Expand Down
1 change: 0 additions & 1 deletion src/distributed_algorithm_node/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cc_library(
# "@com_github_singnet_das_proto//:distributed_algorithm_node_cc_grpc",
"@com_github_grpc_grpc//:grpc++",
"@com_github_grpc_grpc//:grpc++_reflection",
"//mqtt:mqtt_client_lib",
"//commons:commons_lib"
],
)
Loading

0 comments on commit 554ee71

Please sign in to comment.