Development¶
Setup¶
git clone https://github.com/vojtechkostal/BayesicForceFields.git
cd BayesicForceFields
mamba env create -f environment.yaml # editable install with dev, docs, notebook extras
mamba activate bfflearn
pip install torch # the build for your machine
Check a change¶
make check # compileall, ruff, pytest, mkdocs build --strict
Run the narrowest tests while you work (pytest tests/qoi -q), and make
check before you push. Tests use temporary files and mocked GROMACS, Slurm,
and CP2K; nothing external has to be installed.
Code layout¶
bff/
├── cli.py the `bff` command; thin, calls workflows
├── __init__.py public Python API: stage functions, Project, QoI, Results
├── workflows/
│ ├── config.py ConfigSection: the typed YAML reader of every stage
│ ├── build/ bff build
│ ├── campaign/ MD campaigns of sample-parameters and validate,
│ │ including the per-sample job `bff md`
│ ├── sample_parameters/
│ ├── build_qoi_datasets/
│ ├── fit_lgp/
│ ├── learn/
│ └── validate/
├── domain/ specs, charge constraints, systems, samples.yaml, biases
├── qoi/ routines (rdf, hydrogen_bonds, custom), analysis, QoIDataset
├── bayes/ Gaussian-process surrogates, likelihoods, priors, results
├── mcmc/ Metropolis-Hastings sampler, proposals, checkpoints
├── io/ MDP, Colvars, PLUMED, YAML, logs
├── gromacs.py grompp/mdrun with an optional bias
├── slurm.py job arrays and queue polling
├── topology.py force-field parameter edits on GROMACS topologies
└── plotting.py
scripts/label_structures.py standalone CP2K labeling; must not import bff
Design rules¶
- Stage files are interfaces. Directory layouts, file names, and
system_id/sample_idvalues are what stages and users rely on; change them only deliberately, with a changelog and migration note. - IDs pair systems, never list order or display names.
- Configs go through
ConfigSection. It reports unknown keys, wrong types, and missing files with the full key path. A new option needs its parser, a test, the option table indocs/configuration/, and the example YAML if it is user-facing;tests/test_docs_config.pyfails when an accepted key is missing from its table. - External tools stay at the edges: GROMACS in
gromacs.py, Slurm inslurm.py, file formats inio/. The reference MD is outside BFF. - Plain code first. Prefer linear functions over small wrappers, and raise errors that name the stage, system or sample, and the path or key.
Branches and pull requests¶
Work on a branch (fix/slurm-time, docs/acetate), keep pull requests
focused, describe the behavior change, and add a regression test for every
bug fix. After main moves on: git rebase origin/main and git push
--force-with-lease.
Release¶
- Set the version in
pyproject.toml,bff/__init__.py, andCITATION.cff; updateCHANGELOG.mdanddocs/changelog.md. - Run
make check,python -m build, andpython -m twine check dist/*, and execute the notebooks in a temporary copy. - Check that new files are tracked (
git status). - Merge into
main, tagvX.Y.Z, and publish the GitHub release; the release workflow publishes to PyPI. - Install the wheel and run
bff examples, which fetches the examples of the tag. - Archive the release on Zenodo and record its DOI in
CITATION.cff.
AI coding agents follow AGENTS.md.