Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements to dev tools & documentation #244

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 26 additions & 7 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,29 @@ Github CI workflows.
You can also run only a subset of tests with one of these commands:

- ``cargo test`` runs everything
- ``cargo test --test=<test-name>`` to run only the tests in ``tests/<test-name>.rs``;
- ``cargo test --test=python-api`` (or ``tox`` directly) to run Python tests only;
- ``cargo test --test=c-api`` to run the C API tests only;
- ``cargo test --package=rascaline`` to run the calculators tests;
- ``cargo test --package=rascaline-c-api`` to run the C/C++ tests only;

- ``cargo test --test=run-cxx-tests`` will run the unit tests for the C/C++
API. If `valgrind`_ is installed, it will be used to check for memory
errors. You can disable this by setting the `RASCALINE_DISABLE_VALGRIND`
environment variable to 1 (`export RASCALINE_DISABLE_VALGRIND=1` for most
Linux/macOS shells);
- ``cargo test --test=check-cxx-install`` will build the C/C++ interfaces,
install them and the associated CMake files and then try to build a basic
project depending on this interface with CMake;

- ``cargo test --package=rascaline-torch`` to run the C++ TorchScript extension
tests only;

- ``cargo test --test=run-torch-tests`` will run the unit tests for the
TorchScript C++ extension;
- ``cargo test --test=check-cxx-install`` will build the C++ TorchScript
extension, install it and then try to build a basic project depending on
this extension with CMake;

- ``cargo test --package=rascaline-python`` (or ``tox`` directly, see below) to
run Python tests only;
- ``cargo test --lib`` to run unit tests;
- ``cargo test --doc`` to run documentation tests;
- ``cargo bench --test`` compiles and run the benchmarks once, to quickly ensure
Expand All @@ -135,10 +155,8 @@ You can add some flags to any of above commands to further refine which tests
should run:

- ``--release`` to run tests in release mode (default is to run tests in debug mode)
- ``-- <filter>`` to only run tests whose name contains filter, for example ``cargo test -- spherical_harmonics``
- ``--package rascaline`` to run tests defined in the rascaline crate (the core implementation)
- ``--package rascaline-c-api`` to run tests defined in the rascaline-c-api
crate (the C API implementation)
- ``-- <filter>`` to only run tests whose name contains filter, for example
``cargo test -- spherical_harmonics``

Also, you can run individual python tests using `tox`_
if you wish to test only specific functionalities, for example:
Expand All @@ -156,6 +174,7 @@ The latter command ``tox -e format`` will use tox to do actual formatting instea
of just testing it.

.. _`cargo` : https://doc.rust-lang.org/cargo/
.. _valgrind: https://valgrind.org/

Writing your own calculator
---------------------------
Expand Down
29 changes: 28 additions & 1 deletion docs/src/get-started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,33 @@ install using `rustup <https://rustup.rs/>`_ or your OS package manager.
Installing the Python module
----------------------------

For building and using the Python package, clone the repository using `git
<https://git-scm.com>`_ and install rascaline using `pip
<https://pip.pypa.io>`_.

From source:

.. code-block:: bash

# Make sure you are using the latest version of pip
pip install --upgrade pip

git clone https://github.com/Luthaf/rascaline
cd rascaline
pip install .

# alternatively, the same thing in a single command
pip install git+https://github.com/Luthaf/rascaline


Rascaline is also provided as prebuilt wheel which avoids the intermediate step
of building the package with a Rust compiler from the source code.

.. code-block:: bash

pip install git+https://github.com/Luthaf/rascaline.git
pip install --upgrade pip
pip install --extra-index-url https://luthaf.fr/temporary-wheels/ rascaline


.. _install-c-lib:

Expand Down Expand Up @@ -96,6 +120,9 @@ Building from source:
cd rascaline/python/rascaline-torch
pip install .

# Make sure you are using the latest version of pip
pip install --upgrade pip

# alternatively, the same thing in a single command
pip install git+https://github.com/luthaf/rascaline#subdirectory=python/rascaline-torch

Expand Down
14 changes: 8 additions & 6 deletions rascaline-c-api/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ target_link_libraries(tests_helpers rascaline::shared)

find_program(VALGRIND valgrind)
if (VALGRIND)
message(STATUS "Running tests using valgrind")
set(TEST_COMMAND
"${VALGRIND}" "--tool=memcheck" "--dsymutil=yes" "--error-exitcode=125"
"--leak-check=full" "--show-leak-kinds=definite,indirect,possible" "--track-origins=yes"
"--suppressions=${CMAKE_CURRENT_SOURCE_DIR}/valgrind.supp" "--gen-suppressions=all"
)
if (NOT "$ENV{RASCALINE_DISABLE_VALGRIND}" EQUAL "1")
message(STATUS "Running tests using valgrind")
set(TEST_COMMAND
"${VALGRIND}" "--tool=memcheck" "--dsymutil=yes" "--error-exitcode=125"
"--leak-check=full" "--show-leak-kinds=definite,indirect,possible" "--track-origins=yes"
"--suppressions=${CMAKE_CURRENT_SOURCE_DIR}/valgrind.supp" "--gen-suppressions=all"
)
endif()
else()
set(TEST_COMMAND "")
endif()
Expand Down
2 changes: 1 addition & 1 deletion rascaline-torch/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target_link_libraries(catch torch)

find_program(VALGRIND valgrind)
if (VALGRIND)
if (NOT "$ENV{METATENSOR_DISABLE_VALGRIND}" EQUAL "1")
if (NOT "$ENV{RASCALINE_DISABLE_VALGRIND}" EQUAL "1")
message(STATUS "Running tests using valgrind")
set(TEST_COMMAND
"${VALGRIND}" "--tool=memcheck" "--dsymutil=yes" "--error-exitcode=125"
Expand Down