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

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Feb 23, 2023

Fixes #5895

This is already supported but it is important that the generated submission script uses a login script or conda activate will not work properly.

@sphuber sphuber requested review from ltalirz and chrisjsewell and removed request for ltalirz February 23, 2023 21:03
ltalirz
ltalirz previously approved these changes Feb 25, 2023
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

Thanks @sphuber

Some comments, but no need for further review

Comment on lines 362 to 363
In the `prepend_text`, the required Conda environment is activated as one normally would.
This allows to simply specify the target executable by its name, and there is no need to specify an absolute path.
Copy link
Member

Choose a reason for hiding this comment

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

You may consider skipping these two lines (they seem obvious from the example above)

Suggested change
In the `prepend_text`, the required Conda environment is activated as one normally would.
This allows to simply specify the target executable by its name, and there is no need to specify an absolute path.


.. 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

Comment on lines 365 to 368
The final requirement is that the computer should be configured to create a submission script that uses a login shell.
To do so, make sure the computer sets ``#!/bin/bash -l`` for the `shebang` property.
The ``-l`` flag in bash enforces the script to be executed using a login shell.
Without this, a normal non-interactive shell is used instead, which will cause the ``conda activate`` command to fail.
Copy link
Member

Choose a reason for hiding this comment

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

Could also be dropped if you accept the suggestion above

Suggested change
The final requirement is that the computer should be configured to create a submission script that uses a login shell.
To do so, make sure the computer sets ``#!/bin/bash -l`` for the `shebang` property.
The ``-l`` flag in bash enforces the script to be executed using a login shell.
Without this, a normal non-interactive shell is used instead, which will cause the ``conda activate`` command to fail.

If you like, you could mention the alternative of providing the absolute path and skipping conda activate (I guess conda packages are typically reasonable with using RPATH etc. to pick up the right dependencies, but I don't have much experience with it)

This is already supported but it is important that the generated
submission script uses a login script or `conda activate` will not work
properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should the use_login_shell property of the AuthInfo also be considered in the submission script shebang
2 participants