Skip to content

Commit

Permalink
[ApiServerDB] fix comment - use defintions for separators
Browse files Browse the repository at this point in the history
  • Loading branch information
ohad123 committed Jan 26, 2024
1 parent d6be794 commit e4d5b30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src_py/apiServer/decoderHttpMainServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
def decode_main_server_ets_str(string_to_convert: str):
result_dict = {} # {entity_name: ets_dict,...}

entity_with_stats_list = string_to_convert.split("|")[:-1] # Example: [c2&bytes_sent:0:int#messages_sent:8015:int#bad_messages:0:int#batches_sent:0:int#messages_received:8015:int#batches_received:0:int#bytes_received:40022:int#batches_dropped:0:int#messages_dropped:0:int#, w4^bytes_sent$0$int@empty_batches$0$int@bad_messages$0$int@batches_dropped_predict$0$int@batches_sent_predict$0$int@nan_loss_count$0$int@batches_received_predict$1001$int@batches_dropped_train$0$int@acc_time_training$0$int@bytes_received$0$int@average_time_prediction$0$int@batches_received_train$1000$int@average_time_training$0$int@acc_time_prediction$0$int@batches_sent_train$0$int@, s1&bytes_sent:0:int#messages_sent:4:int#bad_messages:0:int#batches_sent:8004:int#messages_received:7:int#batches_received:0:int#bytes_received:0:int#batches_dropped:0:int#messages_dropped:0:int#, c1&bytes_sent:54036:int#messages_sent:8016:int#bad_messages:0:int#batches_sent:0:int#messages_received:8016:int#batches_received:0:int#bytes_received:40022:int#batches_dropped:0:int#messages_dropped:0:int#, w2^bytes_sent$0$int@empty_batches$0$int@bad_messages$0$int@batches_dropped_predict$0$int@batches_sent_predict$0$int@nan_loss_count$0$int@batches_received_predict$1001$int@batches_dropped_train$0$int@acc_time_training$0$int@bytes_received$0$int@average_time_prediction$0$int@batches_received_train$1000$int@average_time_training$0$int@acc_time_prediction$0$int@batches_sent_train$0$int@, w1^bytes_sent$0$int@empty_batches$0$int@bad_messages$0$int@batches_dropped_predict$0$int@batches_sent_predict$0$int@nan_loss..]
entity_with_stats_list = string_to_convert.split(SEP_ENTITY_OR_STATS)[:-1]
for entity_with_stats in entity_with_stats_list:
# Example: entity_with_stats = c2&bytes_sent:0:int#messages_sent:8015:int#bad_messages:0:int#batches_sent:0:int...
if "&" in entity_with_stats:
if SEP_ENTITY_AND_STATS in entity_with_stats:
# Example: entity_with_stats = c2&bytes_sent:0:int#messages_sent:8015:int#bad_messages:0:int#batches_sent:0:int...
entity_name = entity_with_stats.split('&')[0] # Example: c2
entity_stats = entity_with_stats.split('&')[1] # Example: bytes_sent:0:int#messages_sent:8015:int#bad_messages:0:int#batches_sent:0:int...
triplets = entity_stats.split("#")[:-1] # Example: [bytes_sent:0:int, messages_sent:8015:int, bad_messages:0:int, batches_sent:0:int, ...]
entity_name = entity_with_stats.split(SEP_ENTITY_AND_STATS)[0] # Example: c2
entity_stats = entity_with_stats.split(SEP_ENTITY_AND_STATS)[1] # Example: bytes_sent:0:int#messages_sent:8015:int#bad_messages:0:int#batches_sent:0:int...
triplets = entity_stats.split(SEP_ENTITY_HASH_STATS)[:-1] # Example: [bytes_sent:0:int, messages_sent:8015:int, bad_messages:0:int, batches_sent:0:int, ...]
entity_dict = {}

for triplet in triplets:
key, value, value_type = triplet.split(':') # Example: [bytes_sent,0,int]
key, value, value_type = triplet.split(SEP_ENTITY_COLON_STATS) # Example: [bytes_sent,0,int]
if value_type == 'string':
value = value
else:
Expand All @@ -34,15 +34,15 @@ def decode_main_server_ets_str(string_to_convert: str):

result_dict[entity_name] = entity_dict

if "^" in entity_with_stats: # Belongs only to workers
if SEP_ENTITY_XOR_STATS in entity_with_stats: # Belongs only to workers
# Example: entity_with_stats = w4^bytes_sent$0$int@empty_batches$0$int@...
worker_name = entity_with_stats.split('^')[0]
worker_stats = entity_with_stats.split('^')[1]
worker_triplets = worker_stats.split('@')[:-1] # Example: [bytes_sent$0$int, empty_batches$0$int, ...]
worker_name = entity_with_stats.split(SEP_ENTITY_XOR_STATS)[0]
worker_stats = entity_with_stats.split(SEP_ENTITY_XOR_STATS)[1]
worker_triplets = worker_stats.split(SEP_ENTITY_AT_STATS)[:-1] # Example: [bytes_sent$0$int, empty_batches$0$int, ...]
worker_dict = {}

for worker_triplet in worker_triplets:
key, value, value_type = worker_triplet.split('$') # Example: [bytes_sent,0,int]
key, value, value_type = worker_triplet.split(SEP_ENTITY_DOLLAR_STATS) # Example: [bytes_sent,0,int]
if value_type == 'string':
value = value
else:
Expand Down
7 changes: 7 additions & 0 deletions src_py/apiServer/decoderHttpMainServerDefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SEP_ENTITY_AND_STATS = '&'
SEP_ENTITY_OR_STATS = '|'
SEP_ENTITY_HASH_STATS = '#'
SEP_ENTITY_AT_STATS = '@'
SEP_ENTITY_COLON_STATS = ':'
SEP_ENTITY_XOR_STATS = '^'
SEP_ENTITY_DOLLAR_STATS = '$'

0 comments on commit e4d5b30

Please sign in to comment.