Skip to main content

AiiDA plugin provides the GroupPathX class

Project description

Build Status Coverage Status PyPI version

aiida-grouppathx

AiiDA plugin provides the GroupPathX class.

This plugin was kickstarted using AiiDA plugin cutter, intended to help developers get started with their AiiDA plugins.

Features and usage

Interactive example at: Binder

This package is provides a enhanced version of GroupPath - GroupPathX. The main feature is that it allows nodes stored under a group to be named by an alias. This way, one can address a specific Node as GroupPath('mygroup/structure1'). In addition, a show_tree method is provided for visualising the content of a specific GroupPathX, similiar to the command line tool tree that works on the file system. The goal is to provide a way for managing data with an interface what is similar to a file system based approach.

tree aiida_grouppathx

aiida_grouppathx
├── __init__.py
├── pathx.py
└── __pycache__
   ├── __init__.cpython-38.pyc
   └── pathx.cpython-38.pyc

In analogy:

from aiida_grouppathx import GroupPathX
path = GroupPathX('group1')
path.get_or_create_group()
path['group2'].get_or_create_group()
path.add_node(Int(1).store(), 'int1')
path['group2'].add_node(Int(1).store(), 'int2')

path.show_tree()

gives

group1
├── group2
│   └── int2 *
└── int1 *

where the * highlights that a leaf is a Node rather than a group. This kind of mark up can be customised, for example, to show the status of workflow nodes.

def decorate_name(path):
    if path.is_node:
        return ' ' + str(path.get_node())
path.show_tree(decorate_name)

gives:

group1
├── group2
│   └── int2  uuid: de79d244-d3bb-4f61-9d3a-b3f09e1afb72 (pk: 7060) value: 1
└── int1  uuid: e2f70643-0c25-4ae5-929a-a3e055969d10 (pk: 7059) value: 1

Multiple decorators can be combined

from aiida_grouppathx import decorate_with_group_names, decorate_with_label decorate_with_uuid_first_n

path.show_tree(decorate_with_group_names, decorate_with_label, decorate_with_uuid_first_n())

output:

group1
├── group2
│   └── int2 group1/group2 |  | de79d244-d3b
└── int1 group1 |  | e2f70643-0c2

The stored nodes can be access through:

group1['group2/int2'].get_node()  # Gives node de89d2
group1.browse.group2.int2().get_node()  # Also gives node de89d2

and also

path.browse.<tab>
path.browse.int1()     # To access the `group1/int1` path
path.browse.int1().get_node()     # To access the `group1/int1` node

Please see the pathx.py for the extended methods, and the official documentation for the concept of GroupPath.

The package does not change how Group and Node operates in the AiiDA. It is only built on top of the existing system as an alternative way to access the underlying data.

Installation

pip install aiida-grouppathx
verdi quicksetup  # better to set up a new profile

Development

git clone https://github.com/zhubonan/aiida-grouppathx .
cd aiida-grouppathx
pip install --upgrade pip
pip install -e .[pre-commit,testing]  # install extra dependencies
pre-commit install  # install pre-commit hooks
pytest -v  # discover and run all tests

See the developer guide for more information.

License

MIT

Contact

zhubonan@outlook.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiida_grouppathx-0.2.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

aiida_grouppathx-0.2.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file aiida_grouppathx-0.2.2.tar.gz.

File metadata

  • Download URL: aiida_grouppathx-0.2.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for aiida_grouppathx-0.2.2.tar.gz
Algorithm Hash digest
SHA256 0ec96ebc217801a1ae84625f8a1bca569bceba4814618dbd2276c176ec2409ad
MD5 6aa51573f05b5098870b0d57e3899167
BLAKE2b-256 f541debad1c7366349c074a81a5d18bd49a0495edb762b86b2c335cbb764b090

See more details on using hashes here.

File details

Details for the file aiida_grouppathx-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for aiida_grouppathx-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5b2a2acf771b645bef696180b66bee28d660df92618c8955648ba0c92303e467
MD5 30e1ee33b7bc3a4380d7404d7ece8d04
BLAKE2b-256 0493214df58dcc23e82cd30696a1ced8584f93e85e1b24e5ccae5b9ec941bc77

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page