Skip to content
MolCraftsPublic

About

AI-assisted workflow management and knowledge system for computational research

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

 molab

A scientific-workflow platform for FAIR research

test Python 3.12+ License Ruff

Documentation  ·  Quick start  ·  Ecosystem

molab turns a Python script of typed tasks into a tracked, reproducible experiment. It pairs a content-hashed workflow engine with a file-system-backed Workspace → Project → Experiment → Run hierarchy, profile-driven run variants, and optional cluster submission — then adds a knowledge layer that writes findings, reports and notes beside the runs they describe, and a FastAPI server with a bundled React UI.

In the web UI, knowledge files are browsed under Workspace → Project → Experiment. Select a project in the explorer to open its Relations editor tab; Relations previews that project's documents plus their connected workspace knowledge (plans, hypotheses and references), while retaining the file browser. The Files explorer also offers Open Relations, and a project page has a Relations action. Select a document in the relation map for its excerpt and references; open the document to return to its page. The map preserves Tack's paper grid, class-specific node shapes, typed arrows, floating status card and document preview. References are visible on first open; Fold references hides secondary links and selecting either endpoint reveals them. Trace lineage highlights a selected document's transitive origins and downstream consumers. The preview lists Origins and Used by with shortest-path step counts; only derived_from and supersedes imply provenance, while evidence and citations retain their separate roles. The Show lineage action on a project research document opens its Relations tab with that document selected. The offline NVE showcase includes a synthetic plan → observation → findings → report chain, conflicting evidence, an external citation, an asset/run source and a missing reference. Tack's execution controls and its existing research entry point remain in Tack.

Under active development. Public APIs may change between minor releases.

Vision

Research computation is rarely a single program — it is the same idea run many times, with different parameters, on different machines, until something works. The artifacts of that effort usually scatter: a script in one place, its outputs in another, the parameters in a notebook, the "which run was the good one" in someone's memory. molab exists to close that gap, so the definition of an experiment and the record of every execution are one connected object instead of folklore.

It aspires to make reproducibility the default rather than a discipline. You write ordinary typed Python; molab captures the workflow's content hash, the resolved configuration, the artifacts, the errors, and the execution history, and writes them down atomically as the run happens. The same workflow runs locally for a smoke test and on a cluster for the real thing, without changing the science — only where the worker process launches.

What that unlocks is a research workflow you can trust and revisit: experiments that re-run exactly, runs that can be compared and resumed, and a workspace that stays browsable — from the CLI or a web UI — long after the original author has moved on.

Capabilities

Module Capability
molab.workflow Task graph — write steps on Workflow, run them with wf.run(), freeze a digest with wf.compile(). A tracked run takes the same object (run.execute(wf))
molab.workspace File-system storage primitive — Workspace → Project → Experiment → Run Folder hierarchy, content-addressed assets, atomic JSON I/O, run lifecycle
molab.config In-code process-global config — a live molcfg.Config kept as a process-level place to register runtime values in code (never from env)
molab.profile File-based per-run config — molcfg.yaml loading and named profiles; resolves defaults + profiles into an immutable, content-hashed ProfileConfig
molab.services Application-service layer between the shells and the domain layers — operator_config (read / write ~/.molab/config.json), auth. CLI and server both call it and never each other, so a Python operation and a UI operation share one code path
molab.knowledge Knowledge documents (knowledges/<slug>.md, path is identity) and the @concept_type registry — sits above workspace and reaches it only through function-body imports
molab.server FastAPI app — REST routes for workspace, projects, experiments, runs, assets, execution, plus SSE streaming and bundled-SPA serving
molab.cli molab command-line entry point — workspace init/info, run/execute, project / experiment / run / asset / target / session subcommands
molab.plugins On-demand capability registry — submit_molq scheduler bridge (SLURM / PBS / LSF) and gh GitHub client; core stays dependency-light
molab.git Thin async wrappers over the git binary — ensure_clone / fetch / push and GitWorktreeManager for per-experiment working dirs
apps/web/ React 19 + Rsbuild three-panel web client — navigation tree, entity viewers, inspector; compiled ahead of time and bundled into the wheel
apps/vsc-ext/ VS Code workflow-preview extension — reuses the web workflow canvas components

Install

Distribution name on PyPI will be molcrafts-molab (CLI / import: molab). Until the first publish, install from GitHub:

pip install "git+https://github.com/MolCrafts/molab"
# or, with uv
uv pip install "git+https://github.com/MolCrafts/molab"

Agents and their hooks call the molab command (molab check, molab knowledge write, molab runs adopt), so put it on PATH as a tool, not only inside a project environment:

uv tool install "git+https://github.com/MolCrafts/molab"      # or, from a checkout:
uv tool install --editable /path/to/molab

Workspace metadata uses .molab/; user configuration is stored under ~/.molab/.

Requires Python >= 3.12. Core depends on pydantic, pyyaml, typer, rich, fastapi, uvicorn, zarr, and the MolCrafts libraries mollog, molcfg, molq, and molpy (the workflow engine is self-owned — pydantic-graph is no longer a dependency). Optional extras: molcrafts-molab[molvis] molvis snapshots, headless included; molcrafts-molab[all] bundles the optional extras, and molcrafts-molab[dev] pulls everything for development.

Default uv pip / pip does not compile the React UI (no Node required). A published wheel already ships src/molab/dist/.

Serve the UI

Three jobs — do not mix them. Full table: Serve and rebuild the UI.

Job Command Open
Daily checkout (HMR) uv pip install -e ".[dev]" once, then molab serve ./lab --dev printed Dev UI (:5173)
Bundled SPA preview npm run build:web then molab serve ./lab :8000
Wheel with UI uv pip install . -C build-web=true then molab serve on :8000

--dev starts npm run dev:api (real /api proxy). npm run dev:web is the MSW mock, not that path. After npm run build:web on an editable install, do not reinstall Python. The old flag -C build-ui=true is rejected.

Quick start

from molab.workflow import Workflow

wf = Workflow(name="demo")


@wf.task
async def fetch() -> list[float]:
    return [1.0, 4.0, 9.0]


# A task receives an upstream's output by naming a parameter after that task —
# ``reduce`` binds ``fetch``'s output to its ``fetch`` argument (there is no
# ``ctx.inputs``: inputs are plain named parameters).
@wf.task(depends_on=["fetch"])
async def reduce(fetch: list[float]) -> float:
    return sum(fetch)


result = wf.run()
print(result.outputs)  # {'fetch': [1.0, 4.0, 9.0], 'reduce': 14.0}

Attaching a workflow to a tracked Workspace experiment (ws.add_project(...).add_experiment(...).define(wf, params=...)), running it with molcfg profiles via molab run, and submitting to a cluster are covered in the docs.

Documentation

  • Getting Started — runnable first workflow, tracked runs, CLI and profiles
  • Concepts — the workflow / workspace / plugin mental model
  • Guide — task & actor authoring, runtime, assets, server, molq
  • Architecture — layer boundaries the code preserves
  • Development — serve/rebuild the UI, compiler internals, task protocols

MolCrafts ecosystem

Project Role
molpy Python toolkit — the shared molecular data model & workflow layer
molrs Rust core — molecular data structures & compute kernels (native + WASM)
molpack Packmol-grade molecular packing (Rust + Python)
molvis WebGL molecular visualization & editing
molab Scientific-workflow platform for FAIR research — this repo
molnex Molecular machine-learning framework
molq Unified job queue — local / SLURM / PBS / LSF
molcfg Layered configuration library
mollog Structured logging, stdlib-compatible
molhub Molecular dataset hub
molrec Atomistic record specification

Contributing

Contributions are welcome — see the development docs (including serve and rebuild the UI) to get started.

License

BSD-3-Clause — see LICENSE.


Crafted with 💚 by MolCrafts

About

AI-assisted workflow management and knowledge system for computational research

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages