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

✨ NEW: Allow for CLI usage via python -m aiida #5356

Merged
merged 4 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 16 additions & 0 deletions .github/workflows/verdi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@ done

$VERDI devel check-load-time
$VERDI devel check-undesired-imports


# Test that we can also run the CLI via `python -m aiida`,
# that it returns a 0 exit code, and contains the expected stdout.
chrisjsewell marked this conversation as resolved.
Show resolved Hide resolved
echo "Invoking verdi via `python -m aiida`"
OUTPUT=$(python -m aiida 2>&1)
RETVAL=$?
echo $OUTPUT
if [ $RETVAT -ne 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Uhm @chrisjsewell this may have been my mistake in the review suggestion, but there is a type here. If I promise to not merge your PRs anymore, will you promise to let me sign off on them first :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh, thats all your fault 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't worry, I have a small PR coming up with some minor corrections that I can put this in as well

Copy link
Member Author

Choose a reason for hiding this comment

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

cheers!

echo "'python -m aiida' exitted with code $RETVAL"
chrisjsewell marked this conversation as resolved.
Show resolved Hide resolved
fi
if [[ $OUTPUT != *"command line interface of AiiDA"* ]]; then
echo "'python -m aiida' did not contain the expected stdout:"
exit 2
fi
exit $RETVAL
chrisjsewell marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions aiida/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
###########################################################################
# Copyright (c), The AiiDA team. All rights reserved. #
# This file is part of the AiiDA code. #
# #
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core #
# For further information on the license, see the LICENSE.txt file #
# For further information please visit http://www.aiida.net #
###########################################################################
"""Expose the AiiDA CLI, for usage as `python -m aiida`"""
import sys

if __name__ == '__main__':
from aiida.cmdline.commands.cmd_verdi import verdi
sys.exit(verdi())