Skip to content

Commit

Permalink
Dependencies: Add new extra tui that provides verdi as a TUI (#6071)
Browse files Browse the repository at this point in the history
The `tui` extra installs `trogon`. This package leverages `textual` to
turn `verdi`'s `click` interface into a Text-based User Interface (TUI).
It is added only if `trogon` is installed and can be imported. When it
is installed, it adds the `verdi tui` command, which launches the 
text-based interface of `verdi`.

Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
  • Loading branch information
chrisjsewell and sphuber authored Sep 17, 2023
1 parent 83fc5cf commit a42e09c
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
strategy:
fail-fast: false
matrix:
extras: [ '', '[atomic_tools,docs,notebook,rest,tests]' ]
extras: [ '', '[atomic_tools,docs,notebook,rest,tests,tui]' ]

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -242,7 +242,7 @@ jobs:
- name: Install aiida-core
run: |
pip install -e .[atomic_tools,docs,notebook,rest,tests]
pip install -e .[atomic_tools,docs,notebook,rest,tests,tui]
- run: pip freeze

Expand Down
10 changes: 10 additions & 0 deletions aiida/cmdline/commands/cmd_verdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@
@click.version_option(__version__, package_name='aiida_core', message='AiiDA version %(version)s')
def verdi():
"""The command line interface of AiiDA."""


# Apply the ``tui`` interface if the dependency is installed. If the case, this will add the ``verdi tui`` command
# that allows to explore the interface in a graphical manner in the terminal.
try:
from trogon import tui
except ImportError:
pass
else:
tui()(verdi)
6 changes: 6 additions & 0 deletions docs/source/howto/interact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ AiiDA comes with a command line interface called ``verdi``.
The :ref:`reference:command-line` section gives an overview of all available commands.
For more detailed information, refer to the topic section :ref:`topics:cli`.

.. tip::

The ``verdi`` command line interface can also be explored as a `text-based user interface <https://en.wikipedia.org/wiki/Text-based_user_interface>`_ (TUI).
It requires ``aiida-core`` to be installed with the ``tui`` extra (e.g. ``pip install aiida-core[tui]``).
The TUI can then be launched with ``verdi tui``.


.. _how-to:interact-scripts:

Expand Down
15 changes: 15 additions & 0 deletions docs/source/reference/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,21 @@ Below is a list with all available subcommands.
version Print the current version of the storage schema.
.. _reference:command-line:verdi-tui:

``verdi tui``
-------------

.. code:: console
Usage: [OPTIONS]
Open Textual TUI.
Options:
--help Show this message and exit.
.. _reference:command-line:verdi-user:

``verdi user``
Expand Down
6 changes: 6 additions & 0 deletions docs/source/topics/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Command line interface
The command line interface utility for AiiDA is called ``verdi``.
This section explains the basic concepts that apply to all ``verdi`` commands.

.. tip::

The ``verdi`` command line interface can also be explored as a `text-based user interface <https://en.wikipedia.org/wiki/Text-based_user_interface>`_ (TUI).
It requires ``aiida-core`` to be installed with the ``tui`` extra (e.g. ``pip install aiida-core[tui]``).
The TUI can then be launched with ``verdi tui``.


.. _topics:cli:parameters:

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Documentation = "https://aiida.readthedocs.io"
Source = "https://github.com/aiidateam/aiida-core"

[project.optional-dependencies]
tui = [
"trogon",
]
ssh_kerberos = [
"gssapi~=1.6",
"pyasn1~=0.4.8"
Expand Down Expand Up @@ -439,6 +442,7 @@ module = [
'sqlalchemy_utils.*',
'tabulate.*',
'tqdm.*',
'trogon.*',
'wrapt.*',
'upf_to_json.*',
]
Expand Down
8 changes: 7 additions & 1 deletion requirements/requirements-py-3.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ alabaster==0.7.13
alembic==1.11.1
aniso8601==9.0.1
anyio==3.7.0
appnope==0.1.3
archive-path==0.4.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -79,8 +80,9 @@ jupyterlab-widgets==3.0.7
kiwipy[rmq]==0.7.7
kiwisolver==1.4.4
latexcodec==2.0.1
linkify-it-py==2.0.2
mako==1.2.4
markdown-it-py==2.2.0
markdown-it-py[linkify,plugins]==2.2.0
markupsafe==2.1.3
matplotlib==3.7.1
matplotlib-inline==0.1.6
Expand Down Expand Up @@ -160,6 +162,7 @@ qtpy==2.3.1
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.4.2
ruamel-yaml==0.17.32
ruamel-yaml-clib==0.2.7
scipy==1.10.1
Expand Down Expand Up @@ -193,13 +196,16 @@ sympy==1.12
tabulate==0.8.10
tenacity==8.2.2
terminado==0.17.1
textual==0.29.0
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
trogon==0.5.0
typing-extensions==4.6.3
tzdata==2023.3
uc-micro-py==1.0.2
uncertainties==3.1.7
upf-to-json==0.9.5
urllib3==2.0.3
Expand Down
8 changes: 7 additions & 1 deletion requirements/requirements-py-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ alabaster==0.7.13
alembic==1.11.1
aniso8601==9.0.1
anyio==3.7.0
appnope==0.1.3
archive-path==0.4.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -78,8 +79,9 @@ jupyterlab-widgets==3.0.7
kiwipy[rmq]==0.7.7
kiwisolver==1.4.4
latexcodec==2.0.1
linkify-it-py==2.0.2
mako==1.2.4
markdown-it-py==2.2.0
markdown-it-py[linkify,plugins]==2.2.0
markupsafe==2.1.3
matplotlib==3.7.1
matplotlib-inline==0.1.6
Expand Down Expand Up @@ -159,6 +161,7 @@ qtpy==2.3.1
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.4.2
ruamel-yaml==0.17.32
ruamel-yaml-clib==0.2.7
scipy==1.10.1
Expand Down Expand Up @@ -192,12 +195,15 @@ sympy==1.12
tabulate==0.8.10
tenacity==8.2.2
terminado==0.17.1
textual==0.29.0
tinycss2==1.2.1
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
trogon==0.5.0
typing-extensions==4.6.3
tzdata==2023.3
uc-micro-py==1.0.2
uncertainties==3.1.7
upf-to-json==0.9.5
urllib3==2.0.3
Expand Down
8 changes: 7 additions & 1 deletion requirements/requirements-py-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ alabaster==0.7.13
alembic==1.11.1
aniso8601==9.0.1
anyio==3.7.0
appnope==0.1.3
archive-path==0.4.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -81,8 +82,9 @@ jupyterlab-widgets==3.0.7
kiwipy[rmq]==0.7.7
kiwisolver==1.4.4
latexcodec==2.0.1
linkify-it-py==2.0.2
mako==1.2.4
markdown-it-py==2.2.0
markdown-it-py[linkify,plugins]==2.2.0
markupsafe==2.1.3
matplotlib==3.7.1
matplotlib-inline==0.1.6
Expand Down Expand Up @@ -162,6 +164,7 @@ qtpy==2.3.1
requests==2.31.0
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.4.2
ruamel-yaml==0.17.32
ruamel-yaml-clib==0.2.7
scipy==1.10.1
Expand Down Expand Up @@ -195,13 +198,16 @@ sympy==1.12
tabulate==0.8.10
tenacity==8.2.2
terminado==0.17.1
textual==0.29.0
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
trogon==0.5.0
typing-extensions==4.6.3
tzdata==2023.3
uc-micro-py==1.0.2
uncertainties==3.1.7
upf-to-json==0.9.5
urllib3==2.0.3
Expand Down

0 comments on commit a42e09c

Please sign in to comment.