Skip to content

Commit a5bc5bf

Browse files
committed
[Submission] Add final (default false) to check archive in zenodo
1 parent 399e2e5 commit a5bc5bf

4 files changed

Lines changed: 69 additions & 3 deletions

File tree

smtcomp/defs.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,10 @@ def uniq_id(self) -> str:
11331133
def path(self) -> Path:
11341134
return Path(self.uniq_id())
11351135

1136+
def check_final(self) -> None:
1137+
if self.url.host != "zenodo.org":
1138+
raise ValueError("Final version should have its archive in zenodo")
1139+
11361140

11371141
class Command(BaseModel, extra="forbid"):
11381142
"""
@@ -1292,6 +1296,7 @@ class Submission(BaseModel, extra="forbid"):
12921296
participations: Participations
12931297
seed: int | None = None
12941298
competitive: bool = True
1299+
final: bool = False
12951300

12961301
@model_validator(mode="after")
12971302
def check_archive(self) -> Submission:
@@ -1303,6 +1308,16 @@ def check_archive(self) -> Submission:
13031308
raise ValueError(
13041309
"Field command (or aws_repository) is needed in all participations if not present at the root"
13051310
)
1311+
1312+
def check_archive(archive: None | Archive) -> None:
1313+
if archive:
1314+
archive.check_final()
1315+
1316+
if self.final:
1317+
check_archive(self.archive)
1318+
for p in self.participations.root:
1319+
check_archive(p.archive)
1320+
13061321
return self
13071322

13081323
def uniq_id(self) -> str:

tests/test_bad_final.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "mysolver",
3+
"contributors": [
4+
"foo",
5+
{
6+
"name": "bar",
7+
"website": "http://bar.com/"
8+
}
9+
],
10+
"final":true,
11+
"contacts": ["foo bar <foo@bar.org>"],
12+
"archive": {
13+
"url": "http://example.com/solver.tar.gz",
14+
"h": { "sha256": "012345" }
15+
},
16+
"website": "http://example.com/",
17+
"system_description": "http://example.com/system.pdf",
18+
"command": ["foo", "--super-fast"],
19+
"solver_type": "Standalone",
20+
"participations": [
21+
{ "tracks": ["SingleQuery"], "divisions": ["QF_Strings"] },
22+
{ "tracks": ["SingleQuery"], "logics": "QF_.*" }
23+
]
24+
}

tests/test_good_final.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "mysolver",
3+
"contributors": [
4+
"foo",
5+
{
6+
"name": "bar",
7+
"website": "http://bar.com/"
8+
}
9+
],
10+
"contacts": ["foo bar <foo@bar.org>"],
11+
"archive": {
12+
"url": "http://zenodo.org/blabla/solver.tar.gz"
13+
},
14+
"website": "http://example.com/",
15+
"system_description": "http://example.com/system.pdf",
16+
"command": ["foo", "--super-fast"],
17+
"solver_type": "Standalone",
18+
"participations": [
19+
{ "tracks": ["SingleQuery"], "divisions": ["QF_Strings"] },
20+
{ "tracks": ["SingleQuery"], "logics": "QF_.*" }
21+
]
22+
}

tests/test_validate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
import smtcomp.results, smtcomp.scoring, smtcomp.generate_website_page
1515

1616
runner = CliRunner()
17-
good_cases = ["tests/test1.json", "submissions/template/template.json", "submissions/template/template_aws_tracks.json"]
18-
bad_cases = ["test_bad.json"]
17+
good_cases = [
18+
"tests/test1.json",
19+
"submissions/template/template.json",
20+
"submissions/template/template_aws_tracks.json",
21+
"tests/test_good_final.json",
22+
]
23+
bad_cases = ["tests/test_bad.json", "tests/test_bad_final.json"]
1924

2025

2126
@pytest.mark.parametrize("name", good_cases)
@@ -27,7 +32,7 @@ def test_good_json(name: str) -> None:
2732

2833
@pytest.mark.parametrize("name", bad_cases)
2934
def test_bad_json(name: str) -> None:
30-
result = runner.invoke(app, ["validate", path.join("tests", name)])
35+
result = runner.invoke(app, ["validate", name])
3136
assert result.exit_code == 1
3237

3338

0 commit comments

Comments
 (0)