Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Download Annoy Index file from Google Drive
run: |
pip install gdown
gdown --id 1gTXqQtP9JS92gAtPzhKgZpdIHSV_Lcnp -O ${{ github.workspace }}/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/models_index.ann
gdown --id 1TQvt1bSXares-I9l7Wki0Jge3oubRkOJ -O ${{ github.workspace }}/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/models_index.ann

- name: Compile and run tests
uses: eProsima/eProsima-CI/multiplatform/colcon_build_test@v0
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
- name: Download file from Google Drive
run: |
pip install gdown
gdown --id 1gTXqQtP9JS92gAtPzhKgZpdIHSV_Lcnp -O ${{ github.workspace }}/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/models_index.ann
gdown --id 1TQvt1bSXares-I9l7Wki0Jge3oubRkOJ -O ${{ github.workspace }}/src/sustainml_lib/sustainml_modules/sustainml_modules/sustainml-wp1/rag/models_index.ann

- name: Compile and run tests
uses: eProsima/eProsima-CI/multiplatform/clang_build_test@v0
Expand All @@ -243,7 +243,7 @@ jobs:
# UNCRUSTIFY

uncrustify:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:

- name: Uncrustify
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ sustainml_docs/rst/_static/css/eprosima-furo.css
sustainml_docs/rst/_static/eprosima-logo-white.png
sustainml_docs/rst/_templates/sidebar/

# local build & venv
# Local build & venv
sustainml_docs/_build/
.venv/

# Build artifacts
build/
install/
log/
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://sustainml.readthedocs.io/en/latest">Docs</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://sustainml.eu/index.php/news">News</a>
<a href="https://sustainml.eu/showroom/news">News</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
<a href="https://twitter.com/EProsima">Twitter</a>
<span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
Expand All @@ -23,8 +23,8 @@
<a href="https://github.com/eProsima/SustainML/releases"><img alt="Releases" src="https://img.shields.io/github/v/release/eProsima/SustainML?sort=semver"/></a>
<a href="https://github.com/eProsima/SustainML-Library/actions/workflows/test.yml"><img alt="SustainML Ubuntu CI" src="https://github.com/eProsima/SustainML-Library/actions/workflows/test.yml/badge.svg"/></a>
<a href="https://github.com/eProsima/SustainML/issues"><img alt="Issues" src="https://img.shields.io/github/issues/eProsima/SustainML.svg"/></a>
<a href="https://github.com/eProsima/SustainML/network/memberss"><img alt="Forks" src="https://img.shields.io/github/forks/eProsima/SustainML.svg"/></a>
<a href="https://github.com/eProsima/SustainML/stargazerss"><img alt="Stars" src="https://img.shields.io/github/stars/eProsima/SustainML.svg"/></a>
<a href="https://github.com/eProsima/SustainML/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/eProsima/SustainML.svg"/></a>
<a href="https://github.com/eProsima/SustainML/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/eProsima/SustainML.svg"/></a>
<a href="https://SustainML.readthedocs.io/en/latest/"><img alt="Documentation Status" src="https://readthedocs.org/projects/sustainml/badge/?version=latest&style=flat"/></a>
</div>

Expand All @@ -44,27 +44,28 @@ AI developers from all experience levels can make use of the framework through i

### Project Architecture

The *SustainML Framework* is composed of different Software Modules, each one related to specific task, which are specialized in solving the different parts of the machine learning problem architecture definition, starting from the user’s problem description.
Each of the modules conforms a Node.
These steps are basically:
The *SustainML Framework* is composed of different Software Modules, each one related to a specific task, which are specialized in solving the different parts of the machine learning problem architecture definition, starting from the user’s problem description.
Each of these modules forms a Node.
The main processing steps are:

1. Encode the problem and constraints defined by the user
2. Suggest a machine learning model
3. Propose an optimized hardware for running the suggested model
4. Warn about the estimated carbon footprint that would take training the model in the hardware
4. Warn about the estimated carbon footprint of training the model on the proposed hardware

All the Nodes shall import its corresponding Python library, so that each Node can be abstracted from the DDS communications.
All the Nodes shall import their corresponding Python library, so that each Node can be abstracted from the DDS communications.

### Library

This library repository contains all the modules definitions.
The Framework uses the library API to deploy those different SustainML modules.
The exchanged information between the modules is over DDS.
This library repository contains all the modules definitions. This repository is not intended to be used or installed independently.
It is consumed internally by the SustainML Framework.
The Framework uses the library API to deploy different SustainML modules.
Information exchanged between modules is transmitted over DDS.

### Framework

The Framework includes a *Graphical User Interface* (GUI) in which user interacts and introduces the ML problem definition.
That GUI implements also the **Orchestrator** node, a key node that feds the remain modules with the information provided by the user, retrieves all the results, and display them to the user though this GUI.
The Framework includes a *Graphical User Interface* (GUI) through which the user interacts with the framework and defines the ML problem.
That GUI implements also the **Orchestrator** node, a key node that feeds the remaining modules with the information provided by the user, retrieves all the results, and display them to the user through this GUI.

This process can be iterative.
So, based on a previous solution and the user's feedback, the framework provides new ML solutions.
Expand All @@ -77,9 +78,9 @@ This repository is divided in sub-packages with different targets:

* `sustainml_cpp`: Main definition and implementation of the project logic library. C++ API provided.
* `sustainml_docs`: ReadTheDocs documentation project ([available here](https://sustainml.readthedocs.io/en/latest/))
* `sustainml_modules`: Set of piped modules that use the Python API.
* `sustainml_py`: Wrap of the project logic library. Python API.
* `sustainml_swig`: Binding from the C++ API `sustainml_cpp` to the `sustainml_py` Python API.
* `sustainml_modules`: Set of pipeline modules that use the Python API.
* `sustainml_py`: Wrapper of the project logic library. Python API.
* `sustainml_swig`: Bindings from the C++ API `sustainml_cpp` to the `sustainml_py` Python API.

## Getting Help

Expand Down
20 changes: 18 additions & 2 deletions sustainml_cpp/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# SustainML Node C++
# SustainML C++ library (`sustainml_cpp`)

> :warning: **TODO**
This package contains the core C++ implementation of SustainML logic and the public C++ API used by other SustainML components.

The public C++ types are designed to avoid exposing Fast DDS types in public headers to keep the SWIG Python wrapper generation simple. Implementation types generated from IDL use the `Impl` suffix and are wrapped by public types.

## Scope

This package is primarily intended for SustainML developers and contributors. End users should follow the installation and deployment instructions in the SustainML Framework repository:

https://github.com/eProsima/SustainML-Framework

## Build

This package is a colcon package and is built automatically as part of the SustainML workspace.

For development and verification purposes, it can be built independently:

`colcon build --packages-select sustainml_cpp`
39 changes: 39 additions & 0 deletions sustainml_cpp/include/sustainml_cpp/idl/SustainMLService.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exception InternalError
{
};

// 1. AppRequirements
interface AppRequirementsService
{
string update_configuration(in string configuration) raises (InternalError);
};

// 2. HWConstraints
interface HWConstraintsService
{
string update_configuration(in string configuration) raises (InternalError);
};

// 3. HWResources
interface HWResourcesService
{
string update_configuration(in string configuration) raises (InternalError);
};

// 4. CarbonFootprint
interface CarbonFootprintService
{
string update_configuration(in string configuration) raises (InternalError);
};

// 5. MLModelMetadata
interface MLModelMetadataService
{
string update_configuration(in string configuration) raises (InternalError);
};

// 6. MLModel
interface MLModelService
{
string update_configuration(in string configuration) raises (InternalError);
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,18 @@ namespace dds {
class DomainParticipant;
class Topic;
class Publisher;
class Subscriber;
class DataWriter;

} // namespace dds
} // namespace fastdds
} // namespace eprosima

namespace sustainml {
namespace core {
class RequestReplier;
} // namespace core
namespace orchestrator {

class ModuleNodeProxy;
template <typename ... Args> class TaskDB;
template<typename ... Args> class TaskDB;
class TaskManager;

/**
Expand Down Expand Up @@ -251,17 +249,17 @@ class OrchestratorNode
*/
OrchestratorNodeHandle* handler_;

eprosima::fastdds::dds::DomainParticipant* participant_;
eprosima::fastdds::dds::DomainParticipant* participant_{nullptr};

eprosima::fastdds::dds::Topic* control_topic_;
eprosima::fastdds::dds::Topic* status_topic_;
eprosima::fastdds::dds::Topic* user_input_topic_;
eprosima::fastdds::dds::Topic* control_topic_{nullptr};
eprosima::fastdds::dds::Topic* status_topic_{nullptr};
eprosima::fastdds::dds::Topic* user_input_topic_{nullptr};

eprosima::fastdds::dds::Publisher* pub_;
eprosima::fastdds::dds::Subscriber* sub_;
eprosima::fastdds::dds::Publisher* pub_{nullptr};
eprosima::fastdds::dds::Subscriber* sub_{nullptr};

eprosima::fastdds::dds::DataWriter* control_writer_;
eprosima::fastdds::dds::DataWriter* user_input_writer_;
eprosima::fastdds::dds::DataWriter* control_writer_{nullptr};
eprosima::fastdds::dds::DataWriter* user_input_writer_{nullptr};

std::array<ModuleNodeProxy*, (size_t)NodeID::MAX> node_proxies_;
std::mutex proxies_mtx_;
Expand All @@ -276,8 +274,8 @@ class OrchestratorNode
std::atomic_bool terminated_{false};
std::condition_variable initialization_cv_;

types::ResponseType res_;
sustainml::core::RequestReplier* req_res_;
// Opaque holder for per-service RPC clients (defined in OrchestratorNode.cpp)
void* rpc_client_holder_{nullptr};

/**
* @brief This class implements the callbacks for the DomainParticipant
Expand Down Expand Up @@ -312,4 +310,3 @@ class OrchestratorNode
} // namespace sustainml

#endif // SUSTAINMLCPP_ORCHESTRATOR_ORCHESTRATORNODE_HPP

106 changes: 106 additions & 0 deletions sustainml_cpp/src/cpp/core/GenericServiceNodeImpl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://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.

/**
* @file GenericServiceNode.hpp
*/

#ifndef SUSTAINML_CORE_GENERICSERVICENODEIMPL_HPP
#define SUSTAINML_CORE_GENERICSERVICENODEIMPL_HPP

#include <iostream>
#include <string>

#include <core/NodeImpl.hpp>
#include <types/types.hpp>
#include <types/SustainMLServiceServer.hpp>

namespace eprosima {
namespace fastdds {
namespace dds {
namespace rpc {
class RpcRequest;
} // namespace rpc
} // namespace dds
} // namespace fastdds
} // namespace eprosima

namespace sustainml {
namespace core {

template<typename ServerBase>
class GenericServiceNodeImpl : public ServerBase
{
public:

GenericServiceNodeImpl(
NodeImpl& node,
const char* tag)
: node_(node)
, tag_(tag)
{
}

std::string update_configuration(
const eprosima::fastdds::dds::rpc::RpcRequest& /*info*/,
const std::string& configuration) override
{
if (node_.shutting_down())
{
throw ::InternalError("update_configuration: node is shutting down");
}

types::RequestType req;
types::ResponseType res;

req.configuration(configuration);

try
{
node_.request_listener().on_configuration_request(req, res);
}
catch (const std::exception& e)
{
throw ::InternalError(std::string("update_configuration: ") + e.what());
}

// Copy into owned std::string
std::string reply = res.configuration();

return reply;
}

private:

NodeImpl& node_;
const char* tag_;
};

using AppRequirementsServiceNodeImpl =
GenericServiceNodeImpl<AppRequirementsServiceServer_IServerImplementation>;
using HWConstraintsServiceNodeImpl =
GenericServiceNodeImpl<HWConstraintsServiceServer_IServerImplementation>;
using HWResourcesServiceNodeImpl =
GenericServiceNodeImpl<HWResourcesServiceServer_IServerImplementation>;
using CarbonFootprintServiceNodeImpl =
GenericServiceNodeImpl<CarbonFootprintServiceServer_IServerImplementation>;
using MLModelMetadataServiceNodeImpl =
GenericServiceNodeImpl<MLModelMetadataServiceServer_IServerImplementation>;
using MLModelServiceNodeImpl =
GenericServiceNodeImpl<MLModelServiceServer_IServerImplementation>;

} // namespace core
} // namespace sustainml

#endif // SUSTAINML_CORE_GENERICSERVICENODEIMPL_HPP
Loading