Sorted nodes by Id to fix graph generation
This commit is contained in:
parent
8fc0377a9e
commit
9b05af85a9
@ -6,6 +6,8 @@ import xml.etree.ElementTree as ET
|
|||||||
from structures import Job
|
from structures import Job
|
||||||
from gantt_types import ThreadId
|
from gantt_types import ThreadId
|
||||||
|
|
||||||
|
def get_nodeId(elem: Job) -> int:
|
||||||
|
return elem.nodeId
|
||||||
|
|
||||||
def read_jobs(filename: str) -> List[Job]:
|
def read_jobs(filename: str) -> List[Job]:
|
||||||
jobs: List[Job] = []
|
jobs: List[Job] = []
|
||||||
@ -22,7 +24,9 @@ def read_jobs(filename: str) -> List[Job]:
|
|||||||
if job := parse_job_node(node):
|
if job := parse_job_node(node):
|
||||||
jobs.append(job)
|
jobs.append(job)
|
||||||
|
|
||||||
return jobs
|
sortedJobs: List[Job] = []
|
||||||
|
sortedJobs = sorted(jobs, key=get_nodeId)
|
||||||
|
return sortedJobs
|
||||||
|
|
||||||
|
|
||||||
def parse_iso(time: str) -> datetime:
|
def parse_iso(time: str) -> datetime:
|
||||||
@ -51,9 +55,11 @@ def parse_job_node(node: ET.Element) -> Optional[Job]:
|
|||||||
name = value
|
name = value
|
||||||
if attr == "Slot" or attr == "Thread":
|
if attr == "Slot" or attr == "Thread":
|
||||||
thread = value
|
thread = value
|
||||||
|
if attr == "Id":
|
||||||
|
nodeId = value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return Job(start, end, strip_newlines(name), parse_thread_id(thread))
|
return Job(start, end, strip_newlines(name), parse_thread_id(thread), int(nodeId))
|
||||||
except UnboundLocalError:
|
except UnboundLocalError:
|
||||||
# most likely doesn't include "Thread" or "Slot" attribute.
|
# most likely doesn't include "Thread" or "Slot" attribute.
|
||||||
return None
|
return None
|
||||||
|
@ -12,6 +12,7 @@ class Job(NamedTuple):
|
|||||||
end: datetime
|
end: datetime
|
||||||
name: str
|
name: str
|
||||||
thread: ThreadId
|
thread: ThreadId
|
||||||
|
nodeId: int
|
||||||
|
|
||||||
|
|
||||||
class Row(NamedTuple):
|
class Row(NamedTuple):
|
||||||
|
Loading…
Reference in New Issue
Block a user