Skip to content

Commit

Permalink
Remove use of .value when comparing enums: enums can be compared dire…
Browse files Browse the repository at this point in the history
…ctly (#1967)

Co-authored-by: Zhuozhao Li <[email protected]>
  • Loading branch information
benclifford and ZhuozhaoLi authored Feb 11, 2021
1 parent ed035be commit 98c03b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions parsl/monitoring/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def start(self,
task_info_update_messages, task_info_insert_messages, task_info_all_messages = [], [], []
try_update_messages, try_insert_messages, try_all_messages = [], [], []
for msg_type, msg in priority_messages:
if msg_type.value == MessageType.WORKFLOW_INFO.value:
if msg_type == MessageType.WORKFLOW_INFO:
if "python_version" in msg: # workflow start message
logger.debug(
"Inserting workflow start info to WORKFLOW table")
Expand All @@ -379,7 +379,7 @@ def start(self,
messages=[msg])
self.workflow_end = True

elif msg_type.value == MessageType.TASK_INFO.value:
elif msg_type == MessageType.TASK_INFO:
task_try_id = str(msg['task_id']) + "." + str(msg['try_id'])
task_info_all_messages.append(msg)
if msg['task_id'] in inserted_tasks:
Expand Down
8 changes: 4 additions & 4 deletions parsl/monitoring/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,11 @@ def start(self,
try:
msg = self.dfk_channel.recv_pyobj()
self.logger.debug("Got ZMQ Message from DFK: {}".format(msg))
if msg[0].value == MessageType.BLOCK_INFO.value:
if msg[0] == MessageType.BLOCK_INFO:
block_msgs.put((msg, 0))
else:
priority_msgs.put((msg, 0))
if msg[0].value == MessageType.WORKFLOW_INFO.value and 'python_version' not in msg[1]:
if msg[0] == MessageType.WORKFLOW_INFO and 'python_version' not in msg[1]:
break
except zmq.Again:
pass
Expand All @@ -468,13 +468,13 @@ def start(self,
try:
msg = self.ic_channel.recv_pyobj()
self.logger.debug("Got ZMQ Message from interchange: {}".format(msg))
if msg[0].value == MessageType.NODE_INFO.value:
if msg[0] == MessageType.NODE_INFO:
msg[2]['last_heartbeat'] = datetime.datetime.fromtimestamp(msg[2]['last_heartbeat'])
msg[2]['run_id'] = self.run_id
msg[2]['timestamp'] = msg[1]
msg = (msg[0], msg[2])
node_msgs.put((msg, 0))
elif msg[0].value == MessageType.BLOCK_INFO.value:
elif msg[0] == MessageType.BLOCK_INFO:
block_msgs.put((msg, 0))
else:
self.logger.error(f"Discarding message from interchange with unknown type {msg[0].value}")
Expand Down

0 comments on commit 98c03b9

Please sign in to comment.