3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-08-15 01:15:30 +00:00

Add kind to csv (and database)

This commit is contained in:
Krystine Sherwin 2025-07-08 15:47:32 +12:00
parent 4a14207b37
commit 48a5859a1e
No known key found for this signature in database
2 changed files with 14 additions and 6 deletions

View file

@ -111,6 +111,10 @@ class SbyProperty:
def celltype(self): def celltype(self):
return f"${str(self.type).lower()}" return f"${str(self.type).lower()}"
@property
def kind(self):
return str(self.type)
@property @property
def hdlname(self): def hdlname(self):
return pretty_path(self.path).rstrip() return pretty_path(self.path).rstrip()

View file

@ -37,6 +37,7 @@ CREATE TABLE task_property (
src TEXT, src TEXT,
name TEXT, name TEXT,
hdlname TEXT, hdlname TEXT,
kind TEXT,
created REAL, created REAL,
FOREIGN KEY(task) REFERENCES task(id) FOREIGN KEY(task) REFERENCES task(id)
); );
@ -170,8 +171,8 @@ class SbyStatusDb:
now = time.time() now = time.time()
self.db.executemany( self.db.executemany(
""" """
INSERT INTO task_property (name, src, hdlname, task, created) INSERT INTO task_property (name, src, hdlname, task, kind, created)
VALUES (:name, :src, :hdlname, :task, :now) VALUES (:name, :src, :hdlname, :task, :kind, :now)
""", """,
[ [
dict( dict(
@ -179,6 +180,7 @@ class SbyStatusDb:
src=prop.location or "", src=prop.location or "",
hdlname=prop.hdlname, hdlname=prop.hdlname,
task=task_id, task=task_id,
kind=prop.kind,
now=now, now=now,
) )
for prop in properties for prop in properties
@ -250,8 +252,9 @@ class SbyStatusDb:
data.get("engine", data["source"]), data.get("engine", data["source"]),
property.hdlname, property.hdlname,
property.location, property.location,
property.kind,
property.status, property.status,
data.get("step", "DEPTH?"), data.get("step", ""),
] ]
self.task.log(f"{click.style('csv', fg='yellow')}: {','.join(str(v) for v in csv)}") self.task.log(f"{click.style('csv', fg='yellow')}: {','.join(str(v) for v in csv)}")
@ -296,7 +299,6 @@ class SbyStatusDb:
def get_result(row): def get_result(row):
row = dict(row) row = dict(row)
row["name"] = tuple(json.loads(row.get("name", "[]"))) row["name"] = tuple(json.loads(row.get("name", "[]")))
row["data"] = json.loads(row.get("data", "null"))
return row return row
return {row["id"]: get_result(row) for row in rows} return {row["id"]: get_result(row) for row in rows}
@ -380,7 +382,7 @@ class SbyStatusDb:
def all_status_data_joined(self): def all_status_data_joined(self):
rows = self.db.execute( rows = self.db.execute(
""" """
SELECT task.name as 'task_name', task.mode, task.created, SELECT task.name as 'task_name', task.mode, task.created, task_property.kind,
task_property.src as 'location', task_property.name, task_property.hdlname, task_property_status.status, task_property.src as 'location', task_property.name, task_property.hdlname, task_property_status.status,
task_property_status.data, task_property_status.created as 'status_created', task_property_status.data, task_property_status.created as 'status_created',
task_property_status.id task_property_status.id
@ -410,6 +412,7 @@ class SbyStatusDb:
"engine", "engine",
"name", "name",
"location", "location",
"kind",
"status", "status",
"depth", "depth",
] ]
@ -452,10 +455,11 @@ class SbyStatusDb:
engine, engine,
name or pretty_path(prop_status['name']), name or pretty_path(prop_status['name']),
prop_status['location'], prop_status['location'],
prop_status['kind'],
status, status,
depth, depth,
] ]
print(','.join("N/A" if v is None else str(v) for v in csv_line)) print(','.join("" if v is None else str(v) for v in csv_line))
def combine_statuses(statuses): def combine_statuses(statuses):