aiida-worktree


Nameaiida-worktree JSON
Version 0.1.8 PyPI version JSON
download
home_pageNone
SummaryDesign flexible node-based workflow for AiiDA calculation.
upload_time2024-04-19 05:22:27
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords aiida workflows
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AiiDA-WorkTree
[![PyPI version](https://badge.fury.io/py/aiida-worktree.svg)](https://badge.fury.io/py/aiida-worktree)
[![Unit test](https://github.com/superstar54/aiida-worktree/actions/workflows/ci.yaml/badge.svg)](https://github.com/superstar54/aiida-worktree/actions/workflows/ci.yaml)
[![Docs status](https://readthedocs.org/projects/aiida-worktree/badge)](http://aiida-worktree.readthedocs.io/)

Provides the third workflow component: `WorkTree`, to design flexible node-based workflows using AiiDA.

In AiiDA, there are two workflow components: `workfunction` and `WorkChain`. Workfunction is easy to implement but it does not support automatic checkpointing, which is important for long-running calculations. Workchain supports automatic checkpointing but it is difficult to implement and also not as flexible as the `workfunction`. AiiDA-WorkTree provides the third component: `WorkTree`. It is easy to implement and supports automatic checkpointing. It is also flexible and can be used to design complex workflows.


Here is a detailed comparison between the ``WorkTree`` with two AiiDA built-in workflow components.


| Aspect                   | WorkFunction           | WorkChain                     | WorkTree               |
| ------------------------ | ---------------------- | ----------------------------- | ---------------------- |
| Use Case                 | Short-running jobs     | Long-running jobs             | Long-running jobs      |
| Checkpointing            | ``No``                 | Yes                           | Yes                    |
| Execution order          | ``Sequential``         | ``Hybrid Sequential-Parallel``| Directed Acyclic Graph |
| Non-blocking             | ``No``                 | Yes                           | Yes                    |
| Implementation           | Easy                   | ``Difficult``                 | Easy                   |
| Dynamic                  | ``No``                 | ``No``                        | Yes                    |
| Ready to Use             | Yes                    | ``Need PYTHONPATH``           | Yes                    |
| Subprocesses Handling    | ``No``                 | Launches & waits              | Launches & waits       |
| Flow Control             | All                    | `if`, `while`                 | `if`, `while`, `match` |
| Termination              | ``Hard exit``          | ExitCode                      | ExitCode               |
| Data Passing             | Direct passing         | Context                       | Link & Context         |
| Output Recording         | Limited support        | Out & validates               | Out                    |
| Port Exposing            | Limited support        | Manual & automatic            | Manual                 |



## Installation

```console
    pip install aiida-worktree
```

To install the latest version from source, first clone the repository and then install using `pip`:

```console
git clone https://github.com/superstar54/aiida-worktree
cd aiida-worktree
pip install -e .
```
In order to use the widget, you also need to run:
```console
cd aiida_worktree/widget/
npm install
npm run build
```

## Documentation
Check the [docs](https://aiida-worktree.readthedocs.io/en/latest/) and learn about the features.

## Examples

Create calcfunction nodes:

```python
from aiida_worktree import node

# define add calcfunction node
@node.calcfunction()
def add(x, y):
    return x + y

# define multiply calcfunction node
@node.calcfunction()
def multiply(x, y):
    return x*y

```

Create a worktree to link the nodes.

```python
from aiida_worktree import WorkTree
from aiida import load_profile
from aiida.orm import Int
load_profile()


wt = WorkTree("test_add_multiply")
wt.nodes.new(add, name="add1", x=Int(2.0), y=Int(3.0))
wt.nodes.new(multiply, name="multiply1", y=Int(4.0))
wt.links.new(wt.nodes["add1"].outputs[0], wt.nodes["multiply1"].inputs["x"])
wt.submit(wait=True)
```

Start the web app, open a terminal and run:
```console
worktree web start
```

Then visit the page http://127.0.0.1:8000/worktree, you should find a `first_workflow` Worktree, click the pk and view the WorkTree.

<img src="docs/source/_static/images/first-workflow.png" />


One can also generate the node graph from the process:
```console
verdi node generate pk
```

<img src="docs/source/_static/images/add_multiply.png"/>


## Development

### Pre-commit and Tests
To contribute to this repository, please enable pre-commit so the code in commits are conform to the standards.
```console
pip install -e .[tests, pre-commit]
pre-commit install
```

### Web app
See the [README.md](https://github.com/superstar54/aiida-worktree/blob/main/aiida_worktree/web/README.md)

### Build and publish
Build package:
```console
pip install build
python -m build
```
Upload to PyPI:
```console
pip install twine
twine upload dist/*
```

## License
[MIT](http://opensource.org/licenses/MIT)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "aiida-worktree",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "aiida, workflows",
    "author": null,
    "author_email": "Xing Wang <xingwang1991@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2c/65/83cc44ebfd56bd50153660cf3ef01658fd34be776b0c8f5b76f5b9829b13/aiida_worktree-0.1.8.tar.gz",
    "platform": null,
    "description": "# AiiDA-WorkTree\n[![PyPI version](https://badge.fury.io/py/aiida-worktree.svg)](https://badge.fury.io/py/aiida-worktree)\n[![Unit test](https://github.com/superstar54/aiida-worktree/actions/workflows/ci.yaml/badge.svg)](https://github.com/superstar54/aiida-worktree/actions/workflows/ci.yaml)\n[![Docs status](https://readthedocs.org/projects/aiida-worktree/badge)](http://aiida-worktree.readthedocs.io/)\n\nProvides the third workflow component: `WorkTree`, to design flexible node-based workflows using AiiDA.\n\nIn AiiDA, there are two workflow components: `workfunction` and `WorkChain`. Workfunction is easy to implement but it does not support automatic checkpointing, which is important for long-running calculations. Workchain supports automatic checkpointing but it is difficult to implement and also not as flexible as the `workfunction`. AiiDA-WorkTree provides the third component: `WorkTree`. It is easy to implement and supports automatic checkpointing. It is also flexible and can be used to design complex workflows.\n\n\nHere is a detailed comparison between the ``WorkTree`` with two AiiDA built-in workflow components.\n\n\n| Aspect                   | WorkFunction           | WorkChain                     | WorkTree               |\n| ------------------------ | ---------------------- | ----------------------------- | ---------------------- |\n| Use Case                 | Short-running jobs     | Long-running jobs             | Long-running jobs      |\n| Checkpointing            | ``No``                 | Yes                           | Yes                    |\n| Execution order          | ``Sequential``         | ``Hybrid Sequential-Parallel``| Directed Acyclic Graph |\n| Non-blocking             | ``No``                 | Yes                           | Yes                    |\n| Implementation           | Easy                   | ``Difficult``                 | Easy                   |\n| Dynamic                  | ``No``                 | ``No``                        | Yes                    |\n| Ready to Use             | Yes                    | ``Need PYTHONPATH``           | Yes                    |\n| Subprocesses Handling    | ``No``                 | Launches & waits              | Launches & waits       |\n| Flow Control             | All                    | `if`, `while`                 | `if`, `while`, `match` |\n| Termination              | ``Hard exit``          | ExitCode                      | ExitCode               |\n| Data Passing             | Direct passing         | Context                       | Link & Context         |\n| Output Recording         | Limited support        | Out & validates               | Out                    |\n| Port Exposing            | Limited support        | Manual & automatic            | Manual                 |\n\n\n\n## Installation\n\n```console\n    pip install aiida-worktree\n```\n\nTo install the latest version from source, first clone the repository and then install using `pip`:\n\n```console\ngit clone https://github.com/superstar54/aiida-worktree\ncd aiida-worktree\npip install -e .\n```\nIn order to use the widget, you also need to run:\n```console\ncd aiida_worktree/widget/\nnpm install\nnpm run build\n```\n\n## Documentation\nCheck the [docs](https://aiida-worktree.readthedocs.io/en/latest/) and learn about the features.\n\n## Examples\n\nCreate calcfunction nodes:\n\n```python\nfrom aiida_worktree import node\n\n# define add calcfunction node\n@node.calcfunction()\ndef add(x, y):\n    return x + y\n\n# define multiply calcfunction node\n@node.calcfunction()\ndef multiply(x, y):\n    return x*y\n\n```\n\nCreate a worktree to link the nodes.\n\n```python\nfrom aiida_worktree import WorkTree\nfrom aiida import load_profile\nfrom aiida.orm import Int\nload_profile()\n\n\nwt = WorkTree(\"test_add_multiply\")\nwt.nodes.new(add, name=\"add1\", x=Int(2.0), y=Int(3.0))\nwt.nodes.new(multiply, name=\"multiply1\", y=Int(4.0))\nwt.links.new(wt.nodes[\"add1\"].outputs[0], wt.nodes[\"multiply1\"].inputs[\"x\"])\nwt.submit(wait=True)\n```\n\nStart the web app, open a terminal and run:\n```console\nworktree web start\n```\n\nThen visit the page http://127.0.0.1:8000/worktree, you should find a `first_workflow` Worktree, click the pk and view the WorkTree.\n\n<img src=\"docs/source/_static/images/first-workflow.png\" />\n\n\nOne can also generate the node graph from the process:\n```console\nverdi node generate pk\n```\n\n<img src=\"docs/source/_static/images/add_multiply.png\"/>\n\n\n## Development\n\n### Pre-commit and Tests\nTo contribute to this repository, please enable pre-commit so the code in commits are conform to the standards.\n```console\npip install -e .[tests, pre-commit]\npre-commit install\n```\n\n### Web app\nSee the [README.md](https://github.com/superstar54/aiida-worktree/blob/main/aiida_worktree/web/README.md)\n\n### Build and publish\nBuild package:\n```console\npip install build\npython -m build\n```\nUpload to PyPI:\n```console\npip install twine\ntwine upload dist/*\n```\n\n## License\n[MIT](http://opensource.org/licenses/MIT)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Design flexible node-based workflow for AiiDA calculation.",
    "version": "0.1.8",
    "project_urls": {
        "Documentation": "https://aiida-worktree.readthedocs.io",
        "Source": "https://github.com/superstart54/aiida-worktree"
    },
    "split_keywords": [
        "aiida",
        " workflows"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0dbe457eb1b5552b1f2933c63d558b70aaf258b8097a0879e143896365a31166",
                "md5": "cd262d5d861f23542dd14748d0123b19",
                "sha256": "74d567a47007767cb5397695d7b75c50f76593b7c37a4600013bb0daedef5429"
            },
            "downloads": -1,
            "filename": "aiida_worktree-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cd262d5d861f23542dd14748d0123b19",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5771819,
            "upload_time": "2024-04-19T05:22:20",
            "upload_time_iso_8601": "2024-04-19T05:22:20.009977Z",
            "url": "https://files.pythonhosted.org/packages/0d/be/457eb1b5552b1f2933c63d558b70aaf258b8097a0879e143896365a31166/aiida_worktree-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2c6583cc44ebfd56bd50153660cf3ef01658fd34be776b0c8f5b76f5b9829b13",
                "md5": "2879e612b61610beee31782855c8f173",
                "sha256": "fc7ce87f3cae1894bfeda2df0ae4624cb13b7faa82681f9b6bc073d961e4aaba"
            },
            "downloads": -1,
            "filename": "aiida_worktree-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "2879e612b61610beee31782855c8f173",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5690013,
            "upload_time": "2024-04-19T05:22:27",
            "upload_time_iso_8601": "2024-04-19T05:22:27.955139Z",
            "url": "https://files.pythonhosted.org/packages/2c/65/83cc44ebfd56bd50153660cf3ef01658fd34be776b0c8f5b76f5b9829b13/aiida_worktree-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-19 05:22:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "superstart54",
    "github_project": "aiida-worktree",
    "github_not_found": true,
    "lcname": "aiida-worktree"
}
        
Elapsed time: 0.26525s