Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nodes/cardano-node/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"color": "#5e5086",
"reports": {
"cbor-decoding": {
"conway": "https://raw.githubusercontent.com/r2rationality/cardano-cbor-dataset/4fd977b201f7426a2983161a702bb127c87973f7/dataset/reports/conway/haskell-latest.json",
"dijkstra": "https://raw.githubusercontent.com/r2rationality/cardano-cbor-dataset/4fd977b201f7426a2983161a702bb127c87973f7/dataset/reports/dijkstra/haskell-latest.json"
"conway": "https://raw.githubusercontent.com/r2rationality/cardano-cbor-dataset/ed6c49a4e273bb540a26c46d61c011974d0192f6/dataset/reports/conway/haskell-latest.json",
"dijkstra": "https://raw.githubusercontent.com/r2rationality/cardano-cbor-dataset/ed6c49a4e273bb540a26c46d61c011974d0192f6/dataset/reports/dijkstra/haskell-latest.json"
},
"uplc-turbo": "https://raw.githubusercontent.com/pragma-org/node-diversity-conformance/main/scenarios/uplc-turbo/preview/cardano-node.json.zst",
"uplc-conformance": "https://raw.githubusercontent.com/pragma-org/node-diversity-conformance/main/scenarios/uplc-conformance/preview/cardano-node.json.zst",
Expand Down
36 changes: 27 additions & 9 deletions scenarios/cbor-decoding/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,33 @@
DATASET_RAW = f"https://raw.githubusercontent.com/{DATASET_REPOSITORY}"


def samples_of(era, commit):
"""The samples of an era at a commit, as the names and hashes of its folders. The coverage summary of the era is made
from the samples, so it does not count. Returns None when the era does not exist at this commit."""
url = f"https://api.github.com/repos/{DATASET_REPOSITORY}/git/trees/{commit}:dataset/{era}"
try:
tree = json.loads(build_common.download(url))["tree"]
except Exception:
return None
return {(entry["path"], entry["sha"]) for entry in tree if entry["path"] != "coverage.json"}


def dataset_change(era, commit=None):
"""The newest commit that changed the samples of an era, up to a commit (the default branch when None).
"""The commit that made the samples of an era as they are at a commit (the default branch when None).

A commit that only changes the README, the code or the reference reports does not make a new dataset. Returns None
when GitHub cannot be read."""
query = f"path=dataset/{era}&per_page=1" + (f"&sha={commit}" if commit else "")
This is the oldest commit of the unbroken run of commits, up to this one, that leave the samples as they are. A commit
that only changes the README, the code, the coverage or the reference reports does not make a new dataset. Returns
None when GitHub cannot be read, or when it does not know the commit."""
query = f"path=dataset/{era}&per_page=30" + (f"&sha={commit}" if commit else "")
try:
commits = json.loads(build_common.download(f"https://api.github.com/repos/{DATASET_REPOSITORY}/commits?{query}"))
return commits[0]["sha"]
commits = [change["sha"] for change in json.loads(build_common.download(f"https://api.github.com/repos/{DATASET_REPOSITORY}/commits?{query}"))]
samples = samples_of(era, commits[0])
change = commits[0]
for older in commits[1:]:
if samples_of(era, older) != samples:
break
change = older
return change
except Exception as error:
print(f"warn cbor-decoding: no dataset change for {era} at {(commit or 'the default branch')[:7]} ({error})")
return None
Expand Down Expand Up @@ -62,7 +80,8 @@ def prepare(_scenario, entries):

def is_outdated(report, dataset_changes):
"""Whether a report was made with an older dataset than the latest one of its era. Mirrors the pill of the scenario
page: a report that names no dataset is outdated, and nothing is outdated when the dataset changes are unknown."""
page: a report is outdated when it names no dataset, or a dataset that GitHub does not know. Nothing is outdated when
the latest dataset change is unknown."""
if not (report and report.get("protocol_version")):
return False
try:
Expand All @@ -73,8 +92,7 @@ def is_outdated(report, dataset_changes):
return False
if not report.get("dataset_commit"):
return True
own = changes["by_commit"].get(report["dataset_commit"])
return bool(own) and own != changes["latest"]
return changes["by_commit"].get(report["dataset_commit"]) != changes["latest"]


def outdated(entry, dataset_changes):
Expand Down
2 changes: 1 addition & 1 deletion scenarios/cbor-decoding/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ <h1>CBOR decoding</h1>
</div>
<script src="../../js/percent.js"></script>
<script src="../../js/fit.js"></script>
<script src="scenario.js?v=54"></script>
<script src="scenario.js?v=56"></script>
</body>
</html>
21 changes: 16 additions & 5 deletions scenarios/cbor-decoding/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,15 @@ function datasetChanges() {
return state.datasetChanges[state.era] || null;
}

// Whether the report was made with an older dataset than the latest one of the era, as the pill shows it. A report is
// not outdated when the build could not find the latest dataset change.
function isOutdated(report, changes) {
if (!changes?.latest) return false;
return !report.dataset_commit || changes.by_commit[report.dataset_commit] !== changes.latest;
}

// A pill that tells whether the report was made with the latest dataset of the era, with a box that gives the reason on
// hover. A dataset is the samples of an era: a commit that changes only the README or the code is not a new one. Nothing
// hover. A dataset is the samples of an era: a commit that changes only the README, the code or the coverage is not a new one. Nothing
// is shown when the build could not find the dataset changes.
function freshnessPill(report, changes) {
if (!changes?.latest) return '';
Expand All @@ -110,7 +117,9 @@ function freshnessPill(report, changes) {
return pill('outdated', 'Outdated', 'This report was made with an older version of the dataset. The report does not name it.');
}
const own = changes.by_commit[report.dataset_commit];
if (!own) return '';
if (!own) {
return pill('outdated', 'Outdated', `This report names a dataset commit that the dataset repository does not know: ${short(report.dataset_commit)}`);
}
if (own === changes.latest) {
return pill('latest', 'Latest', `This report was made with the latest CBOR dataset: ${short(own)}`);
}
Expand Down Expand Up @@ -147,11 +156,13 @@ function loaded() {
return state.nodes.filter((n) => n.report);
}

// Keep the strongest reports first so all report sections use the same order.
// Reports made with the latest dataset come first, then the outdated ones. Each group goes from the strongest report to
// the weakest, as on the front page. All report sections use the same order.
function ranked() {
const changes = datasetChanges();
return loaded()
.map((n) => ({ node: n, s: score(n.report.totals) }))
.sort((a, b) => (b.s.ratio ?? -1) - (a.s.ratio ?? -1) || a.node.name.localeCompare(b.node.name));
.map((n) => ({ node: n, s: score(n.report.totals), outdated: isOutdated(n.report, changes) }))
.sort((a, b) => a.outdated - b.outdated || (b.s.ratio ?? -1) - (a.s.ratio ?? -1) || a.node.name.localeCompare(b.node.name));
}

function renderWarnings() {
Expand Down
2 changes: 2 additions & 0 deletions scripts/build_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def is_pinned(url):
parts = urlsplit(url)
if parts.netloc == "raw.githubusercontent.com":
return re.match(r"/[^/]+/[^/]+/[0-9a-f]{40}/", parts.path) is not None
if parts.netloc == "api.github.com" and re.match(r"/repos/[^/]+/[^/]+/git/trees/[0-9a-f]{40}:", parts.path):
return True
return parts.netloc == "api.github.com" and re.search(r"[?&]sha=[0-9a-f]{40}(&|$)", parts.query) is not None


Expand Down
Loading