Skip to content

Commit

Permalink
Fix serialization error. Remove single quote removal logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed May 8, 2024
1 parent 567b777 commit 84eeeaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/engine/src/core/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions src/engine/src/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 84eeeaf

Please sign in to comment.