Skip to content

Commit

Permalink
Add service configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Javier Gil Aviles <javiergil@eprosima.com>
  • Loading branch information
Javgilavi committed Jan 23, 2025
1 parent 5d0582c commit f794c39
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
21 changes: 20 additions & 1 deletion hw_constraints_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,28 @@ def task_callback(user_input, node_status, hw_constraints):
hw_constraints.max_memory_footprint(mem_footprint)
hw_constraints.hardware_required([hw_req])

# User Configuration Callback implementation
# Inputs: req
# Outputs: res
def configuration_callback(req, res):

# Callback for configuration implementation here

# Dummy JSON configuration and implementation
dummy_config = {
"param1": "value1",
"param2": "value2",
"param3": "value3"
}
res.configuration(json.dumps(dummy_config))
res.node_id(req.node_id())
res.transaction_id(req.transaction_id())
res.success(True)
res.err_code(sustainml_py.ErrorCode.NO_ERROR)

# Main workflow routine
def run():
node = HardwareConstraintsNode(callback=task_callback)
node = HardwareConstraintsNode(callback=task_callback, service_callback=configuration_callback)
global running
running = True
node.spin()
Expand Down
22 changes: 21 additions & 1 deletion hw_resources_provider_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import signal
import threading
import time
import json

# Whether to go on spinning or interrupt
running = False
Expand All @@ -39,9 +40,28 @@ def task_callback(ml_model, app_requirements, hw_constraints, node_status, hw):

hw.hw_description("This is a HW description")

# User Configuration Callback implementation
# Inputs: req
# Outputs: res
def configuration_callback(req, res):

# Callback for configuration implementation here

# Dummy JSON configuration and implementation
dummy_config = {
"param1": "value1",
"param2": "value2",
"param3": "value3"
}
res.configuration(json.dumps(dummy_config))
res.node_id(req.node_id())
res.transaction_id(req.transaction_id())
res.success(True)
res.err_code(sustainml_py.ErrorCode.NO_ERROR)

# Main workflow routine
def run():
node = HardwareResourcesNode(callback=task_callback)
node = HardwareResourcesNode(callback=task_callback, service_callback=configuration_callback)
global running
running = True
node.spin()
Expand Down

0 comments on commit f794c39

Please sign in to comment.