Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
29846ac
initial greenfield implementation
gregorweiss Jul 22, 2026
ba109ee
Auto-detect GROMACS binary (gmx_mpi vs gmx) and add error handling
gregorweiss Jul 22, 2026
d0f77cf
Fix stage functions to support optional prev_future for checkpoint re…
gregorweiss Jul 22, 2026
04e79e2
Add checkpoint detection, stage execution, and trajectory validation
gregorweiss Jul 22, 2026
c85b903
Add comprehensive test suite (64 tests) for checkpoint and workflow v…
gregorweiss Jul 22, 2026
c2562e4
Refactor GROMACS binary detection into testable function
gregorweiss Jul 22, 2026
67f14fb
Update tests to expect dynamic GROMACS binary detection
gregorweiss Jul 22, 2026
bf69835
Add retries=3 to Parsl config for transient fault recovery
gregorweiss Jul 23, 2026
8b429d1
Wire restart_from_cpt into mdrun bash app for -cpi/-append restart su…
gregorweiss Jul 23, 2026
d80f7b4
Thread checkpoint restart info from detection through stages into mdrun
gregorweiss Jul 23, 2026
1ce80e7
Add stage_overrides field and get_stage_config() to SlurmExecutorConfig
gregorweiss Jul 23, 2026
5c417fe
Thread per-stage resource config (ntasks, disable_gpu) through stage …
gregorweiss Jul 23, 2026
33c88fd
Fix simulate CLI to discover fresh sim dirs without requiring BuildIn…
gregorweiss Jul 23, 2026
9baa8d3
Make account optional in BaseSlurmConfig to support clusters without …
gregorweiss Jul 23, 2026
bb8cd9c
Support gmx_mpi (pure MPI) builds in mdrun app: use -ntomp instead of…
gregorweiss Jul 23, 2026
3881ea7
Normalise bash app exit codes to status dicts in _wait_with_progress
gregorweiss Jul 23, 2026
e83f7de
Add result_transform to _wait_with_progress to decouple bash_app resu…
gregorweiss Jul 23, 2026
ea7076f
Update account test to document optional-account contract for cluster…
gregorweiss Jul 23, 2026
44e8c1f
Remove run_full_pipeline dead code: bypassed stage_config, restart su…
gregorweiss Jul 23, 2026
bd06d3f
Fix MPI comment (single-rank execution) and accept prod.trr alongside…
gregorweiss Jul 23, 2026
7878af4
Fix simulate --hash filter; add next-steps hint after build
gregorweiss Jul 23, 2026
a6fead9
Handle ValueError from hash filter with clean sys.exit
gregorweiss Jul 23, 2026
59e31b0
Remove stale filter_paths_by_hash import from simulate command
gregorweiss Jul 23, 2026
cfcba15
Fix examples/slurm_gpu.yaml partition (gpu-l40s→gpu) and module; make…
gregorweiss Jul 23, 2026
719cb13
Fix PME-GPU for EM: pass pme_gpu=False so EM uses -nb gpu -pme cpu
gregorweiss Jul 23, 2026
d2ac1f4
Add StageSpec/STAGE_REGISTRY and generic run_stage(); stage functions…
gregorweiss Jul 23, 2026
00613d7
Replace six scattered stage dicts with STAGE_BY_NAME lookups; make _d…
gregorweiss Jul 23, 2026
cccb7e8
Extract _require_bash_app, _build_grompp_script, _build_mdrun_script …
gregorweiss Jul 23, 2026
e45db6c
Extract _get_block_status, _is_running, _poll_future as module-level …
gregorweiss Jul 23, 2026
d80bc20
Extract _resolve_analysis_slurm_config and _resolve_sim_paths_for_sim…
gregorweiss Jul 23, 2026
df2dfec
Update tests to use _build_grompp_script/_build_mdrun_script pure fun…
gregorweiss Jul 23, 2026
aa47a90
update CONTRIBUTORS.md
gregorweiss Jul 23, 2026
1a9d80d
Promote _find_structure_file to public API; export from orchestration…
gregorweiss Jul 23, 2026
da17c04
Document sequential session constraint in parsl_session docstring
gregorweiss Jul 23, 2026
bd26a3d
Skip simulations for dirs with incomplete builds instead of raising
gregorweiss Jul 23, 2026
395c631
Export OMP_NUM_THREADS=$NTHR in mdrun script to match -ntomp flag
gregorweiss Jul 23, 2026
4cc1e07
refactor(apps): decompose _build_mdrun_script into Python resolver hi…
gregorweiss Jul 24, 2026
5e9fe25
feat(config,stages): add gmx_binary field and thread through mdrun pi…
gregorweiss Jul 24, 2026
35b8f74
refactor(tests): replace bash-string assertions with resolver unit tests
gregorweiss Jul 24, 2026
d2b8e61
fix(lint): resolve all ruff warnings in orchestration and tests
gregorweiss Jul 24, 2026
5f23c50
fix(format): apply ruff formatter to cli, stages, and config tests
gregorweiss Jul 24, 2026
657f40f
refactor(apps): extract _build_gmx_detect_block to eliminate duplicat…
gregorweiss Jul 24, 2026
a2c7845
fix(format): apply ruff formatter to apps.py
gregorweiss Jul 24, 2026
caae59b
fix(simulate): check all traj_files in production output state detection
gregorweiss Jul 27, 2026
5c29ec0
fix(simulate): derive find_structure_file candidates from STAGE_REGISTRY
gregorweiss Jul 27, 2026
9d64397
refactor(simulate): replace stage_functions dict with run_stage dispa…
gregorweiss Jul 27, 2026
5579581
fix(simulate): warn on wait=False that raw futures resolve to None, n…
gregorweiss Jul 27, 2026
3a2567f
fix(cli): add consume_multiple=True to stages and hash list parameter…
gregorweiss Jul 27, 2026
7445f18
fix(stages): pass pme_gpu=spec.supports_pme_gpu in restart branch
gregorweiss Jul 27, 2026
ae2eef8
fix(stages): default disable_gpu=True when stage_config is None, guar…
gregorweiss Jul 27, 2026
c1b5254
fix(simulate): treat MDAnalysis parse failure as incomplete trajectory
gregorweiss Jul 27, 2026
1857287
fix(simulate): normalize MDP keys and read nstxout for TRR frame coun…
gregorweiss Jul 27, 2026
55790b9
fix(simulate): check all traj_files in skip checkpoint mode
gregorweiss Jul 27, 2026
a5f7cfc
fix(simulate): include skipped builds in result accounting
gregorweiss Jul 27, 2026
74461b9
fix(config): validate stage_overrides keys and use model_validate
gregorweiss Jul 27, 2026
0588ce8
fix(stages): divide cpus_per_node by max_workers_per_node for mdrun t…
gregorweiss Jul 27, 2026
426193b
test(simulate): add checkpoint restart detection, run_stage grompp wi…
gregorweiss Jul 27, 2026
3c21be5
test(apps): add grompp flag generation, gmx_binary selection, and res…
gregorweiss Jul 27, 2026
8256883
test(cli): add simulate command and helper unit tests
gregorweiss Jul 27, 2026
1336fd3
chore(config): document deferred account validation and Nextflow reti…
gregorweiss Jul 27, 2026
89bf71d
fix(tests): split long @patch decorator line to comply with E501
gregorweiss Jul 27, 2026
4ce79d7
fix(simulate): extract _detect_skip_stage_state and _detect_auto_outp…
gregorweiss Jul 27, 2026
ddc2854
style(tests): apply ruff formatting to orchestration test files
gregorweiss Jul 27, 2026
f623605
docs: replace Nextflow with Parsl orchestration documentation (#27)
gregorweiss Aug 10, 2026
c8da89e
chore: remove legacy Nextflow workflow files (#29)
gregorweiss Aug 10, 2026
338497d
chore: regenerate pixi.lock for parsl and docs environments
gregorweiss Aug 10, 2026
f0c8a01
feat: add per-stage override prompts to SLURM config wizard (#33)
gregorweiss Aug 10, 2026
5b94e7b
feat: adaptive rescue retry for GROMACS physics failures (#31)
gregorweiss Aug 10, 2026
836d3dd
feat(tui): make stage-override prompts context-aware based on actual …
gregorweiss Aug 11, 2026
d4a116e
test: add rescue retry integration tests with real GROMACS
gregorweiss Aug 11, 2026
92f1865
fix(tests): repair rescue integration tests with correct GROMACS fixt…
gregorweiss Aug 11, 2026
cd4588e
feat: include detected GROMACS modules in default worker init for sim…
gregorweiss Aug 11, 2026
b84323e
fix: unwrap Parsl DependencyError to surface grompp root cause (#36)
gregorweiss Aug 11, 2026
94c1632
feat(tui): auto-detect GROMACS and prompt for module load in worker init
gregorweiss Aug 11, 2026
ee972c1
test: add --max-rescue CLI passthrough tests
gregorweiss Aug 11, 2026
1b7e884
style: fix ruff lint and formatting violations
gregorweiss Aug 11, 2026
f044a03
feat: add --clean flag to simulate for resetting output directories (…
gregorweiss Aug 11, 2026
378c28d
feat: print resolved gmx commands in dry-run mode
gregorweiss Aug 12, 2026
aa37bb6
docs: add Parsl investigation findings write-up
gregorweiss Aug 12, 2026
08f6aeb
docs: move parsl-findings to developer-guide
gregorweiss Aug 12, 2026
3c96e9a
docs: remove parsl-findings from docs (moved to issue)
gregorweiss Aug 12, 2026
7e96242
refactor: separate EnvironmentConfig from SLURM allocation (#41)
gregorweiss Aug 12, 2026
16168c4
refactor: clean up simulation orchestration per DESIGN.md
gregorweiss Aug 12, 2026
46a0626
fix: resolve ruff lint and format issues
gregorweiss Aug 12, 2026
df8cbb5
fix: single Ctrl+C cleanly exits simulation workflow
gregorweiss Aug 12, 2026
648fda2
fix: suppress Parsl interchange tracebacks on Ctrl+C
gregorweiss Aug 12, 2026
67dda01
fix: use daemon threads to prevent atexit hang on Ctrl+C
gregorweiss Aug 12, 2026
96e7e56
fix: squeue fallback to cancel Parsl jobs missed by DFK tracking
gregorweiss Aug 12, 2026
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,7 @@ charmm36.ff/
!docs/public/diagrams/**/*.png
!docs/public/mdfactory-logo-v1.0.png

# Allow GROMACS test fixtures
!mdfactory/tests/fixtures/**

.pixi/
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

- Marc Siggel — Merck KGaA, Darmstadt, Germany
- Maximilian Scheurer — Merck KGaA, Darmstadt, Germany
- Gregor Weiss — Merck KGaA, Darmstadt, Germany
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MDFactory is a high-throughput library for setting up molecular dynamics (MD) si

- **System building** — Mixedbox, bilayer, and LNP build types from YAML or CSV input
- **Parametrization** — OpenFF/SMIRNOFF and CGenFF with automatic per-molecule caching
- **Batch processing** — CSV-driven Nextflow pipelines for parallel builds and GROMACS runs on HPC
- **Batch processing** — CSV-driven Parsl pipelines for parallel builds and GROMACS runs on HPC
- **Analysis** — Registered analysis and artifact types with parquet output, local or SLURM execution
- **Data integration** — Push/pull/sync across SQLite, CSV, and Palantir Foundry backends

Expand Down Expand Up @@ -83,7 +83,7 @@ pip install -e .[dev]
mdfactory build system.yaml simulation_dir
```

See the [Quick Start guide](https://emdgroup.github.io/mdfactory/docs/quick-start) for details on bulk CSV input and Nextflow pipelines.
See the [Quick Start guide](https://emdgroup.github.io/mdfactory/docs/quick-start) for details on bulk CSV input and running simulations.

## Configuration

Expand Down
21 changes: 19 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@ This folder contains the Fumadocs + Next.js application that renders the MDFacto
documentation. The site mixes hand-written guides with API pages generated straight from the
Python package.

## Prerequisites
## Quick start with pixi

The root `pyproject.toml` defines a `docs` environment that installs Bun, the JS
dependencies, and `fumapy-generate` automatically:

```bash
pixi run -e docs docs-dev # dev server with hot-reload
pixi run -e docs docs-build # full static build to docs/out/
pixi run -e docs docs-generate # regenerate API docs only
```

Each command chains through `docs-install` → `docs-fumapy` automatically, so a
single command handles all setup. On subsequent runs the dependency steps are
fast (no-op when already satisfied).

## Manual setup (without pixi)

### Prerequisites

- [Bun](https://bun.sh/) 1.0+ (fast JavaScript runtime and package manager)
- Python 3.11 (to install `mdfactory` and `fumapy`)
Expand All @@ -18,7 +35,7 @@ python3.11 -m pip install -e .. # expose the local packa
python3.11 -m pip install ./node_modules/fumadocs-python
```

## Commands
### Commands

```bash
bun run docs:generate # runs fumapy-generate + converts JSON into MDX
Expand Down
24 changes: 19 additions & 5 deletions docs/content/docs/developer-guide/architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ graph TD
flowchart LR
A[CSV or YAML inputs] --> B[prepare-build or build]
B --> C[Simulation directories]
C --> D[Local run or Nextflow]
C --> D[Local run or Parsl orchestration]
D --> E[Trajectory and output files]
E --> F[Simulation.run_analysis / run_artifact]
F --> G[.analysis parquet, artifacts, metadata.json]
Expand Down Expand Up @@ -164,12 +164,26 @@ For analysis and artifact sync, the code uses:

## Workflow orchestration

The repository contains Nextflow scripts under `workflows/`. The scripts that most directly align with the current CLI are:
The `mdfactory/orchestration/` package provides Parsl-based parallel orchestration for both building and simulating systems on local machines or SLURM clusters.

- `build.nf`
- `simulate.nf`
### Architecture layers

These scripts wrap the checked-in `mdfactory prepare-build` and `mdfactory build` commands plus a fixed GROMACS run chain.
```mermaid
graph TD
A[CLI: build --slurm / simulate --slurm] --> B[config.py: ExecutorConfig / SlurmExecutorConfig]
B --> C[session.py: parsl_session context manager]
C --> D[apps.py: Parsl python_app / bash_app definitions]
D --> E[stages.py: STAGE_REGISTRY + run_stage dispatch]
E --> F[build.py: build_systems / simulate.py: run_simulations]
F --> G[Rich progress UI + result collection]
```

- **`config.py`**: Pydantic models for local and SLURM execution. `ExecutorConfig` handles local runs; `SlurmExecutorConfig` adds SLURM-specific fields (account, partition, walltime, gres, per-stage overrides). Both serialize to/from YAML via `from_yaml()` and `model_dump()`.
- **`session.py`**: `parsl_session()` context manager that owns the Parsl DataFlowKernel lifecycle. On exit it calls `parsl.clear()` and explicitly `scancel`s any lingering SLURM job IDs.
- **`apps.py`**: Defines `get_build_app()` (python\_app for system building), `get_grompp_app()` and `get_mdrun_app()` (bash\_apps for GROMACS). Nearly all conditional logic (GPU, MPI, thread counts, restart flags) is resolved in Python before generating the bash script — the only permitted runtime branch is a small `if/elif/else/fi` block for binary detection when `gmx_binary` is set to `auto`.
- **`stages.py`**: `STAGE_REGISTRY` declares the canonical pipeline (EM → NVT → NPT → Production) as `StageSpec` dataclasses. `run_stage()` is the single generic dispatch function for all stages.
- **`build.py`** / **`simulate.py`**: Top-level entry points. `build_systems()` submits parallel build tasks; `run_simulations()` chains stages sequentially per simulation with checkpoint detection and trajectory validation.
- **`tui.py`**: Interactive SLURM configuration wizard using `questionary`. Auto-discovers cluster hardware via `sinfo`/`sacctmgr` and persists the result as a reusable YAML file.

## Extension points

Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MDFactory is an open source, end-to-end simulation manager for high-throughput m
/>

<FeatureCards>
<FeatureCard icon="layers" title="Batch Processing" description="CSV-driven: one row = one system. Run hundreds of systems in parallel via Nextflow on HPC." />
<FeatureCard icon="layers" title="Batch Processing" description="CSV-driven: one row = one system. Run hundreds of systems in parallel via Parsl on HPC." />
<FeatureCard icon="puzzle" title="Modular Pipeline" description="Pluggable build types (mixedbox, bilayer, LNP) with swappable force fields (OpenFF, CGenFF)." />
<FeatureCard icon="bar-chart" title="Analysis Framework" description="11+ registered analysis types with parquet + JSON metadata output and extensible registry." />
<FeatureCard icon="database" title="Data Integration" description="SQLite, CSV, and Palantir Foundry backends with intelligent push/pull/sync via CLI." />
Expand Down
26 changes: 13 additions & 13 deletions docs/content/docs/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,29 @@ This writes GROMACS-ready build output into `simulation_dir`.
</Step>
<Step>

## Run with Nextflow (optional)
## Run simulations (optional)

For high-throughput runs, use the checked-in workflows:
Run the GROMACS simulation chain (EM → NVT → NPT → Production) locally:

Build many systems from CSV:
```bash
mdfactory simulate output_systems/
```

For high-throughput runs on a SLURM cluster, generate a config interactively and pass it:

```bash
nextflow run workflows/build.nf \
--csv_file sample_input.csv \
--output_dir output_systems
mdfactory config slurm # interactive wizard → saves slurm_executor.yaml
mdfactory simulate output_systems/ --slurm slurm_executor.yaml
```

Run the GROMACS chain using the generated summary YAML:
Or use `--slurm tui` to launch the wizard inline:

```bash
nextflow run workflows/simulate.nf \
-c workflows/simulate.config \
--base_dir output_systems \
--config_yaml output_systems/sample_input.yaml
mdfactory simulate output_systems/ --slurm tui
```

<Callout type="warn" title="Cluster-specific configuration">
The shipped `simulate.config` contains SLURM settings tuned for a specific cluster. Edit this file to match your HPC environment before running. See [Running on HPC Clusters](/docs/user-guide/running-on-hpc) for details.
<Callout type="info" title="Parsl dependency">
SLURM orchestration requires the `parsl` extra: `pip install "mdfactory[parsl]"`. See [Running on HPC Clusters](/docs/user-guide/running-on-hpc) for details.
</Callout>

</Step>
Expand Down
87 changes: 85 additions & 2 deletions docs/content/docs/user-guide/cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ mdfactory prepare-build <input.csv> [output_dir]

### `mdfactory build`

Build one simulation from a YAML file into the chosen output directory.
Build MD system(s) from YAML, CSV, or summary input. Supports three input modes:

- **Single YAML**: builds one system locally
- **CSV file**: builds systems from each row (parallel with `--slurm`, sequential without)
- **Summary YAML**: dispatches builds for previously prepared systems

```bash
mdfactory build <input.yaml> [output_dir]
mdfactory build <input> [options]
```

Options:

- `--output` — output directory (default: `.`)
- `--slurm` — SLURM executor config: path to YAML file, or `'tui'` for interactive setup
- `--dry-run` — print what would be built without executing

### `mdfactory check-csv`

Validate a CSV by converting each row into a `BuildInput` model and, for bilayers, running the current buildability checks.
Expand All @@ -31,6 +41,79 @@ Validate a CSV by converting each row into a `BuildInput` model and, for bilayer
mdfactory check-csv <input.csv>
```

## Simulation commands

### `mdfactory simulate`

Run GROMACS MD simulations via Parsl. The simulation pipeline runs four stages by default: EM → NVT → NPT → Production.

```bash
mdfactory simulate <source> [options]
```

Options:

- `--slurm` — SLURM config YAML or `'tui'` for interactive setup
- `--stages` — stages to run (EM, NVT, NPT, Production); defaults to all
- `--checkpoint` — checkpoint mode: `auto` (default), `skip`, `force`
- `--hash` — filter by hash prefix (can specify multiple)
- `--dry-run` — preview plan without executing
- `--clean` — remove simulation outputs before running (respects `--stages` filter)
- `--max-rescue` — max rescue tiers for physics failures (default: 3; set to 0 to disable)

Usage examples:

```bash
# Local execution (all stages)
mdfactory simulate output_dir/

# SLURM with interactive config
mdfactory simulate output_dir/ --slurm tui

# Resume from checkpoint with existing config
mdfactory simulate output_dir/ --slurm gpu.yaml --checkpoint auto

# Equilibration only
mdfactory simulate output_dir/ --stages EM NVT NPT

# Filter specific simulations
mdfactory simulate output_dir/ --hash abc123 def456

# Dry-run preview
mdfactory simulate output_dir/ --slurm gpu.yaml --dry-run

# Clean outputs and re-run (e.g. after a killed job left stale checkpoints)
mdfactory simulate output_dir/ --clean --slurm gpu.yaml

# Clean only Production stage before re-running it
mdfactory simulate output_dir/ --clean --stages Production --slurm gpu.yaml

# Preview what --clean would delete without acting
mdfactory simulate output_dir/ --clean --dry-run
```

## Configuration commands

### `mdfactory config slurm`

Interactive wizard to configure a SLURM executor and save to YAML. Queries the local SLURM scheduler for available accounts, partitions, and hardware, then walks through resource selection interactively.

The result is saved to a YAML file that can be reused with `mdfactory build --slurm <file>` or `mdfactory simulate --slurm <file>`.

On non-SLURM machines, falls back to manual text entry.

```bash
mdfactory config slurm
```

### `mdfactory config cluster`

Show discovered SLURM cluster information. Queries the local SLURM scheduler and displays available partitions, accounts, and QOS policies. Useful for verifying autodiscovery before submitting jobs.

```bash
mdfactory config cluster [--json]
```

## Utility commands

### `mdfactory clean`
Expand Down
Loading
Loading