Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into custom_dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulPPelaez committed Nov 21, 2023
2 parents d359155 + 0275e54 commit 1287249
Show file tree
Hide file tree
Showing 52 changed files with 1,858 additions and 348 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ jobs:
- name: Run tests
run: pytest -v -s

- name: Test torchmd-train utility
run: torchmd-train --help

36 changes: 36 additions & 0 deletions .github/workflows/docs_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build Documentation

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"


jobs:
build-docs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Env
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
init-shell: bash
generate-run-shell: true

- name: Install docs dependencies
run: |
pip install -vv .
pip install -r docs/requirements.txt
shell: bash -el {0}

- name: Build Sphinx Documentation
run: |
cd docs
make html
shell: bash -el {0}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,11 @@ dmypy.json

# temp directories
logs/

# Docs
docs/build/
docs/source/generated

# Extra

*~
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"

build:
os: "ubuntu-22.04"
tools:
python: "mambaforge-22.9"
jobs:
post_create_environment:
- pip install -r docs/requirements.txt
- pip install .

conda:
environment: environment.yml


sphinx:
configuration: docs/source/conf.py
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![CI](https://github.com/torchmd/torchmd-net/actions/workflows/CI.yml/badge.svg)](https://github.com/torchmd/torchmd-net/actions/workflows/CI.yml)
[![Documentation Status](https://readthedocs.org/projects/torchmd-net/badge/?version=latest)](https://torchmd-net.readthedocs.io/en/latest/?badge=latest)

# TorchMD-NET

TorchMD-NET provides state-of-the-art neural networks potentials (NNPs) and a mechanism to train them. It offers efficient and fast implementations if several NNPs and it is integrated in GPU-accelerated molecular dynamics code like [ACEMD](https://www.acellera.com/products/molecular-dynamics-software-gpu-acemd/), [OpenMM](https://www.openmm.org) and [TorchMD](https://github.com/torchmd/torchmd). TorchMD-NET exposes its NNPs as [PyTorch](https://pytorch.org) modules.


## Documentation

Documentation is available at https://torchmd-net.readthedocs.io

## Available architectures

- [Equivariant Transformer (ET)](https://arxiv.org/abs/2202.02541)
Expand All @@ -13,15 +19,23 @@ TorchMD-NET provides state-of-the-art neural networks potentials (NNPs) and a me
- [TensorNet](https://arxiv.org/abs/2306.06482)


## Installation

## Installation
TorchMD-Net is available in [conda-forge](https://conda-forge.org/) and can be installed with:
```shell
mamba install torchmd-net
```
We recommend using [Mamba](https://github.com/conda-forge/miniforge/#mambaforge) instead of conda.

### Install from source

1. Clone the repository:
```shell
git clone https://github.com/torchmd/torchmd-net.git
cd torchmd-net
```

2. Install [Mambaforge](https://github.com/conda-forge/miniforge/#mambaforge). We recommend to use `mamba` rather than `conda`.
2. Install the dependencies in environment.yml. You can do it via pip, but we recommend [Mambaforge](https://github.com/conda-forge/miniforge/#mambaforge) instead.

3. Create an environment and activate it:
```shell
Expand All @@ -36,6 +50,23 @@ TorchMD-NET provides state-of-the-art neural networks potentials (NNPs) and a me
This will install TorchMD-NET in editable mode, so that changes to the source code are immediately available.
Besides making all python utilities available environment-wide, this will also install the `torchmd-train` command line utility.


#### CUDA enabled installation

Besides the dependencies listed in the environment file, you will also need the CUDA `nvcc` compiler suite to build TorchMD-Net.
If your system lacks nvcc you may install it via conda-forge:
```shell
mamba install cudatoolkit-dev
```
Or from the nvidia channel:
```shell
mamba install -c nvidia cuda-nvcc cuda-cudart-dev cuda-libraries-dev
```
Make sure you install a major version compatible with your torch installation, which you can check with:
```shell
python -c "import torch; print(torch.version.cuda)"
```

## Usage
Specifying training arguments can either be done via a configuration yaml file or through command line arguments directly. Several examples of architectural and training specifications for some models and datasets can be found in [examples/](https://github.com/torchmd/torchmd-net/tree/main/examples). Note that if a parameter is present both in the yaml file and the command line, the command line version takes precedence.
GPUs can be selected by setting the `CUDA_VISIBLE_DEVICES` environment variable. Otherwise, the argument `--ngpus` can be used to select the number of GPUs to train on (-1, the default, uses all available GPUs or the ones specified in `CUDA_VISIBLE_DEVICES`). Keep in mind that the [GPU ID reported by nvidia-smi might not be the same as the one `CUDA_VISIBLE_DEVICES` uses](https://stackoverflow.com/questions/26123252/inconsistency-of-ids-between-nvidia-smi-l-and-cudevicegetname).
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
59 changes: 59 additions & 0 deletions docs/_static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@import 'theme.css';

.rst-content dl:not(.docutils) dt:first-child {
margin-top: 0;
}

.rst-content dl:not(.docutils) dl dt {
margin-bottom: 4px;
border: none;
border-left: solid 3px #ccc;
background: #f0f0f0;
color: #555;
}

.rst-content dl table,
.rst-content dl ul,
.rst-content dl ol,
.rst-content dl p {
margin-bottom: 8px !important;
}

.rst-content dl:not(.docutils) dt {
display: table;
margin: 6px 0;
font-size: 90%;
line-height: normal;
background: #e7f2fa;
color: #2980B9;
border-top: solid 3px #6ab0de;
padding: 6px;
position: relative;
}

html.writer-html5 .rst-content dl.field-list {
display: initial;
}

html.writer-html5 .rst-content dl.field-list>dd,
html.writer-html5 .rst-content dl.field-list>dt {
margin-bottom: 4px;
padding-left: 6px;
}

p {
line-height: 20px;
font-size: 14px;
}

html.writer-html5 .rst-content dl.field-list>dt:after {
content: initial;
}

dt.field-even {
text-transform: uppercase;
}

dt.field-odd {
text-transform: uppercase;
}
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx==7.2.6
sphinx-rtd-theme==1.3.0
sphinxcontrib-autoprogram==0.1.8
sphinxcontrib-napoleon==0.7
gitpython
10 changes: 10 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
API Reference
=============

.. autosummary::
:toctree: generated
:recursive:

torchmdnet


88 changes: 88 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Configuration file for the Sphinx documentation builder.

# -- Project information
project = "TorchMD-Net"
author = "RaulPPelaez"

import git


def get_latest_git_tag(repo_path="."):
repo = git.Repo(repo_path)
tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)
return tags[-1].name if tags else None


current_tag = get_latest_git_tag("../../")
if current_tag is None:
current_tag = "master"
release = current_tag
version = current_tag

# -- General configuration
extensions = [
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinxcontrib.autoprogram",
]
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_admonition_for_references = True
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_preprocess_types = True
napoleon_type_aliases = None
napoleon_attr_annotations = True
autosummary_ignore_module_all = False

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"torch": ("https://pytorch.org/docs/stable/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
}
intersphinx_disabled_domains = ["std"]

templates_path = ["_templates"]

# -- Options for HTML output

html_theme = "sphinx_rtd_theme"

# -- Options for EPUB output
epub_show_urls = "footnote"

autoclass_content = "both"
autodoc_typehints = "none"
autodoc_inherit_docstrings = False
sphinx_autodoc_typehints = True
html_show_sourcelink = True
autodoc_default_options = {
"members": True,
"member-order": "bysource",
"exclude-members": "__weakref__",
"undoc-members": False,
"show-inheritance": True,
"inherited-members": False,
}
# Exclude all torchmdnet.datasets.*.rst files in source/generated/
exclude_patterns = [
"generated/torchmdnet.datasets.*.rst",
"generated/torchmdnet.scripts.*rst",
]
html_static_path = ["../_static"]
html_css_files = [
"style.css",
]

autodoc_mock_imports = ["torchmdnet.extensions.torchmdnet_extensions"]
Loading

0 comments on commit 1287249

Please sign in to comment.