Skip to content

Commit

Permalink
#35: first level of fixes for id/seq_id -- also added other consisten…
Browse files Browse the repository at this point in the history
…cy tests
  • Loading branch information
ppebay committed Nov 27, 2024
1 parent 5355d46 commit c97de9f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/ccm_milp/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#

import json
import sys

class Data:

Check notice on line 39 in src/ccm_milp/data.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Too many instance attributes (15/10) (too-many-instance-attributes)
"""Data file class used after parsing json data files"""
Expand Down Expand Up @@ -93,8 +94,19 @@ def parse_json(self, data_files: list, verbose: bool):
for task in data_json["phases"][0]["tasks"]:
# Get data
time = task["time"]
index = task.get("entity").get("index")
obj_id = task.get("entity").get("seq_id")
entity = task.get("entity")
if entity is None:
print (f"*** ERROR: task {task} has no associated entity")
sys.exit(1)
index = entity.get("index")
try:
obj_id = entity["id"]
except:

Check warning on line 104 in src/ccm_milp/data.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

No exception type(s) specified (bare-except)
try:
obj_id = entity["seq_id"]
except:

Check warning on line 107 in src/ccm_milp/data.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

No exception type(s) specified (bare-except)
print (f"*** ERROR: entity {entity} neither has an id nor a seq_id")
sys.exit(1)
if task.get("user_defined") is None:
continue
shared_id = task.get("user_defined").get("shared_id")
Expand Down Expand Up @@ -125,8 +137,8 @@ def parse_json(self, data_files: list, verbose: bool):
if "communications" in data_json["phases"][0]:
for com in data_json["phases"][0]["communications"]:
comunications.append([
com["from"]["seq_id"],
com["to"]["seq_id"],
com["from"].get("id", com.get("id", com.get("seq_id"))),
com["to"].get("id", com.get("id", com.get("seq_id"))),
com["bytes"]
])

Expand Down

0 comments on commit c97de9f

Please sign in to comment.