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

🔀 MERGE: Release v2.0.0b1 #5426

Merged
merged 12 commits into from
Mar 15, 2022
Merged
466 changes: 466 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aiida/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
'For further information please visit http://www.aiida.net/. All rights reserved.'
)
__license__ = 'MIT license, see LICENSE.txt file.'
__version__ = '2.0.0a1'
__version__ = '2.0.0b1'
__authors__ = 'The AiiDA team.'
__paper__ = (
'S. P. Huber et al., "AiiDA 1.0, a scalable computational infrastructure for automated reproducible workflows and '
Expand Down
7 changes: 7 additions & 0 deletions aiida/cmdline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
'UserParamType',
'WorkflowParamType',
'dbenv',
'echo_critical',
'echo_dictionary',
'echo_error',
'echo_info',
'echo_report',
'echo_success',
'echo_warning',
'format_call_graph',
'is_verbose',
'only_if_daemon_running',
Expand Down
8 changes: 8 additions & 0 deletions aiida/cmdline/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@
from .ascii_vis import *
from .common import *
from .decorators import *
from .echo import *

__all__ = (
'dbenv',
'echo_critical',
'echo_dictionary',
'echo_error',
'echo_info',
'echo_report',
'echo_success',
'echo_warning',
'format_call_graph',
'is_verbose',
'only_if_daemon_running',
Expand Down
2 changes: 1 addition & 1 deletion aiida/cmdline/utils/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

CMDLINE_LOGGER = AIIDA_LOGGER.getChild('cmdline')

__all__ = ('echo', 'echo_info', 'echo_success', 'echo_warning', 'echo_error', 'echo_critical', 'echo_dictionary')
__all__ = ('echo_report', 'echo_info', 'echo_success', 'echo_warning', 'echo_error', 'echo_critical', 'echo_dictionary')


class ExitCode(enum.IntEnum):
Expand Down
10 changes: 8 additions & 2 deletions aiida/engine/processes/calcjobs/importer.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# -*- coding: utf-8 -*-
"""Abstract utility class that helps to import calculation jobs completed outside of AiiDA."""
from abc import abstractmethod
from abc import ABC, abstractmethod
from typing import Dict, Union

from aiida.orm import Node, RemoteData

__all__ = ('CalcJobImporter',)


class CalcJobImporter:
class CalcJobImporter(ABC):
"""An abstract class, to define an importer for computations completed outside of AiiDA.

This class is used to import the results of a calculation that was completed outside of AiiDA.
The importer is responsible for parsing the output files of the calculation and creating the
corresponding AiiDA nodes.
"""

@staticmethod
@abstractmethod
Expand Down
16 changes: 15 additions & 1 deletion aiida/manage/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def profile_context(profile: Optional[str] = None, allow_switch=False) -> 'Profi
"""
from aiida.manage import get_manager
get_manager().load_profile(profile, allow_switch)
yield
yield profile
get_manager().unload_profile()


Expand Down Expand Up @@ -248,6 +248,20 @@ def load_documentation_profile():
"""
import tempfile

# imports required for docs/source/reference/api/public.rst
from aiida import ( # pylint: disable=unused-import
cmdline,
common,
engine,
manage,
orm,
parsers,
plugins,
schedulers,
tools,
transports,
)
Comment on lines +251 to +263
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do they have to be imported in this particular file?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is required in docs/source/reference/api/public.rst, by the autoattribute directive.
What it actually does, is calls, e.g. getattr(aiida, 'tools'), which gives an AttributeError, if you haven't actually already loaded the module.

from aiida.cmdline.params import arguments, options # pylint: disable=unused-import
from aiida.storage.psql_dos.models.base import get_orm_metadata

from .config import Config
Expand Down
1 change: 1 addition & 0 deletions aiida/orm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'GroupEntityLoader',
'ImportGroup',
'Int',
'JsonableData',
'Kind',
'KpointsData',
'LinkManager',
Expand Down
1 change: 1 addition & 0 deletions aiida/orm/nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'Float',
'FolderData',
'Int',
'JsonableData',
'Kind',
'KpointsData',
'List',
Expand Down
2 changes: 2 additions & 0 deletions aiida/orm/nodes/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from .float import *
from .folder import *
from .int import *
from .jsonable import *
from .list import *
from .numeric import *
from .orbital import *
Expand All @@ -47,6 +48,7 @@
'Float',
'FolderData',
'Int',
'JsonableData',
'Kind',
'KpointsData',
'List',
Expand Down
4 changes: 3 additions & 1 deletion aiida/orm/nodes/data/jsonable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import json
import typing

from aiida.orm import Data
from .data import Data

__all__ = ('JsonableData',)


class JsonSerializableProtocol(typing.Protocol):
Expand Down
1 change: 1 addition & 0 deletions aiida/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for PEP 561
2 changes: 1 addition & 1 deletion aiida/transports/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def validate_positive_number(ctx, param, value): # pylint: disable=unused-argum


class Transport(abc.ABC):
"""Abstract class for a generic transport (ssh, local, ...) ontains the set of minimal methods."""
"""Abstract class for a generic transport (ssh, local, ...) contains the set of minimal methods."""
# pylint: disable=too-many-public-methods

# This is used as a global default in case subclasses don't redefine this,
Expand Down
8 changes: 7 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
]

intersphinx_mapping = {
'aep': ('https://aep.readthedocs.io/en/latest/', None),
'click': ('https://click.palletsprojects.com/', None),
'flask': ('http://flask.pocoo.org/docs/latest/', None),
'flask_restful': ('https://flask-restful.readthedocs.io/en/latest/', None),
Expand All @@ -80,7 +81,8 @@
todo_include_todos = False
ipython_mplbackend = ''

myst_enable_extensions = []
myst_enable_extensions = ['colon_fence', 'deflist']
nb_merge_streams = True

# -- Options for HTML output ---------------------------------------------------

Expand Down Expand Up @@ -187,6 +189,7 @@ def run_apidoc(_):


# Warnings to ignore when using the -n (nitpicky) option
nitpicky = True
with open('nitpick-exceptions', 'r') as handle:
nitpick_ignore = [
tuple(line.strip().split(None, 1)) for line in handle.readlines() if line.strip() and not line.startswith('#')
Expand Down Expand Up @@ -265,7 +268,10 @@ def setup(app: Sphinx):
'aiida.orm.AuthInfo': 'aiida.orm.authinfos.AuthInfo',
'aiida.orm.Computer': 'aiida.orm.computers.Computer',
'aiida.orm.Comment': 'aiida.orm.comments.Comment',
'aiida.orm.EnumData': 'aiida.orm.nodes.data.enum.EnumData',
'aiida.orm.Group': 'aiida.orm.groups.Group',
'aiida.orm.JsonableData': 'aiida.orm.nodes.data.jsonable.JsonableData',
'aiida.orm.List': 'aiida.orm.nodes.data.list.List',
'aiida.orm.Log': 'aiida.orm.logs.Log',
'aiida.orm.Node': 'aiida.orm.nodes.node.Node',
'aiida.orm.User': 'aiida.orm.users.User',
Expand Down
88 changes: 88 additions & 0 deletions docs/source/howto/archive_profile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.11.4
kernelspec:
display_name: Python 3
language: python
name: python3
---

(how-to:data:share:archive:profile)=

# How to inspect an archive

```{note}
This tutorial can be downloaded and run as a Jupyter Notebook: {nb-download}`archive_profile.ipynb` {octicon}`download`, together with the archive {download}`include/process.aiida`.
```

The AiiDA archive is a file format for long term storage of data from a particular profile.

See {ref}`how-to:share:archives` for information on how to create and migrate an archive.
Once you have an archive at the latest version, you can inspect its contents in the same way you would with a standard AiiDA profile.

We first create a profile instance from the archive path:

```{code-cell} ipython3
from aiida import manage, orm, profile_context
from aiida.storage.sqlite_zip.backend import SqliteZipBackend

archive_profile = SqliteZipBackend.create_profile('include/process.aiida')
print(archive_profile)
```

The {py:func}`~aiida.manage.configuration.profile_context` function works similarly to the {py:func}`~aiida.manage.configuration.load_profile` function,
but is used within a context manager, that insures that the storage is properly closed when the context is exited.
With this, we can load our archive as a profile:

```{code-cell} ipython3
with profile_context(archive_profile):
print(manage.get_manager().get_profile())
```

To directly access the storage backend, and view information about it, we can use:

```{code-cell} ipython3
import json
with profile_context(archive_profile):
storage = manage.get_manager().get_profile_storage()
print(storage)
print(json.dumps(storage.get_info(), indent=2))
```

This is directly equivalent to the command-line call:

```{code-cell} ipython3
!verdi archive info include/process.aiida
```

Note, that once the context manager is exited, the storage is closed, and will except on further calls.

```{code-cell} ipython3
print(storage)
```

As per a standard profile, we can now use the {py:class}`~aiida.orm.QueryBuilder`, to [find and query for data](how-to:query):

```{code-cell} ipython3
with profile_context(archive_profile):
process = orm.QueryBuilder().append(orm.ProcessNode).first(flat=True)
print(process)
```

and also use {py:class}`~aiida.tools.visualization.graph.Graph`, to [visualize data provenance](how-to:data:visualise-provenance):

```{code-cell} ipython3
from aiida.tools.visualization import Graph

with profile_context(archive_profile):
process = orm.QueryBuilder().append(orm.ProcessNode).first(flat=True)
graph = Graph(graph_attr={"size": "8!,8!", "rankdir": "LR"})
graph.add_incoming(process, annotate_links="both")
graph.add_outgoing(process, annotate_links="both")

graph.graphviz
```
Binary file added docs/source/howto/include/process.aiida
Binary file not shown.
3 changes: 2 additions & 1 deletion docs/source/howto/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ How-To Guides
data
query
share_data
visualising_graphs/visualising_graphs
archive_profile
visualising_graphs
installation
plugins_develop
cookbook
Expand Down
4 changes: 4 additions & 0 deletions docs/source/howto/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ Updating from 0.x.* to 1.*
- `Additional instructions on how to migrate from versions 0.4 -- 0.11 <https://aiida.readthedocs.io/projects/aiida-core/en/v1.2.1/install/updating_installation.html#older-versions>`_.
- For a list of breaking changes between the 0.x and the 1.x series of AiiDA, `see here <https://aiida.readthedocs.io/projects/aiida-core/en/v1.2.1/install/updating_installation.html#breaking-changes-from-0-12-to-1>`_.

Updating from 1.* to 2.*
------------------------

See the :doc:`../reference/_changelog` for a list of breaking changes.

.. _how-to:installation:backup:

Expand Down
18 changes: 18 additions & 0 deletions docs/source/howto/interact.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ If, for whatever reason, ``verdi run`` nor the special shebang can be used, a pr

One can pass a particular profile name to :meth:`~aiida.manage.configuration.load_profile`, otherwise the default profile is loaded.

Within a script or Python instance, you can also switch to a different profile, or use one within a context manager:

.. code-block:: python

from aiida import load_profile, profile_context, orm

with profile_context('my_profile_1'):
# The profile will be loaded within the context
node_from_profile_1 = orm.load_node(1)
# then the profile will be unloaded automatically

# load a global profile
load_profile('my_profile_2')
node_from_profile_2 = orm.load_node(1)

# switch to a different global profile
load_profile('my_profile_3', allow_switch=True)
node_from_profile_3 = orm.load_node(1)

.. _how-to:interact-shell:

Expand Down
Loading