| Title: | Check Packages and Corpora Against the openalexPro Ecosystem Standard |
|---|---|
| Description: | Checks R packages and Parquet corpora against STANDARD.md of the openalexPro ecosystem (corpus layout, works schema, provenance files, identifiers, link table, package requirements) and writes compliance reports. Used in package tests and by the ecosystem's compliance workflow. |
| Authors: | Rainer M. Krug [aut, cre] (ORCID: <https://orcid.org/0000-0002-7490-0066>) |
| Maintainer: | Rainer M. Krug <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-30 15:11:58 UTC |
| Source: | https://github.com/openalexPro/openalexPro_Ecosystem |
Check an annotation folder against STANDARD.md (N1-N3, T2)
check_annotation(dir, corpus = NULL)check_annotation(dir, corpus = NULL)
dir |
The annotation folder, |
corpus |
Optional: the corpus it annotates. When given, the partitions
and |
A data frame of results, as check_corpus().
Runs every automatable corpus rule of STANDARD.md (sections 1-5 and 7, and T1/T2 for transformers) on a corpus folder and its sibling link table. The corpus is only read, never changed.
check_corpus( dir, links = file.path(dirname(dir), "links"), kind = c("writer", "transformer"), prefix = NULL, api = TRUE )check_corpus( dir, links = file.path(dirname(dir), "links"), kind = c("writer", "transformer"), prefix = NULL, api = TRUE )
dir |
The corpus folder: the folder a reader is given, with
|
links |
The link table folder (K1). Defaults to |
kind |
|
prefix |
The writer's prefix (I5), or the prefixes of all writers of a
mixed corpus. Defaults to the prefix(es) in |
api |
Also run |
A data frame with one row per rule: rule, level, status
(pass, fail, n/a, not verified, manual), evidence, fix.
Checks the package rules (P1-P7) from DESCRIPTION, NAMESPACE and the
source, works out which kinds of package it is (writer, consumer,
transformer, annotator; STANDARD.md section 8), and flags code to review for
A1 and A3. Works for any package, in the ecosystem or not.
check_package(path, kind = NULL, manifest = NULL)check_package(path, kind = NULL, manifest = NULL)
path |
Package source folder. |
kind |
Kinds to assume instead of detecting them. |
manifest |
Optional paths to the ecosystem's |
A data frame of results, as check_corpus(), with attributes
package, version, kind and prefix.
Write the index page of the report site
compliance_index( site = "compliance", state = jsonlite::read_json(file.path(site, "state.json")) )compliance_index( site = "compliance", state = jsonlite::read_json(file.path(site, "state.json")) )
site |
The report site folder. |
state |
The parsed state file (a named list, |
The path of index.md, invisibly.
Used by the ecosystem's compliance workflow. Each folder in artifacts
holds the output of one compliance_report() run plus target.json
(repo, branch, commit, private, standard, checker, deps). The reports
are copied to <site>/<owner>/<repo>/<branch>.md|json (the redacted version
for private repositories), state is updated, and <site>/index.md is
rebuilt from all reports.
compliance_publish( artifacts, site = "compliance", state = file.path(site, "state.json") )compliance_publish( artifacts, site = "compliance", state = file.path(site, "state.json") )
artifacts |
Folder with one sub-folder per checked repository and branch. |
site |
The report site folder ( |
state |
The state file recording what was checked. |
The paths written, invisibly.
Checks a package source with check_package(). For writers and
transformers it then builds the package's example corpus
(<prefix>_example_corpus(), STANDARD.md P7) in a temporary folder and
checks it with check_corpus(). Every rule of STANDARD.md gets one row:
rules for other kinds of package are n/a, rules that need a review are
manual, rules that could not be checked are not verified.
compliance_report( path, out_dir = NULL, redact = FALSE, repo = NULL, ref = NULL, commit = NULL, kind = NULL, manifest = NULL, api = TRUE )compliance_report( path, out_dir = NULL, redact = FALSE, repo = NULL, ref = NULL, commit = NULL, kind = NULL, manifest = NULL, api = TRUE )
path |
Package source folder. |
out_dir |
Folder to write |
redact |
Also write |
repo, ref, commit
|
Shown in the report header (e.g. |
kind, manifest
|
Passed to |
api |
Run |
The report is deterministic: it names the package commit, the standard version and the checker version, but no date, so re-checking an unchanged package gives an identical file.
The results (a data frame) with attribute meta, invisibly.
SHA-256 of one line per Parquet file below dir (sorted by relative path):
<relative path>\t<size>\t<SHA-256 of the last 65536 bytes>. The last bytes
hold the Parquet footer (row counts, schema, column statistics), so the
fingerprint changes with the data but not when the corpus is copied.
content_fingerprint(dir)content_fingerprint(dir)
dir |
A corpus (or annotation) folder. |
"sha256:<hex>".
A testthat expectation for package tests: fails when any MUST rule of
check_corpus() fails, and lists them.
expect_compliant_corpus(dir, ...)expect_compliant_corpus(dir, ...)
dir |
Corpus folder. |
... |
Passed to |
dir, invisibly.
Follows derived_from in _dataset.json back to the sources, and checks each
recorded content fingerprint against the input's current data (D5).
provenance(dir)provenance(dir)
dir |
A corpus or annotation folder. |
A data frame: level (0 = dir), path, writer, checksum
(ok, changed, none, missing, external).
Writes three works (zenodo: ids, as written by openalexImportZenodo) with
_dataset.json, _query.json, _query.html and a link table below the
project folder out, and returns the corpus folder. Used to test packages
that read corpora (A2) and annotators (P7a).
standard_example_corpus(out = tempfile())standard_example_corpus(out = tempfile())
out |
Project folder to write into. |
The path of the corpus folder.
Registered prefixes (STANDARD.md I5) and identifier schemes (I7)
standard_prefixes() standard_schemes()standard_prefixes() standard_schemes()
standard_prefixes(): data frame prefix, package, kind.
standard_schemes(): character vector.
One row per rule: rule, level (MUST/SHOULD/MAY), section, kinds
(;-separated: writer, consumer, transformer, annotator), automated
(yes/partly/manual) and a one-line summary. The pseudo-rule API is
openalexAPI's prepare_corpus() on the corpus.
standard_rules()standard_rules()
A data frame.
Version of STANDARD.md the checks implement
standard_version()standard_version()
A string, e.g. "0.1".
Like the usethis functions: adds what a package needs to be checked against STANDARD.md, and never overwrites an existing file.
use_compliance(path = ".", prefix = NULL, kind = NULL)use_compliance(path = ".", prefix = NULL, kind = NULL)
path |
Package source folder. |
prefix |
The package's registered prefix (I5). Defaults to the one registered for the package, if any. |
kind |
Kinds of package, as in |
Config/openalexPro/standard in DESCRIPTION (P2a), and openalexStandard
and openalexAPI in Suggests and Remotes (with the desc package, if
installed; else a message), whether or not they are installed;
writers and transformers: R/example_corpus.R with a stub of
<prefix>_example_corpus(out) to fill in (P7), and
tests/testthat/test-compliance.R running expect_compliant_corpus() and
openalexAPI::prepare_corpus() on it (P4);
.github/workflows/compliance.yml calling the ecosystem's reusable
compliance-check workflow with fail-on: none.
Run devtools::document() afterwards, so the stub is exported.
The paths created or changed, invisibly.
_dataset.json for a corpus or annotation (STANDARD.md D1-D3, T2, N2)Writes a deterministic marker file: no timestamps, no absolute paths, fixed
field order, so an unchanged corpus gets a byte-identical file. Call it after
the data are written: it records their fingerprint (content, D5).
write_dataset_json( dir, package, version, prefix, id_format = NULL, type = c("works", "annotation"), partition_keys = "query", derived_from = NULL, method = NULL )write_dataset_json( dir, package, version, prefix, id_format = NULL, type = c("works", "annotation"), partition_keys = "query", derived_from = NULL, method = NULL )
dir |
The corpus (or annotation) folder. |
package, version
|
The writing package and its version. |
prefix |
The writer's registered prefix (I5). |
id_format |
The template of |
type |
|
partition_keys |
The Hive partition keys, top level first. |
derived_from |
Inputs (transformers, annotators): corpus folders, stored
relative to |
method |
For annotations (N2): a list with the method name, version and settings. |
The path of the file, invisibly.
Writes <dir>/query=<name>/data.parquet with the K1 columns. Checks the
identifier form of every link end (K4) and the prefix of extra columns (S5)
first, and stops with the offending values. A data frame with no rows still
writes a file with the columns (K2).
write_links(links, dir, name, corpus_ids = NULL, prefix = NULL)write_links(links, dir, name, corpus_ids = NULL, prefix = NULL)
links |
A data frame with |
dir |
The link table folder ( |
name |
The partition name, the same as the corpus partition. |
corpus_ids |
The |
prefix |
The writer's prefix, for extra columns. |
The path of the file, invisibly.