# pipen-diagram
Draw pipeline diagrams for [pipen][1].
## Features
- Diagram theming
- Hiding processes from diagram
## Configurations
- `diagram_theme`: The name of the theme to use, or a dict of a custom theme.
- See `pipen_diagram/diagram.py` for the a theme definition
- See [https://graphviz.org/][2] for theme items
- `diagram_savedot`: Whhether to save the dot file (for debugging purpose)
- `diagram_hide`: Process-level item, whether to hide current process from the diagram
## Installation
```shell
pip install -U pipen-diagram
```
## Enabling/Disabling the plugin
The plugin is registered via entrypoints. It's by default enabled. To disable it:
`plugins=[..., "no:diagram"]`, or uninstall this plugin.
## Usage
`example.py`
```python
from pipen import Proc, Pipen, ProcGroup
class A(Proc):
"""Process A"""
input = "a"
class B(Proc):
"""Process B"""
requires = A
input = "b"
plugin_opts = {"diagram_hide": True}
class PG(ProcGroup):
"""Process Group"""
@ProcGroup.add_proc
def c(self):
"""Process C"""
class C(Proc):
input = "c"
return C
@ProcGroup.add_proc
def c1(self):
"""Process C1"""
class C1(Proc):
requires = self.c
input = "c1"
plugin_opts = {"diagram_hide": True}
return C1
@ProcGroup.add_proc
def d(self):
"""Process D"""
class D(Proc):
input = "d"
requires = self.c1
return D
pg = PG()
pg.c.requires = B
class E(Proc):
"""Process E"""
input = "e1,e2"
requires = pg.d, A
class F(Proc):
"""Process F"""
input = "f"
requires = E
Pipen("MyPipeline").set_start(A).run()
# Dark theme
# Pipen("MyPipeline", plugin_opts={"diagram_theme": "dark"}).set_start(A).run()
```
Running `python example.py` will generate `MyPipeline-output/diagram.svg`:
| Default theme | Dark theme | Fancy theme | Fancy dark theme |
| ------------- | ---------- | ----------- | ---------------- |
| ![diagram](./diagram.svg) | ![diagram_dark](./diagram_dark.svg) | ![diagram_fancy](./diagram_fancy.svg) | ![diagram_fancy_dark](./diagram_fancy_dark.svg) |
[1]: https://github.com/pwwang/pipen
[2]: https://graphviz.org/
Raw data
{
"_id": null,
"home_page": "https://github.com/pwwang/pipen-diagram",
"name": "pipen-diagram",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "pwwang",
"author_email": "pwwang@pwwang.com",
"download_url": "https://files.pythonhosted.org/packages/32/12/e543804f50dc1bcc6741a28f4d13abdc433114b705c4507a241db8c5110e/pipen_diagram-0.12.0.tar.gz",
"platform": null,
"description": "# pipen-diagram\n\nDraw pipeline diagrams for [pipen][1].\n\n## Features\n\n- Diagram theming\n- Hiding processes from diagram\n\n## Configurations\n\n- `diagram_theme`: The name of the theme to use, or a dict of a custom theme.\n - See `pipen_diagram/diagram.py` for the a theme definition\n - See [https://graphviz.org/][2] for theme items\n- `diagram_savedot`: Whhether to save the dot file (for debugging purpose)\n- `diagram_hide`: Process-level item, whether to hide current process from the diagram\n\n## Installation\n\n```shell\npip install -U pipen-diagram\n```\n\n## Enabling/Disabling the plugin\n\nThe plugin is registered via entrypoints. It's by default enabled. To disable it:\n`plugins=[..., \"no:diagram\"]`, or uninstall this plugin.\n\n## Usage\n\n`example.py`\n\n```python\nfrom pipen import Proc, Pipen, ProcGroup\n\n\nclass A(Proc):\n \"\"\"Process A\"\"\"\n input = \"a\"\n\n\nclass B(Proc):\n \"\"\"Process B\"\"\"\n requires = A\n input = \"b\"\n plugin_opts = {\"diagram_hide\": True}\n\n\nclass PG(ProcGroup):\n \"\"\"Process Group\"\"\"\n @ProcGroup.add_proc\n def c(self):\n \"\"\"Process C\"\"\"\n class C(Proc):\n input = \"c\"\n\n return C\n\n @ProcGroup.add_proc\n def c1(self):\n \"\"\"Process C1\"\"\"\n class C1(Proc):\n requires = self.c\n input = \"c1\"\n plugin_opts = {\"diagram_hide\": True}\n\n return C1\n\n @ProcGroup.add_proc\n def d(self):\n \"\"\"Process D\"\"\"\n class D(Proc):\n input = \"d\"\n requires = self.c1\n\n return D\n\n\npg = PG()\npg.c.requires = B\n\n\nclass E(Proc):\n \"\"\"Process E\"\"\"\n input = \"e1,e2\"\n requires = pg.d, A\n\n\nclass F(Proc):\n \"\"\"Process F\"\"\"\n input = \"f\"\n requires = E\n\n\nPipen(\"MyPipeline\").set_start(A).run()\n# Dark theme\n# Pipen(\"MyPipeline\", plugin_opts={\"diagram_theme\": \"dark\"}).set_start(A).run()\n```\n\nRunning `python example.py` will generate `MyPipeline-output/diagram.svg`:\n\n| Default theme | Dark theme | Fancy theme | Fancy dark theme |\n| ------------- | ---------- | ----------- | ---------------- |\n| ![diagram](./diagram.svg) | ![diagram_dark](./diagram_dark.svg) | ![diagram_fancy](./diagram_fancy.svg) | ![diagram_fancy_dark](./diagram_fancy_dark.svg) |\n\n[1]: https://github.com/pwwang/pipen\n[2]: https://graphviz.org/\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Draw pipeline diagrams for pipen.",
"version": "0.12.0",
"project_urls": {
"Homepage": "https://github.com/pwwang/pipen-diagram",
"Repository": "https://github.com/pwwang/pipen-diagram"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8d0b591c43d7c5dd976a0e33cde4522cd0bbdc80e8b56b69eeea4c80491cf0b8",
"md5": "a49e8dea4dc5247724be55ce22c6dd85",
"sha256": "ca208c8968b09dd29ccdea1ea3334b4494d971b2714f89165df78687fea31525"
},
"downloads": -1,
"filename": "pipen_diagram-0.12.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a49e8dea4dc5247724be55ce22c6dd85",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 6037,
"upload_time": "2024-07-23T22:51:42",
"upload_time_iso_8601": "2024-07-23T22:51:42.109635Z",
"url": "https://files.pythonhosted.org/packages/8d/0b/591c43d7c5dd976a0e33cde4522cd0bbdc80e8b56b69eeea4c80491cf0b8/pipen_diagram-0.12.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3212e543804f50dc1bcc6741a28f4d13abdc433114b705c4507a241db8c5110e",
"md5": "a6cf38473a5bbef95bdb99309e31df6e",
"sha256": "deb03e8e674c11b3b970655e7872bb8006cb4406caf63069dce013cdb86ec1f4"
},
"downloads": -1,
"filename": "pipen_diagram-0.12.0.tar.gz",
"has_sig": false,
"md5_digest": "a6cf38473a5bbef95bdb99309e31df6e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 5695,
"upload_time": "2024-07-23T22:51:43",
"upload_time_iso_8601": "2024-07-23T22:51:43.306076Z",
"url": "https://files.pythonhosted.org/packages/32/12/e543804f50dc1bcc6741a28f4d13abdc433114b705c4507a241db8c5110e/pipen_diagram-0.12.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-23 22:51:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pwwang",
"github_project": "pipen-diagram",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pipen-diagram"
}