From ddad09c78a515464287990cdc23abf85ebd09c67 Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Mon, 11 Oct 2021 14:35:55 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=93=9A=20DOCS:=20Fix=20system-wide=20?= =?UTF-8?q?install=20instructions=20(#5174)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix some faulty installation instructions for the `pip` installation path, as well as some code-blocks that don't play nice with the `sphinx-copybutton`. Additionally, add an `important` note regarding the version of the Python executable used to set up the virtual environment which AiiDA will be installed in. --- docs/source/intro/install_system.rst | 193 +++++++++++++++------------ 1 file changed, 105 insertions(+), 88 deletions(-) diff --git a/docs/source/intro/install_system.rst b/docs/source/intro/install_system.rst index b254f317e5..9e4931783b 100644 --- a/docs/source/intro/install_system.rst +++ b/docs/source/intro/install_system.rst @@ -23,25 +23,23 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto Open a terminal and execute: - .. code-block:: console + .. code-block:: console - $ sudo apt install \ - git python3-dev python3-pip \ - postgresql postgresql-server-dev-all postgresql-client rabbitmq-server + $ sudo apt install git python3-dev python3-pip postgresql postgresql-server-dev-all postgresql-client rabbitmq-server .. tabbed:: MacOS X (Homebrew) - The recommended installation method for Mac OS X is to use `Homebrew `__. + The recommended installation method for Mac OS X is to use `Homebrew `__. - #. Follow `this guide `__ to install Homebrew on your system if not installed yet. + #. Follow `this guide `__ to install Homebrew on your system if not installed yet. - #. Open a terminal and execute: + #. Open a terminal and execute: - .. code-block:: console + .. code-block:: console - $ brew install postgresql rabbitmq git python - $ brew services start postgresql - $ brew services start rabbitmq + $ brew install postgresql rabbitmq git python + $ brew services start postgresql + $ brew services start rabbitmq .. tabbed:: Windows Subsystem for Linux @@ -55,77 +53,85 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - $ sudo apt install rabbitmq-server - $ sudo service rabbitmq-server start + $ sudo apt install rabbitmq-server + + then start the ``rabbitmq`` server: + + .. code-block:: console + + $ sudo service rabbitmq-server start #. Install Python and PostgreSQL: .. code-block:: console - $ sudo apt install \ - postgresql postgresql-server-dev-all postgresql-client \ - git python3-dev python-pip - $ sudo service postgresql start + $ sudo apt install postgresql postgresql-server-dev-all postgresql-client git python3-dev python-pip + + then start the PostgreSQL server: + + .. code-block:: console + + $ sudo service postgresql start .. dropdown:: How to setup WSL to automatically start services after system boot. - Create a file ``start_aiida_services.sh`` containing the following lines: + Create a file ``start_aiida_services.sh`` containing the following lines: - .. code-block:: console + .. code-block:: console - service postgresql start - service rabbitmq-server start # Only for WSL 2! + $ service postgresql start + $ service rabbitmq-server start # Only for WSL 2! - and store it in your preferred location, e.g., the home directory. - Then make the file executeable, and editable only by root users with: + and store it in your preferred location, e.g., the home directory. + Then make the file executable, and editable only by root users with: - .. code-block:: console + .. code-block:: console - $ chmod a+x,go-w /path/to/start_aiida_services.sh - $ sudo chown root:root /path/to/start_aiida_services.sh + $ chmod a+x,go-w /path/to/start_aiida_services.sh + $ sudo chown root:root /path/to/start_aiida_services.sh - Next, run + Next, run - .. code-block:: console + .. code-block:: console - $ sudo visudo + $ sudo visudo - and add the line + and add the line - .. code-block:: sh + .. code-block:: sh - ALL=(root) NOPASSWD: /path/to/start_aiida_services.sh + ALL=(root) NOPASSWD: /path/to/start_aiida_services.sh - replacing ```` with your Ubuntu username. - This will allow you to run *only* this specific ``.sh`` file with ``root`` access (without password), without lowering security on the rest of your system. + replacing ```` with your Ubuntu username. + This will allow you to run *only* this specific ``.sh`` file with ``root`` access (without password), without lowering security on the rest of your system. - Now you can use the Windows Task Scheduler to automatically execute this file on startup: + Now you can use the Windows Task Scheduler to automatically execute this file on startup: - #. Open Task Scheduler. + #. Open Task Scheduler. - #. In the "Actions" menu, click "Create Task". + #. In the "Actions" menu, click "Create Task". - #. In "General/Security options", select "Run whether user is logged on or not". + #. In "General/Security options", select "Run whether user is logged on or not". - #. In the "Triggers" tab, click "New...". + #. In the "Triggers" tab, click "New...". - #. In the "Begin the task:" dropdown, select "At startup". + #. In the "Begin the task:" dropdown, select "At startup". - #. Click "OK" to confirm. + #. Click "OK" to confirm. - #. In the "Actions" tab, click "New...". + #. In the "Actions" tab, click "New...". - #. In the "Action" dropdown, select "Start a program". + #. In the "Action" dropdown, select "Start a program". - #. In the "Program/script" text field, add ``C:\Windows\System32\bash.exe``. + #. In the "Program/script" text field, add ``C:\Windows\System32\bash.exe``. - #. In the "Add arguments (optional)" text field, add ``-c "sudo /path/to/start_aiida_services.sh"``. + #. In the "Add arguments (optional)" text field, add ``-c "sudo /path/to/start_aiida_services.sh"``. - #. Click "OK" to confirm. + #. Click "OK" to confirm. - #. Click "OK" to confirm the task. + #. Click "OK" to confirm the task. - You can tweak other details of this task to fit your needs. + You can tweak other details of this task to fit your needs. .. tabbed:: Other @@ -134,7 +140,7 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. tip:: - Alternatively use the :ref:`pure conda installation method `. + Alternatively use the :ref:`pure conda installation method `. --- @@ -148,14 +154,25 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - $ python -m venv ~/envs/aiida - $ source ~/envs/aiida/bin/activate - (aiida) $ pip install aiida-core + $ python -m venv ~/envs/aiida + $ source ~/envs/aiida/bin/activate + (aiida) $ pip install aiida-core + + .. important:: + + Make sure the ``python`` executable is for a Python version that is supported by AiiDA. + You can see the version using: + + .. code-block:: console + + $ python --version + + You can find the supported Python versions for the latest version of AiiDA `on the PyPI page `__. .. tip:: - See the `venv documentation `__ if the activation command fails. - The exact command for activating a virtual environment differs slightly based on the used shell. + See the `venv documentation `__ if the activation command fails. + The exact command for activating a virtual environment differs slightly based on the used shell. .. dropdown:: :fa:`plus-circle` Installation extras @@ -173,7 +190,7 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - (aiida) $ pip install aiida-core[atomic_tools,docs] + (aiida) $ pip install aiida-core[atomic_tools,docs] .. dropdown:: :fa:`wrench` Kerberos on Ubuntu @@ -194,8 +211,8 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - $ conda create -n aiida -c conda-forge aiida-core - $ conda activate aiida + $ conda create -yn aiida -c conda-forge aiida-core + $ conda activate aiida .. tabbed:: From source @@ -205,11 +222,11 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - $ git clone https://github.com/aiidateam/aiida-core.git - $ cd aiida-core/ - $ python -m pip venv ~/envs/aiida - $ source ~/envs/aiida/bin/activate - (aiida) $ pip install . + $ git clone https://github.com/aiidateam/aiida-core.git + $ cd aiida-core/ + $ python -m venv ~/envs/aiida + $ source ~/envs/aiida/bin/activate + (aiida) $ pip install . --- @@ -219,19 +236,19 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - (aiida) $ verdi quicksetup - Info: enter "?" for help - Info: enter "!" to ignore the default and set no value - Profile name: me - Email Address (for sharing data): me@user.com - First name: my - Last name: name - Institution: where-i-work + (aiida) $ verdi quicksetup + Info: enter "?" for help + Info: enter "!" to ignore the default and set no value + Profile name: me + Email Address (for sharing data): me@user.com + First name: my + Last name: name + Institution: where-i-work .. admonition:: Is AiiDA unable to auto-detect the PostgreSQL setup? - :class: attention title-icon-troubleshoot + :class: attention title-icon-troubleshoot - If you get an error saying that AiiDA has trouble autodetecting the PostgreSQL setup, you will need to do the manual setup explained in the :ref:`troubleshooting section`. + If you get an error saying that AiiDA has trouble autodetecting the PostgreSQL setup, you will need to do the manual setup explained in the :ref:`troubleshooting section`. --- @@ -241,15 +258,15 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - (aiida) $ verdi daemon start 2 + (aiida) $ verdi daemon start 2 .. important:: - The verdi daemon(s) must be restarted after a system reboot. + The verdi daemon(s) must be restarted after a system reboot. .. tip:: - Do not start more daemons then there are physical processors on your system. + Do not start more daemons then there are physical processors on your system. --- @@ -259,22 +276,22 @@ This is the *recommended* installation method to setup AiiDA on a personal lapto .. code-block:: console - (aiida) $ verdi status - ✓ config dir: /home/ubuntu/.aiida - ✓ profile: On profile me - ✓ repository: /home/ubuntu/.aiida/repository/me - ✓ postgres: Connected as aiida_qs_ubuntu_c6a4f69d255fbe9cdb7385dcdcf3c050@localhost:5432 - ✓ rabbitmq: Connected as amqp://127.0.0.1?heartbeat=600 - ✓ daemon: Daemon is running as PID 16430 since 2020-04-29 12:17:31 + (aiida) $ verdi status + ✓ config dir: /home/ubuntu/.aiida + ✓ profile: On profile me + ✓ repository: /home/ubuntu/.aiida/repository/me + ✓ postgres: Connected as aiida_qs_ubuntu_c6a4f69d255fbe9cdb7385dcdcf3c050@localhost:5432 + ✓ rabbitmq: Connected as amqp://127.0.0.1?heartbeat=600 + ✓ daemon: Daemon is running as PID 16430 since 2020-04-29 12:17:31 At this point you should now have a working AiiDA environment, from which you can add and retrieve data. - .. admonition:: Missing a checkmark or ecountered some other issue? - :class: attention title-icon-troubleshoot + .. admonition:: Missing a checkmark or encountered some other issue? + :class: attention title-icon-troubleshoot - :ref:`See the troubleshooting section `. + :ref:`See the troubleshooting section `. .. link-button:: intro:get_started:next - :type: ref - :text: What's next? - :classes: btn-outline-primary btn-block font-weight-bold + :type: ref + :text: What's next? + :classes: btn-outline-primary btn-block font-weight-bold From 5acf437edf08e79e38bb878aaa7d6b7f5ebbd723 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 13 Oct 2021 02:54:38 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20MAINTAIN:=20Improve=20type?= =?UTF-8?q?=20annotations=20of=20`@classproperty`=20(#5176)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Taken from https://github.com/python/mypy/pull/2266#issuecomment-265600482. These annotations allow for static analysers to correctly return the type of a decorated method. --- aiida/common/lang.py | 9 ++++++--- docs/source/nitpick-exceptions | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/aiida/common/lang.py b/aiida/common/lang.py index f2bb8906f6..37f977b8b9 100644 --- a/aiida/common/lang.py +++ b/aiida/common/lang.py @@ -11,6 +11,7 @@ import functools import inspect import keyword +from typing import Any, Callable, Generic, TypeVar def isidentifier(identifier): @@ -75,8 +76,10 @@ def wrapped_fn(self, *args, **kwargs): # pylint: disable=missing-docstring override = override_decorator(check=False) # pylint: disable=invalid-name +ReturnType = TypeVar('ReturnType') -class classproperty: # pylint: disable=invalid-name + +class classproperty(Generic[ReturnType]): # pylint: disable=invalid-name """ A class that, when used as a decorator, works as if the two decorators @property and @classmethod where applied together @@ -85,8 +88,8 @@ class classproperty: # pylint: disable=invalid-name instance as its first argument). """ - def __init__(self, getter): + def __init__(self, getter: Callable[[Any], ReturnType]) -> None: self.getter = getter - def __get__(self, instance, owner): + def __get__(self, instance: Any, owner: Any) -> ReturnType: return self.getter(owner) diff --git a/docs/source/nitpick-exceptions b/docs/source/nitpick-exceptions index 99af999ad5..44cf0958fc 100644 --- a/docs/source/nitpick-exceptions +++ b/docs/source/nitpick-exceptions @@ -21,6 +21,7 @@ py:class builtins.dict # typing py:class asyncio.events.AbstractEventLoop py:class EntityType +py:class ReturnType py:class function py:class IO py:class traceback