Skip to content

Commit

Permalink
Fix family definition
Browse files Browse the repository at this point in the history
It is all the middle of the path
  • Loading branch information
bobot committed Apr 30, 2024
1 parent a3ec014 commit 702ea60
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
19 changes: 18 additions & 1 deletion smtcomp/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Division(str, Enum):


class Logic(str, Enum):
def __str__(self) -> str:
return str(self.value)

ABV = "ABV"
ABVFP = "ABVFP"
ABVFPLRA = "ABVFPLRA"
Expand Down Expand Up @@ -1101,15 +1104,29 @@ def uniq_id(self) -> str:

class Smt2File(BaseModel):
logic: Logic
family: str
family: list[str]
name: str
status: Status
asserts: int
check_sats: int

@model_validator(mode="after")
def check_archive(self) -> Smt2File:
if "/" in self.name:
raise ValueError("name should not contain /, directory part should go in family name")
for f in self.family:
if "/" in f:
raise ValueError("family part should not contain /, it should be splitted")
return self

def path(self) -> Path:
return Path(self.logic).joinpath(Path(*self.family)).joinpath(self.name)


class Benchmarks(BaseModel):
files: list[Smt2File]


Benchmarks.model_validate_json

default = {"timelimit_s": 60, "memlimit_M": 1024 * 20, "cpuCores": 4}
6 changes: 3 additions & 3 deletions smtcomp/list_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def get_info_smt2_file(src: Path, file: Path, scrambler: Optional[Path]) -> defs
parts = PurePath(file.relative_to(src)).parts
return defs.Smt2File(
logic=defs.Logic(parts[0]),
family=parts[1],
name="/".join(parts[2:]),
family=list(parts[1:-1]),
name=parts[-1],
status=get_status(file),
asserts=get_nb_asserts(file, scrambler),
check_sats=get_nb_check_sats(file),
Expand All @@ -74,5 +74,5 @@ def list_benchmarks(src: Path, dst: Path, scrambler: Optional[Path], max_workers
description="Scanning files...",
)
)
files.sort(key=(lambda k: "/".join([k.logic, k.family, k.name])))
files.sort(key=(lambda k: k.path()))
return defs.Benchmarks(files=files)
1 change: 1 addition & 0 deletions smtcomp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,6 @@ def create_benchmarks_list(src: Path, dst: Path, scrambler: Optional[Path] = Non
The path to the binary of the scrambler must be given in order to count
"""
benchmarks = smtcomp.list_benchmarks.list_benchmarks(src, dst, scrambler, j)
src.read_text
with open(dst, "w") as f:
f.write(benchmarks.model_dump_json(indent=2))

0 comments on commit 702ea60

Please sign in to comment.