Skip to content

Commit

Permalink
Added support for custom comm object
Browse files Browse the repository at this point in the history
  • Loading branch information
argenisleon committed Nov 6, 2019
1 parent e7a356e commit 3878a12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions optimus/bumblebee.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ class Comm:
Send encrypted message to the Bumblebee
"""

def __init__(self, queue_name=None):
def __init__(self, queue_name=None, key=None):

# If queue_name was not given try lo load from file if not generate one
if queue_name is None:
self.queue_name = save_config_key("bumblebee.ini", "DEFAULT", "QueueName", str(uuid.uuid4()))
else:
self.queue_name = queue_name

if key is None:
# key is generated as byte convert to base64 so we can saved it in the config file
key = Fernet.generate_key()
self.key = save_config_key("bumblebee.ini", "DEFAULT", "Key", key.decode())

else:
self.queue_name = queue_name
self.key = key

keys_link = "<a href ='{FULL_DOMAIN}'> here</a>".format(FULL_DOMAIN=FULL_DOMAIN,
SESSION=self.queue_name, KEY=self.key)
Expand Down
4 changes: 2 additions & 2 deletions optimus/optimus.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def __init__(self, session=None, master="local[*]", app_name="optimus", checkpoi

if comm is True:
Comm.instance = Comm()
# else:
# Comm.instance = comm
else:
Comm.instance = comm

if session is None:
# Creating Spark Session
Expand Down

0 comments on commit 3878a12

Please sign in to comment.