Technical reference

All model documents · source: docs/models/research-api.md

The research tools from Python: diff, merge, BibTeX, figures and run export

dexvantage/api_research.py (re-exported as dv.diff, dv.merge, dv.bibtex, dv.figures, dv.figure, dv.export_runs), added by the completeness review of research tools part 2. Batch mode already had every one of these (--diff, --merge, --cite, --figure, --runs-export); a notebook had to import core modules for them.

Model

There is none of its own: each function hands its inputs to the module that batch mode uses and wraps the answer.

Function Calls Returns
dv.diff(a, b, metrics=None) core/projdiff.diff, and evaluate_deltas with the API's result cache for metrics Diff: the dexvantage.diff/1 document (a dict) with .identical, .text, .html, .to_frame(), .save(path) (with provenance), an HTML view
dv.merge(base, ours, theirs) core/projdiff.merge3 Merge: .rig (unsaved), .from_ours, .from_theirs, .notes; conflicts raise dv.MergeConflict (a DexVantageError, .conflicts in words)
dv.bibtex(rig, path=None, references='checks') core/cite.bibtex the BibTeX text (written to path too)
dv.figures(result) core/publication.figure_specs (the paper kit's) [{'id', 'study', 'spec'}]
dv.figure(source, path, width='single', palette='tol', index=0) core/figures.write; bars sized and labels cut as the paper kit does (10 + 5 mm per row at least, publication.fit_labels) {'path', 'format', 'width_mm', 'height_mm', 'series'}
dv.export_runs(where, out_dir, formats=…, **filters) core/tracking.export the export's manifest: CSV, Parquet, MLflow mlruns/, W&B offline replay

Projects are a Rig, a core Project or a path (a .dexv file or an unpacked .dexv.d folder). Errors are DexVantageError with one sentence. No Qt is imported on this path except to write a PDF figure (Qt's PDF writer).

The same review made three small changes the API relies on:

And one to the plugin SDK: PluginAPI.check(...) registers a plugin's validation check under its own model (plugin.<name>, validation/suite.py PLUGIN_MODELS, all_models(), model_ids()); its references join validation/references.REFERENCES while the plugin is loaded. Unloading, or a plugin that fails, removes the checks, the model and the references again. --validate --models accepts the plugin models (available_models()).

Validation

Nothing here computes a figure, so there is no validation check of its own; the tests compare each function with the module it calls on the SO-100 sample (tests/test_completeness_api.py, 16 tests):

The plugin checks are tested in tests/test_completeness_plugins.py (5 tests): a toy plugin's check runs in the suite under its model, passes, appears in the JSON and HTML report with its reference and in the checks' BibTeX; unloading and a failing plugin remove it; a taken id, an unknown reference key and a key with other text are skipped with a sentence each.

Known limits

The functions inherit their modules' limits (lists such as grasp poses are diffed and merged whole; only the curve and bar charts have figure specs; dv.figure of a result draws its first per-item list of numbers unless index picks another). dv.diff(…, metrics=…) runs those metrics' studies on both projects in the calling thread. The main-guard check cannot see a pool started from code that execs a script, and a script that starts a pool in a guarded block still re-runs its unguarded top-level code in every worker (Python's spawn rule: keep all top-level work under the guard, as examples/03_research_workflow.py explains). Plugin checks join a run only when the plugin is loaded in that process (the app, batch mode and the API load plugins; python -m dexvantage.validation does not), and the paper kit's per-study validation summary names the built-in models only.