Skip to content

Commit

Permalink
Docs: Improvements to sections containing recently added functionality (
Browse files Browse the repository at this point in the history
#6090)

* Daemon API
 * Processes API
 * Multiple profile serving for REST API
 * Controlling MPI when creating a `Code`
  • Loading branch information
mikibonacci committed Sep 1, 2023
1 parent 35c57b9 commit 836419f
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
23 changes: 23 additions & 0 deletions docs/source/internals/rest_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,26 @@ Moreover, we recommend to consult the documentation of `mod_wsgi <https://modwsg
.. note::
Optionally, create a click option for the variable ``catch_internal_server`` to be ``False`` in order to let exceptions (including python tracebacks) bubble up to the apache error log.
This can be particularly useful when the ``app`` is still under heavy development.


.. _internal_architecture:restapi:multiple_profiles:

Serving multiple profiles
=========================

A single REST API instance can serve data from all profiles of an AiiDA instance.
To maintain backwards compatibility, the new functionality needs to be explicitly enabled through the configuration:

.. code-block:: bash
verdi config set rest_api.profile_switching true
After the REST API is restarted, it will now accept the profile query parameter, for example:

.. code-block:: console
http://127.0.0.1:5000/api/v4/computers?profile=some-profile-name
If the specified profile is already loaded, the REST API functions exactly as without profile switching enabled.
If another profile is specified, the REST API will first switch profiles before executing the request.
If the profile parameter is specified in a request and the REST API does not have profile switching enabled, a 400 response is returned.
1 change: 1 addition & 0 deletions docs/source/topics/calculations/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ The ``Code``
When creating a code, you can tell AiiDA that it should be run as an MPI program, by setting the ``with_mpi`` attribute to ``True`` or ``False``.
From AiiDA 2.3 onward, this is the **recommended** way of controlling MPI behavior.
The attribute can be set from the Python API as ``AbstractCode(with_mpi=with_mpi)`` or through the ``--with-mpi`` / ``--no-with-mpi`` option of the ``verdi code create`` CLI command.
If the code can be run with or without MPI, setting the ``with_mpi`` attribute can be skipped.
It will default to ``None``, leaving the question of whether to run with or without MPI up to the ``CalcJob`` plugin or user input.
Expand Down
23 changes: 22 additions & 1 deletion docs/source/topics/daemon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,28 @@ Client
======

The Python API provides the :class:`~aiida.engine.daemon.client.DaemonClient` class to interact with the daemon.
It can either be constructed directly for a given profile, or the :func:`aiida.engine.daemon.client.get_daemon_client` function can be used to construct it for the current default profile.
It can either be constructed directly for a given profile, or the :func:`aiida.engine.get_daemon_client` utility function can be used to construct it.
In order to control the daemon for the current default profile:

.. code-block:: python
from aiida.engine import get_daemon_client
client = get_daemon_client()
It is also possible to explicitly specify a profile:

.. code-block:: python
client = get_daemon_client(profile='some-profile')
The daemon can be started and stopped through the client:

.. code-block:: python
client.start_daemon()
assert client.is_daemon_running
client.stop_daemon(wait=True)
The main methods of interest for interacting with the daemon are:

* :meth:`~aiida.engine.daemon.client.DaemonClient.start_daemon`
Expand Down
25 changes: 25 additions & 0 deletions docs/source/topics/processes/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -704,3 +704,28 @@ If you know that your daemon runners may be experiencing a heavy load, you can a
.. rubric:: Footnotes

.. [#f1] Note that the :py:class:`~aiida.calculations.arithmetic.add.ArithmeticAddCalculation` process class also takes a ``code`` as input, but that has been omitted for the purposes of the example.
.. _topics:processes:usage:processes_api:

The processes API
-----------------

The functionality of ``verdi process`` to ``play``, ``pause`` and ``kill`` is now made available through the :meth:`aiida.engine.processes.control` module.
Processes can be played, paused or killed through the :meth:`~aiida.engine.processes.control.play_processes`, :meth:`~aiida.engine.processes.control.pause_processes`, and :meth:`~aiida.engine.processes.control.kill_processes`, respectively:

.. code-block:: python
from aiida.engine.processes import control
processes = [load_node(<PK1>), load_node(<PK2>)]
pause_processes(processes) # Pause the processes
play_processes(processes) # Play them again
kill_processes(processes) # Kill the processes
Instead of specifying an explicit list of processes, the functions also take the ``all_entries`` keyword argument:

.. code-block:: python
pause_processes(all_entries=True) # Pause all running processes

0 comments on commit 836419f

Please sign in to comment.