diff --git a/src/engine/src/core/Server.py b/src/engine/src/core/Server.py index a41b4697..9436254f 100644 --- a/src/engine/src/core/Server.py +++ b/src/engine/src/core/Server.py @@ -36,7 +36,7 @@ from core.workers import WorkerPool from core.workflows import WorkflowExecutor -from utils import bytes_to_json, load_plugins, lbuffer_str as lbuf +from utils import serialize_request, load_plugins, lbuffer_str as lbuf from errors import NoAvailableWorkers, WorkflowTerminated @@ -127,7 +127,7 @@ def _start_worker(self, body, connection, channel, delivery_tag): acked = False # Indicates that the message as been acked try: # Decode the message body, then convert to an object. - serialized_request = json.loads(bytes_to_json(body)) + serialized_request = serialize_request(body) request = WorkflowSubmissionRequest(**serialized_request) # Get a workflow executor worker. If there are none available, diff --git a/src/engine/src/utils/__init__.py b/src/engine/src/utils/__init__.py index 704ba459..9fc81d45 100644 --- a/src/engine/src/utils/__init__.py +++ b/src/engine/src/utils/__init__.py @@ -23,16 +23,18 @@ def lbuffer_str(string, length=10): buffer = " " * diff return string + buffer -def bytes_to_json(bytestring): +def serialize_request(bytestring): + # DELETE THE BELOW BY: 2024/10/31 + # OLD Caused a serialization bug. But may have had use? + # value = bytestring.decode("utf8").replace("'", '"') + # Decode UTF-8 bytes to Unicode, and convert single quotes # to double quotes to make it valid JSON - print("\n\nTYPE OF BYTESTRING", type(bytestring)) - print("\n\n", "VALUE OF BS", bytestring) - value = bytestring.decode("utf8").replace("'", '"') + value = bytestring.decode("utf8") data = json.loads(value) - return json.dumps(data) + return data def get_flavor(flavor: str): if flavor not in FLAVORS: