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

Add and use --latest flag for statuses

Should fix CI problem of running tests twice and the verific and non verific
properties having different names when testing the statusdb.
This commit is contained in:
Krystine Sherwin 2025-07-08 15:47:34 +12:00
parent 4adf5e5259
commit aa2d3ed025
No known key found for this signature in database
4 changed files with 23 additions and 6 deletions

View file

@ -63,6 +63,7 @@ status_show = args.status
status_reset = args.status_reset status_reset = args.status_reset
status_live_csv = args.livecsv status_live_csv = args.livecsv
status_show_csv = args.statuscsv status_show_csv = args.statuscsv
status_latest = args.status_latest
if status_show or status_reset or status_show_csv: if status_show or status_reset or status_show_csv:
target = workdir_prefix or workdir or sbyfile target = workdir_prefix or workdir or sbyfile
@ -94,10 +95,10 @@ if status_show or status_reset or status_show_csv:
sys.exit(1) sys.exit(1)
if status_show: if status_show:
status_db.print_status_summary() status_db.print_status_summary(status_latest)
if status_show_csv: if status_show_csv:
status_db.print_status_summary_csv(tasknames) status_db.print_status_summary_csv(tasknames, status_latest)
status_db.db.close() status_db.db.close()
@ -105,6 +106,8 @@ if status_show or status_reset or status_show_csv:
print(f"WARNING: --livecsv flag found but not used.") print(f"WARNING: --livecsv flag found but not used.")
sys.exit(0) sys.exit(0)
elif status_latest:
print(f"WARNING: --latest flag found but not used.")
if sbyfile is not None: if sbyfile is not None:

View file

@ -77,6 +77,8 @@ def parser_func(release_version='unknown SBY version'):
help="summarize the contents of the status database") help="summarize the contents of the status database")
parser.add_argument("--statuscsv", action="store_true", dest="statuscsv", parser.add_argument("--statuscsv", action="store_true", dest="statuscsv",
help="print the most recent status for each property in csv format") help="print the most recent status for each property in csv format")
parser.add_argument("--latest", action="store_true", dest="status_latest",
help="only check statuses from the most recent run of a task")
parser.add_argument("--statusreset", action="store_true", dest="status_reset", parser.add_argument("--statusreset", action="store_true", dest="status_reset",
help="reset the contents of the status database") help="reset the contents of the status database")

View file

@ -347,13 +347,16 @@ class SbyStatusDb:
self._reset() self._reset()
self.db.execute("PRAGMA foreign_keys=ON") self.db.execute("PRAGMA foreign_keys=ON")
def print_status_summary(self): def print_status_summary(self, latest: bool):
tasks, task_properties, task_property_statuses = self.all_status_data() tasks, task_properties, task_property_statuses = self.all_status_data()
latest_task_ids = filter_latest_task_ids(tasks)
properties = defaultdict(set) properties = defaultdict(set)
uniquify_paths = defaultdict(dict) uniquify_paths = defaultdict(dict)
def add_status(task_property, status): def add_status(task_property, status):
if latest and task_property["task"] not in latest_task_ids:
return
display_name = task_property["name"] display_name = task_property["name"]
if display_name[-1].startswith("$"): if display_name[-1].startswith("$"):
@ -400,7 +403,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.workdir, task.created, task_property.kind, SELECT task.id as 'task_id', task.name as 'task_name', task.mode, task.workdir, 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_trace.path, task_trace.kind as trace_kind task_property_status.id, task_trace.path, task_trace.kind as trace_kind
@ -413,9 +416,10 @@ class SbyStatusDb:
return {row["id"]: parse_status_data_row(row) for row in rows} return {row["id"]: parse_status_data_row(row) for row in rows}
def print_status_summary_csv(self, tasknames): def print_status_summary_csv(self, tasknames: list[str], latest: bool):
# get all statuses # get all statuses
all_properties = self.all_status_data_joined() all_properties = self.all_status_data_joined()
latest_task_ids = filter_latest_task_ids(self.all_tasks())
# print csv header # print csv header
csvheader = format_status_data_csvline(None) csvheader = format_status_data_csvline(None)
@ -426,6 +430,8 @@ class SbyStatusDb:
for row, prop_status in all_properties.items(): for row, prop_status in all_properties.items():
if tasknames and prop_status['task_name'] not in tasknames: if tasknames and prop_status['task_name'] not in tasknames:
continue continue
if latest and prop_status['task_id'] not in latest_task_ids:
continue
status = prop_status['status'] status = prop_status['status']
this_depth = prop_status['data'].get('step') this_depth = prop_status['data'].get('step')
this_kind = prop_status['trace_kind'] this_kind = prop_status['trace_kind']
@ -517,3 +523,9 @@ def format_status_data_csvline(row: dict|None) -> str:
depth, depth,
] ]
return ','.join("" if v is None else str(v) for v in csv_line) return ','.join("" if v is None else str(v) for v in csv_line)
def filter_latest_task_ids(all_tasks: dict[int, dict[str]]):
latest: dict[str, int] = {}
for task_id, task_dict in all_tasks.items():
latest[task_dict["workdir"]] = task_id
return list(latest.values())

View file

@ -3,7 +3,7 @@ set -e
python3 $SBY_MAIN -f $SBY_FILE $TASK python3 $SBY_MAIN -f $SBY_FILE $TASK
STATUS_CSV=${WORKDIR}/status.csv STATUS_CSV=${WORKDIR}/status.csv
python3 $SBY_MAIN -f $SBY_FILE $TASK --statuscsv | tee $STATUS_CSV python3 $SBY_MAIN -f $SBY_FILE $TASK --statuscsv --latest | tee $STATUS_CSV
if [[ $TASK =~ "_cover" ]]; then if [[ $TASK =~ "_cover" ]]; then
wc -l $STATUS_CSV | grep -q '6' wc -l $STATUS_CSV | grep -q '6'