diff --git a/MANIFEST.in b/MANIFEST.in index 6abcd1e3b..c373117d0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,14 @@ -include pyproject.toml +graft src + include LICENSE -include VERSION +include README.md + +prune docs +prune tests +prune .github +prune .tox + +exclude .gitignore +exclude tox.ini + +global-exclude *.py[cod] __pycache__/* *.so *.dylib diff --git a/VERSION b/VERSION deleted file mode 100644 index 6e8bf73aa..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.1.0 diff --git a/metatensor_models/__init__.py b/bin/__init__.py similarity index 100% rename from metatensor_models/__init__.py rename to bin/__init__.py diff --git a/bin/eval-metatensor-model.py b/bin/eval-metatensor-model.py new file mode 100644 index 000000000..eacb83ed3 --- /dev/null +++ b/bin/eval-metatensor-model.py @@ -0,0 +1 @@ +print("eval") diff --git a/bin/export-metatensor-model.py b/bin/export-metatensor-model.py new file mode 100644 index 000000000..ed7570b13 --- /dev/null +++ b/bin/export-metatensor-model.py @@ -0,0 +1 @@ +print("export") diff --git a/bin/train-metatensor-model.py b/bin/train-metatensor-model.py new file mode 100644 index 000000000..c859094af --- /dev/null +++ b/bin/train-metatensor-model.py @@ -0,0 +1 @@ +print("train") diff --git a/metatensor_models/kernel/__init__.py b/metatensor_models/kernel/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/kernel/example/__init__.py b/metatensor_models/kernel/example/__init__.py deleted file mode 100644 index 8a0ea15fc..000000000 --- a/metatensor_models/kernel/example/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .example import Example # noqa: F401 diff --git a/metatensor_models/kernel/example/example.py b/metatensor_models/kernel/example/example.py deleted file mode 100644 index 7caf4c566..000000000 --- a/metatensor_models/kernel/example/example.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Dict, List, Tuple - -from metatensor.torch import TensorMap - -from ..kernel import KernelModel - - -class Example(KernelModel): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - super(Example, self).__init__(equivariant_selection, hypers) - - def forward(self, systems: TensorMap): - return systems - - def compute_kernels(self, systems: TensorMap): - return systems diff --git a/metatensor_models/kernel/example/train_example.py b/metatensor_models/kernel/example/train_example.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/kernel/kernel.py b/metatensor_models/kernel/kernel.py deleted file mode 100644 index bcd60461e..000000000 --- a/metatensor_models/kernel/kernel.py +++ /dev/null @@ -1,31 +0,0 @@ -import abc -from typing import Dict, List, Tuple - -import torch -from metatensor.torch import TensorMap # , System - - -class KernelModel(torch.nn.Module, abc.ABC): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - """ - The initialization function. This takes as arguments `equivariant_selection`, - i.e. a list of (lambda, sigma) tuples that indicate the symmetry of the - targets with respect to rotation and inversion, as well as the hypers of the - model as a dictionary. These hypers are model-specific. - """ - super(KernelModel, self).__init__() - self.regression_coefficients = torch.empty(()) - - @abc.abstractmethod - def forward(self, systems: TensorMap) -> TensorMap: - """ - The forward function of the linear model. - """ - pass - - @abc.abstractmethod - def compute_kernels(self, systems: TensorMap) -> TensorMap: - """ - A function that computes the kernels of the model. - """ - pass diff --git a/metatensor_models/linear/__init__.py b/metatensor_models/linear/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/linear/example/__init__.py b/metatensor_models/linear/example/__init__.py deleted file mode 100644 index 8a0ea15fc..000000000 --- a/metatensor_models/linear/example/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .example import Example # noqa: F401 diff --git a/metatensor_models/linear/example/example.py b/metatensor_models/linear/example/example.py deleted file mode 100644 index 738805a68..000000000 --- a/metatensor_models/linear/example/example.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Dict, List, Tuple - -from metatensor.torch import TensorMap - -from ..linear import LinearModel - - -class Example(LinearModel): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - super(Example, self).__init__(equivariant_selection, hypers) - - def forward(self, systems: TensorMap): - return systems - - def compute_features(self, systems: TensorMap): - return systems diff --git a/metatensor_models/linear/example/train_example.py b/metatensor_models/linear/example/train_example.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/linear/linear.py b/metatensor_models/linear/linear.py deleted file mode 100644 index 1a7aa336d..000000000 --- a/metatensor_models/linear/linear.py +++ /dev/null @@ -1,31 +0,0 @@ -import abc -from typing import Dict, List, Tuple - -import torch -from metatensor.torch import TensorMap # , System - - -class LinearModel(torch.nn.Module, abc.ABC): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - """ - The initialization function. This takes as arguments `equivariant_selection`, - i.e. a list of (lambda, sigma) tuples that indicate the symmetry of the - targets with respect to rotation and inversion, as well as the hypers of the - model as a dictionary. These hypers are model-specific. - """ - super(LinearModel, self).__init__() - self.regression_coefficients = torch.empty(()) - - @abc.abstractmethod - def forward(self, systems: TensorMap) -> TensorMap: - """ - The forward function of the linear model. - """ - pass - - @abc.abstractmethod - def compute_features(self, TensorMap) -> TensorMap: - """ - A function that computes the features of the linear model. - """ - pass diff --git a/metatensor_models/nn/__init__.py b/metatensor_models/nn/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/nn/example/__init__.py b/metatensor_models/nn/example/__init__.py deleted file mode 100644 index 8a0ea15fc..000000000 --- a/metatensor_models/nn/example/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .example import Example # noqa: F401 diff --git a/metatensor_models/nn/example/example.py b/metatensor_models/nn/example/example.py deleted file mode 100644 index 77b2de7f1..000000000 --- a/metatensor_models/nn/example/example.py +++ /dev/null @@ -1,16 +0,0 @@ -from typing import Dict, List, Tuple - -from metatensor.torch import TensorMap - -from ..nn import NNModel - - -class Example(NNModel): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - super(Example, self).__init__(equivariant_selection, hypers) - - def forward(self, systems: TensorMap): - return systems - - def compute_kernels(self, systems: TensorMap): - return systems diff --git a/metatensor_models/nn/example/train_example.py b/metatensor_models/nn/example/train_example.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/metatensor_models/nn/nn.py b/metatensor_models/nn/nn.py deleted file mode 100644 index 1e4ec6b0c..000000000 --- a/metatensor_models/nn/nn.py +++ /dev/null @@ -1,23 +0,0 @@ -import abc -from typing import Dict, List, Tuple - -import torch -from metatensor.torch import TensorMap # , System - - -class NNModel(torch.nn.Module, abc.ABC): - def __init__(self, equivariant_selection: List[Tuple[int, int]], hypers: Dict): - """ - The initialization function. This takes as arguments `equivariant_selection`, - i.e. a list of (lambda, sigma) tuples that indicate the symmetry of the - targets with respect to rotation and inversion, as well as the hypers of the - model as a dictionary. These hypers are model-specific. - """ - super(NNModel, self).__init__() - - @abc.abstractmethod - def forward(self, systems: TensorMap) -> TensorMap: - """ - The forward function of the NN model, which computes its predictions. - """ - pass diff --git a/pyproject.toml b/pyproject.toml index 3ca9dff38..ca20272f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "metatensor-models" +name = "metatensor_models" dynamic = ["version"] requires-python = ">=3.7" @@ -11,6 +11,7 @@ authors = [ ] dependencies = [ + "ase", "torch", "metatensor-core", "metatensor-torch" @@ -40,15 +41,46 @@ classifiers = [ repository = "https://github.com/lab-cosmo/metatensor-models" # changelog = "TODO" +[project.scripts] +maicos = "maicos.__main__:main" + ### ======================================================================== ### [build-system] requires = [ - "setuptools >=68", + "setuptools >= 68", + "wheel", ] build-backend = "setuptools.build_meta" -### ======================================================================== ### +[project.optional-dependencies] +soap-bpnn = [ + "rascaline-torch @ git+https://github.com/luthaf/rascaline#subdirectory=python/rascaline-torch", +] + +[tool.setuptools.packages.find] +where = ["src", "bin"] + +[tool.setuptools.dynamic] +version = {attr = "metatensor_models.__version__"} + +[tool.coverage.report] +include = [ + "src/metatensor_models/*" +] + +[tool.coverage.xml] +output = 'tests/coverage.xml' + [tool.pytest.ini_options] python_files = ["*.py"] testpaths = ["tests"] + +[tool.isort] +skip = "__init__.py" +profile = "black" +line_length = 88 +indent = 4 +include_trailing_comma = true +lines_after_imports = 2 +known_first_party = "metatensor_models" diff --git a/setup.py b/setup.py deleted file mode 100644 index eca11a646..000000000 --- a/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -import os - -from setuptools import find_packages, setup - -ROOT = os.path.realpath(os.path.dirname(__file__)) - - -if __name__ == "__main__": - with open(os.path.join(ROOT, "VERSION")) as fd: - version = fd.read().strip() - - setup(version=version, packages=find_packages()) diff --git a/src/metatensor_models/__init__.py b/src/metatensor_models/__init__.py new file mode 100644 index 000000000..e728ace74 --- /dev/null +++ b/src/metatensor_models/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.0-dev" diff --git a/tests/init.py b/tests/init.py new file mode 100644 index 000000000..e4a2c3cc2 --- /dev/null +++ b/tests/init.py @@ -0,0 +1,5 @@ +import metatensor_models + + +def test_version_exists(): + metatensor_models.__version__ diff --git a/tests/test_kernel.py b/tests/test_kernel.py deleted file mode 100644 index 83600e829..000000000 --- a/tests/test_kernel.py +++ /dev/null @@ -1,18 +0,0 @@ -import torch -from metatensor.torch import Labels, TensorBlock, TensorMap -from metatensor_models.kernel.example import Example - - -def test_output(): - tensor_map = TensorMap( - Labels.empty("_"), - [] - ) - example = Example(equivariant_selection=[(0, 1)], hypers={}) - output = example(tensor_map) - assert isinstance(output, torch.ScriptObject) - - -def test_jit_script(): - example = Example(equivariant_selection=[(0, 1)], hypers={}) - torch.jit.script(example) diff --git a/tests/test_linear.py b/tests/test_linear.py deleted file mode 100644 index 88c193239..000000000 --- a/tests/test_linear.py +++ /dev/null @@ -1,18 +0,0 @@ -import torch -from metatensor.torch import Labels, TensorBlock, TensorMap -from metatensor_models.linear.example import Example - - -def test_output(): - tensor_map = TensorMap( - Labels.empty("_"), - [] - ) - example = Example(equivariant_selection=[(0, 1)], hypers={}) - output = example(tensor_map) - assert isinstance(output, torch.ScriptObject) - - -def test_jit_script(): - example = Example(equivariant_selection=[(0, 1)], hypers={}) - torch.jit.script(example) diff --git a/tests/test_nn.py b/tests/test_nn.py deleted file mode 100644 index 7f4015ff3..000000000 --- a/tests/test_nn.py +++ /dev/null @@ -1,18 +0,0 @@ -import torch -from metatensor.torch import Labels, TensorBlock, TensorMap -from metatensor_models.nn.example import Example - - -def test_output(): - tensor_map = TensorMap( - Labels.empty("_"), - [] - ) - example = Example(equivariant_selection=[(0, 1)], hypers={}) - output = example(tensor_map) - assert isinstance(output, torch.ScriptObject) - - -def test_example(): - example = Example(equivariant_selection=[(0, 1)], hypers={}) - torch.jit.script(example) diff --git a/tox.ini b/tox.ini index 65ab3e450..8bbd6cd36 100644 --- a/tox.ini +++ b/tox.ini @@ -4,11 +4,12 @@ min_version = 4.0 # execute `tox` in the command-line without anything else envlist = lint - python-tests + build + tests [testenv] passenv = * -lint_folders = "{toxinidir}/metatensor_models" "{toxinidir}/setup.py" +lint_folders = "{toxinidir}/src" [testenv:lint] # this environement lints the Python code with flake8 (code linter), black (code @@ -41,7 +42,8 @@ commands = black {[testenv]lint_folders} blackdoc {[testenv]lint_folders} -[testenv:python-tests] +[testenv:tests] +description = Run basic package tests with pytest (not the architectures) passenv = * deps = pytest @@ -49,6 +51,14 @@ deps = commands = pytest --import-mode=append {posargs} +[testenv:soap-bpnn] +passenv = * +deps = + pytest + +commands = + echo "success" + [testenv:build-python] # this environement makes sure one can build sdist and wheels for Python deps = @@ -56,19 +66,19 @@ deps = wheel cmake twine + build allowlist_externals = bash commands = # check building sdist and wheels from a checkout - python setup.py sdist - python setup.py bdist_wheel + python -m build twine check dist/*.tar.gz twine check dist/*.whl # check building wheels from the sdist - bash -c "python -m pip wheel --verbose dist/metatensor-models-*.tar.gz -w dist/test" + bash -c "python -m pip wheel --verbose dist/metatensor_models-*.tar.gz -w dist/test" [flake8] # longer lines for compatibility with other linters