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

Docs: Add note on how to create a code that uses Conda environment #5905

Merged
Merged
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
22 changes: 20 additions & 2 deletions docs/source/howto/run_codes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,10 @@ The type of code is specified as the first argument and the rest of the informat

.. tab-item:: Installed

The following example shows how to create an installed code for the ``bash`` binary on the ``localhost`` computer:

.. code-block:: console

The following example shows how to create an installed code for the ``bash`` binary on the ``localhost`` computer:

verdi code create core.code.installed \
--label installed-code \
Expand Down Expand Up @@ -309,7 +310,7 @@ At the end, you receive a confirmation, with the *PK* and the *UUID* of your new
.. tip::

The ``verdi code create`` command performs minimal checks in order to keep it performant and not rely on an internet connection.
If you want additional checks to verify the code is properly configured and usable, run the `verdi code test` command.
If you want additional checks to verify the code is properly configured and usable, run the ``verdi code test`` command.
For installed codes for example, this will check whether the associated computer can be connected to and whether the specified executable exists.
Look at the command help to see what other checks may be run.

Expand Down Expand Up @@ -346,6 +347,23 @@ At the end, you receive a confirmation, with the *PK* and the *UUID* of your new

Note: remove the ``--`` prefix and replace dashes (``-``) within the keys with an underscore ( ``_`` ).


.. note::

It is possible to run codes that are provided by a `Conda environment <https://docs.conda.io/en/latest/>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps start with the computer configuration

Suggested change
It is possible to run codes that are provided by a `Conda environment <https://docs.conda.io/en/latest/>`_.
It is possible to run codes that are provided by a `Conda environment <https://docs.conda.io/en/latest/>`_.
First, configure the AiiDA computer with ``--use-login-shell`` to enable access to the ``conda activate`` command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the computer configuration to the top. But --use-login-shell is not the correct option. It it the shebang that should be set to #!/bin/bash -l

The associated ``Computer`` should be configured to create a submission script that uses a login shell by setting the ``shebang`` attribute to ``#!/bin/bash -l``.
The ``-l`` flag in bash enforces the script to be executed using a login shell, without which the ``conda activate`` command will fail.

The code configuration YAML would look something like the following:

.. code-block:: yaml

filepath_executable: 'executable-name'
prepend_text: conda activate environment-name

Note that the configuration is not complete but only shows the relevant lines.


Managing codes
--------------

Expand Down