molforge.versions¶
versions ¶
One place to ask what is installed here.
:class:~molforge.core.provenance.Provenance answers "what produced this
output", but it can only record a version the wrapper managed to read at
the time. Wrappers that shell out to a native binary — fpocket, P2Rank,
GROMACS, sander, gnina — record no version at all, so a manifest
covering them has blanks exactly where a reader most wants a number. And
there is no way to ask the question before a run, which is what you need
when one output is going to be attributed to thousands of predictions.
This module is that question, answered once::
>>> from molforge import engine_versions
>>> backends = engine_versions() # doctest: +SKIP
>>> backends["OpenMM"].version # doctest: +SKIP
'8.1.1'
>>> [b.name for b in backends.values() if b.available] # doctest: +SKIP
['OpenMM', 'RDKit', 'NumPy', 'molforge']
Three kinds of backend, because they fail to have a version for three different reasons and a manifest should not conflate them:
python
A pip/conda distribution. Read from :mod:importlib.metadata — free,
exact, no subprocess.
executable
A native binary found on $PATH. Presence comes from
:func:shutil.which; the version, where the tool exposes one, comes
from running it with a known flag. Some of these tools ship no version
flag at all (fpocket, tleap), so they report available=True with
an empty version and a :attr:~BackendVersion.detail saying why. That
is a different fact from "not installed", and it is recorded as one.
repo
Run from a checkout the caller points at (RoseTTAFold, DiffDock,
ProteinMPNN, RFdiffusion take a repo_dir). There is nothing global
to inspect, so molforge cannot detect these at all and says so rather
than reporting a confident False.
Nothing here raises. A backend that cannot be inspected reports
available=False and an empty version — the registry's whole job is to
be safe to call on any machine, including one with none of this installed.
See also
:func:molforge.wrappers._versions.engine_version, the per-wrapper
lookup this builds on, and
:func:molforge.wrappers._versions.check_engine_version, which warns
when a wrapper's parser is outside its tested range.
BackendVersion
dataclass
¶
BackendVersion(
name: str,
category: str,
kind: str,
requirement: str,
available: bool,
version: str = "",
location: str = "",
detail: str = "",
)
What molforge can determine about one engine or backend.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
molforge's name for the backend, matching the |
category |
str
|
Which part of molforge drives it — |
kind |
str
|
|
requirement |
str
|
What was looked for: the distribution name that
resolved, or the executable name searched for on |
available |
bool
|
Whether molforge can find this backend right now.
Always |
version |
str
|
The detected version, or |
location |
str
|
Resolved path for an |
detail |
str
|
Plain-language reason :attr: |
to_dict ¶
Convert to a JSON-serialisable plain dict.
Keys with nothing to say (location, detail) are omitted so
an embedded manifest block stays readable.
engine_versions ¶
engine_versions(
*,
category: str | None = None,
probe_executables: bool = True,
timeout: float = DEFAULT_PROBE_TIMEOUT,
refresh: bool = False,
) -> dict[str, BackendVersion]
Report every engine and backend molforge knows how to drive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str | None
|
Return only this category ( |
None
|
probe_executables
|
bool
|
Run each installed native binary's version flag.
|
True
|
timeout
|
float
|
Seconds to wait for one probe. A tool that exceeds it is reported as available with no version, never as an error. |
DEFAULT_PROBE_TIMEOUT
|
refresh
|
bool
|
Re-probe instead of reusing the memoized sweep. The result is cached because the answer only changes when something is installed, and a caller emitting one manifest per output would otherwise re-run every binary on the machine. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, BackendVersion]
|
class: |
dict[str, BackendVersion]
|
attr: |
dict[str, BackendVersion]
|
backend appears, installed or not — an absent engine is a fact |
dict[str, BackendVersion]
|
about the environment worth recording. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
from molforge import engine_versions md = engine_versions(category="md", probe_executables=False) sorted(md) ['AMBER', 'GROMACS', 'OpenMM', 'tleap']