plumcraft-engine 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- plumcraft_engine-0.1.0/.gitignore +17 -0
- plumcraft_engine-0.1.0/LICENSE-APACHE +202 -0
- plumcraft_engine-0.1.0/LICENSE-MIT +21 -0
- plumcraft_engine-0.1.0/PKG-INFO +161 -0
- plumcraft_engine-0.1.0/README.md +133 -0
- plumcraft_engine-0.1.0/pyproject.toml +64 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/__init__.py +546 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/arrays.py +249 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/audio.py +72 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/bind.py +147 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/cli.py +399 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/color.py +505 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/conformance.py +357 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/data.py +498 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/declare.py +704 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/exec.py +1011 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/files.py +430 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/host.py +402 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/http.py +215 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/image.py +62 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/media.py +73 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/memo.py +99 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/new.py +460 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/persist.py +151 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/scratch.py +56 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/seq.py +308 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/serve.py +190 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/slices.py +64 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/svg.py +64 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/README.md.tmpl +90 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/conftest.py.tmpl +20 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/engine.py.tmpl +16 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/array.py.tmpl +14 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/audio.py.tmpl +18 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/audio_array.py.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/helpers_image.py.tmpl +15 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/helpers_list.py.tmpl +41 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/helpers_svg.py.tmpl +2 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/image.py.tmpl +14 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/image_array.py.tmpl +14 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/json.py.tmpl +14 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/json_text.py.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/scalars.py.tmpl +20 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/slow_scalars.py.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/slow_text.py.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/svg.py.tmpl +17 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/svg_text.py.tmpl +10 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/table.py.tmpl +23 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/table_array.py.tmpl +18 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/table_text.py.tmpl +25 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_array.py.tmpl +10 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_audio.py.tmpl +7 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_image.py.tmpl +6 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_json.py.tmpl +6 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_list.py.tmpl +8 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_scalars.py.tmpl +14 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_svg.py.tmpl +8 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_table.py.tmpl +7 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_nodes_text.py.tmpl +12 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_audio_array.py.tmpl +6 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_image_array.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_json_text.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_list.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_scalars.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_svg_text.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_table_array.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_table_text.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/test_pairs_text.py.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/fragments/text.py.tmpl +32 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/gitignore.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/main.py.tmpl +15 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/plumcraft-engine.toml.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/idea.gitignore.tmpl +4 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/module.iml.tmpl +12 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/module.run.xml.tmpl +24 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/modules.xml.tmpl +8 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/pytest.run.xml.tmpl +19 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pycharm/shell.run.xml.tmpl +17 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/pyproject.toml.tmpl +39 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/_plumcraft.sh.tmpl +23 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/check.tmpl +7 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/cli-run.tmpl +9 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/conform.tmpl +12 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/editor.tmpl +9 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/install.tmpl +8 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/nodes.tmpl +5 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/run.tmpl +13 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/serve.tmpl +9 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/scripts/uninstall.tmpl +10 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/test_conformance.py.tmpl +9 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/test_engine.py.tmpl +30 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/test_nodes.py.tmpl +4 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/templates/engine/test_roundtrips.py.tmpl +4 -0
- plumcraft_engine-0.1.0/src/plumcraft_engine/vary.py +390 -0
- plumcraft_engine-0.1.0/src/plumcraft_text/__init__.py +131 -0
- plumcraft_engine-0.1.0/src/plumcraft_text/__main__.py +15 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.gitignore +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.idea/.gitignore +4 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.idea/modules.xml +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.idea/weather-engine.iml +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.python-version +1 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Conformance.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Editor.run.xml +17 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Nodes.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Run demo (attached).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Run demo.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Serve (HTTP 7311).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/.run/Tests.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/README.md +90 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/examples/demo.json +385 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/plumcraft-engine.toml +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/pyproject.toml +43 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/_plumcraft.sh +23 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/check +7 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/cli-run +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/conform +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/editor +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/install +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/nodes +5 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/run +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/serve +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/scripts/uninstall +10 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/src/weather_engine/__init__.py +373 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/src/weather_engine/__main__.py +15 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/conftest.py +20 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/golden/schema.json +1691 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/test_conformance.py +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/test_engine.py +30 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/test_nodes.py +85 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/all/tests/test_roundtrips.py +51 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.gitignore +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.idea/.gitignore +4 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.idea/modules.xml +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.idea/weather-engine.iml +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.python-version +1 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Conformance.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Editor.run.xml +17 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Nodes.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Run demo (attached).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Run demo.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Serve (HTTP 7311).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/.run/Tests.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/README.md +90 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/examples/demo.json +56 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/plumcraft-engine.toml +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/pyproject.toml +43 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/_plumcraft.sh +23 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/check +7 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/cli-run +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/conform +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/editor +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/install +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/nodes +5 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/run +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/serve +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/scripts/uninstall +10 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/src/weather_engine/__init__.py +51 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/src/weather_engine/__main__.py +15 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/conftest.py +20 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/golden/schema.json +136 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/test_conformance.py +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/test_engine.py +30 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/test_nodes.py +18 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/scalars/tests/test_roundtrips.py +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.gitignore +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.idea/.gitignore +4 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.idea/modules.xml +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.idea/weather-engine.iml +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.python-version +1 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Conformance.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Editor.run.xml +17 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Nodes.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Run demo (attached).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Run demo.run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Serve (HTTP 7311).run.xml +24 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/.run/Tests.run.xml +19 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/README.md +90 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/examples/demo.json +104 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/plumcraft-engine.toml +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/pyproject.toml +43 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/_plumcraft.sh +23 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/check +7 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/cli-run +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/conform +12 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/editor +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/install +8 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/nodes +5 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/run +13 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/serve +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/scripts/uninstall +10 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/src/weather_engine/__init__.py +83 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/src/weather_engine/__main__.py +15 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/conftest.py +20 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/golden/schema.json +249 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/test_conformance.py +9 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/test_engine.py +30 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/test_nodes.py +30 -0
- plumcraft_engine-0.1.0/tests/golden/new_engine/text/tests/test_roundtrips.py +13 -0
- plumcraft_engine-0.1.0/tests/golden/text_schema.json +1173 -0
- plumcraft_engine-0.1.0/tests/scratch.py +5 -0
- plumcraft_engine-0.1.0/tests/test_audio.py +145 -0
- plumcraft_engine-0.1.0/tests/test_bind.py +213 -0
- plumcraft_engine-0.1.0/tests/test_cli.py +129 -0
- plumcraft_engine-0.1.0/tests/test_color.py +100 -0
- plumcraft_engine-0.1.0/tests/test_conformance.py +183 -0
- plumcraft_engine-0.1.0/tests/test_declare.py +461 -0
- plumcraft_engine-0.1.0/tests/test_engine.py +302 -0
- plumcraft_engine-0.1.0/tests/test_memo.py +71 -0
- plumcraft_engine-0.1.0/tests/test_new_engine.py +262 -0
- plumcraft_engine-0.1.0/tests/test_persist.py +132 -0
- plumcraft_engine-0.1.0/tests/test_scratch.py +40 -0
- plumcraft_engine-0.1.0/tests/test_store_z.py +68 -0
- plumcraft_engine-0.1.0/tests/test_svg.py +185 -0
- plumcraft_engine-0.1.0/tests/test_vary.py +619 -0
- plumcraft_engine-0.1.0/uv.lock +384 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/target/
|
|
2
|
+
target/
|
|
3
|
+
**/.venv/
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.pyc
|
|
6
|
+
.DS_Store
|
|
7
|
+
# claude-debug: notes (.md) are tracked; code and data are not
|
|
8
|
+
claude-debug/*
|
|
9
|
+
!claude-debug/*.md
|
|
10
|
+
# rendered reports (the .md is the source)
|
|
11
|
+
docs/**/*.pdf
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
|
|
15
|
+
# local, not part of the project
|
|
16
|
+
/.idea/
|
|
17
|
+
/synesthesia.png
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2026 by Sean D. True and Swapwizard LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: plumcraft-engine
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: PlumCraft's Python engine SDK and the text engine in Python, speaking protocol 2 over the mode 2 socket binding, with blobs in commonkit
|
|
5
|
+
Project-URL: Homepage, https://github.com/seantrue/plumcraft
|
|
6
|
+
Project-URL: Repository, https://github.com/seantrue/plumcraft
|
|
7
|
+
Project-URL: Issues, https://github.com/seantrue/plumcraft/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/seantrue/plumcraft/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Sean D. True, Swapwizard LLC
|
|
10
|
+
License-Expression: MIT OR Apache-2.0
|
|
11
|
+
License-File: LICENSE-APACHE
|
|
12
|
+
License-File: LICENSE-MIT
|
|
13
|
+
Keywords: node editor,node graph,plumcraft,workflow
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Requires-Dist: pillow>=10
|
|
26
|
+
Requires-Dist: pyuncommonkit>=0.1
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# PlumCraft engines in Python
|
|
30
|
+
|
|
31
|
+
`plumcraft_engine` is PlumCraft's engine SDK in Python: protocol 2's executor, host, the mode 2 socket and mode 3 HTTP fronts, and blobs in commonkit. `plumcraft_text` is the text engine written with it, kept byte-identical on the wire to the Rust `plumcraft-text` by the conformance suite (`cargo test -p plumcraft-text`).
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pip install plumcraft-engine
|
|
37
|
+
plumcraft-engine new my-engine --name Mine # a whole engine project, with tests and scripts
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Python 3.11 or later. Running an engine needs only this package. The editor is Rust: see [PlumCraft](https://github.com/seantrue/plumcraft) to build it.
|
|
41
|
+
|
|
42
|
+
## An engine in 20 lines
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import sys
|
|
46
|
+
from typing import Annotated, Literal
|
|
47
|
+
|
|
48
|
+
from plumcraft_engine import ConfigError, Cx, Engine, Range, WireType, node
|
|
49
|
+
|
|
50
|
+
Text = Annotated[str, WireType("TEXT", media="text", color="#c9a227", thumb=True)]
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Shout(Engine):
|
|
54
|
+
id, name, version = "shout", "Shout", "0.1.0"
|
|
55
|
+
category = "Text"
|
|
56
|
+
|
|
57
|
+
@node("Loud")
|
|
58
|
+
def loud(self, text: Text, marks: Annotated[int, Range(0, 5)] = 1, case: Literal["upper", "title"] = "upper") -> Text:
|
|
59
|
+
"""Shout the text."""
|
|
60
|
+
if not text:
|
|
61
|
+
raise ConfigError("nothing to shout")
|
|
62
|
+
return (text.upper() if case == "upper" else text.title()) + "!" * marks
|
|
63
|
+
|
|
64
|
+
@node("Wait")
|
|
65
|
+
def wait(self, text: Text, seconds: float = 1.0, *, cx: Cx) -> Text:
|
|
66
|
+
cx.progress(0.5, "waiting")
|
|
67
|
+
return text
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
if __name__ == "__main__":
|
|
71
|
+
sys.exit(Shout.serve())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
That is the whole engine. The class is compiled when it is defined: each `@node` method becomes a NodeDef (`shout.loud`: a `TEXT` socket, an `INT` widget with `min`/`max`, an `ENUM` widget with choices, a `TEXT` output), and each mistake raises `DeclarationError` at import, not mid-run. `Shout()` builds the engine; `Shout` itself is the factory `Host` and the bindings take.
|
|
75
|
+
|
|
76
|
+
## Ports from annotations
|
|
77
|
+
|
|
78
|
+
| Python | Port |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `str`, `int`, `float`, `bool` | `STRING`, `INT`, `FLOAT`, `BOOL`: a widget that can also be wired (no `socket` field, the proto's default) |
|
|
81
|
+
| `Literal["a", "b"]` | `ENUM` with `choices: ["a", "b"]` |
|
|
82
|
+
| `Annotated[T, WireType("ID", media=...)]` alias | a socket of type `ID` (`socket: "socket"`); declare the alias once, at module level |
|
|
83
|
+
| `String`, `Int`, `Float`, `Bool` (from the SDK) | the scalar types as explicit aliases, for `wires` and annotations |
|
|
84
|
+
| `Text`, `Table`, `Image`, `Audio`, `Array`, `Svg`, `Json` (from the SDK) | the core types, exactly as every engine declares them (`docs/interface.md`): a node takes and returns a `str`, a columnar table `dict`, an encoded-picture `Blob` (make one with `image(data)`), an `AudioValue(samples, sample_rate)`, an ndarray or `ArrayValue`, an SVG `Blob` (`svg(text)`), and any JSON value |
|
|
85
|
+
| `= default` | `default` (an `int` default on a `float` port becomes a float) |
|
|
86
|
+
| `X \| None = None` | `optional: true` |
|
|
87
|
+
| `Annotated[float, Range(0, 1, 0.1)]` | `min`, `max`, `step` |
|
|
88
|
+
| `Annotated[str, File("open", (("Text", ("txt",)),))]` | `path: {mode, filters}`; `open`, `save` or `dir` |
|
|
89
|
+
| `Annotated[T, Port(label=, tooltip=, advanced=, socket=, name=, decimals=)]` | those fields |
|
|
90
|
+
| a parameter annotated with a `@dataclass` | one port per field (with the field's annotation and default); the method receives the dataclass |
|
|
91
|
+
| a parameter named `cx` (or annotated `Cx`) | not a port: the node's `Cx`, for `cx.progress(f, stage)` and `cx.cancelled()` |
|
|
92
|
+
| `with_` | the port `with` (one trailing underscore is dropped, for keywords) |
|
|
93
|
+
|
|
94
|
+
Outputs come from the return annotation:
|
|
95
|
+
|
|
96
|
+
| Return | Outputs |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `-> Text` (any port type) | one output, named after the wire type's id in lower case (`text`), or `@node(output="name")` |
|
|
99
|
+
| `-> Pair` (a `NamedTuple`) | one output per field, typed by the field; return the tuple. `output=("a", "b")` renames them |
|
|
100
|
+
| `-> None` | none (a sink) |
|
|
101
|
+
|
|
102
|
+
## `@node` options
|
|
103
|
+
|
|
104
|
+
`@node` alone, or `@node("Display name", ...)` with any of: `id` (default `<engine id>.<method>`), `category` (a string or a path; default the engine's `category`), `description` (default the docstring), `output`, `family` and `icon` (default the engine's), `version` (part of the memo key; bump it when results change), `memo` (a scope such as `"none"`, or a whole `memo` object), `flags`, `x` (passed through).
|
|
105
|
+
|
|
106
|
+
Engine class attributes: `id`, `name`, `version`, `salt` (default `py:<id>+<version>`), `dependencies` (the packages results depend on, such as `("opencv-python-headless",)`: their versions join the memo salt, so an upgrade never reuses an old result), `category`, `family`, `icon`, and `wires`: the wire types in catalogue order. Without `wires`, the catalogue lists the types in the order the nodes first use them; with it, a node using a type not listed is a `DeclarationError`. Subclasses inherit nodes and may override them.
|
|
107
|
+
|
|
108
|
+
## Values and errors
|
|
109
|
+
|
|
110
|
+
Before the method runs, every input is checked against its port:
|
|
111
|
+
|
|
112
|
+
- a `str` port (or a wire type over `str`) receives any value as text: strings as they are, other values as compact JSON;
|
|
113
|
+
- an `int`, `float`, `bool` or `Literal` port that gets the wrong type, or a number outside its `Range`, fails the node with a `config` error naming the port (`marks: 9 is outside 0..5`);
|
|
114
|
+
- `Range(..., invalid="clamp")` clamps instead, and replaces a wrong type with the default; `Range(..., invalid="pass")` makes the range a UI hint only and hands the value over as it is.
|
|
115
|
+
|
|
116
|
+
Raise `ConfigError("...")` for a setting the user can fix, `OpError("...")` for a failure on this input, or `NodeError.cancelled()` when `cx.cancelled()`. Any other exception fails the node as `op` with its type and message, and the engine carries on.
|
|
117
|
+
|
|
118
|
+
## Serving
|
|
119
|
+
|
|
120
|
+
`MyEngine.serve()` reads the command line: `--connect unix:<path>` (or `PLUMCRAFT_ENGINE_SOCKET` and `PLUMCRAFT_ENGINE_TOKEN`) serves mode 2, `--listen host:port [--port-file f] [--lifeline]` serves mode 3. In a test, `Host(MyEngine)` runs it in process.
|
|
121
|
+
|
|
122
|
+
**Pictures on nodes:** a picture file's value shows a thumbnail when it carries one. Make it with `image(data, pixels=array)`, or override `Engine.picture_thumb(blob)` to give Load Files' values one, returning (h, w, 4) uint8; the SDK itself decodes no pictures.
|
|
123
|
+
|
|
124
|
+
## From the command line
|
|
125
|
+
|
|
126
|
+
`plumcraft-engine` drives an engine with no Rust build:
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
uv run plumcraft-engine nodes # the catalogue
|
|
130
|
+
uv run plumcraft-engine run # the [tool.plumcraft] demo, events as they come
|
|
131
|
+
uv run plumcraft-engine run my.json --watch shout.text # a workflow, with a value watched
|
|
132
|
+
uv run plumcraft-engine run my.json --cancel-after 0.5 --raw # cancel mid-run; every event as JSON
|
|
133
|
+
uv run plumcraft-engine run my.json --attach http://127.0.0.1:7311 # an engine serving --listen
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
- **The engine:** `--engine module:Class`, else `[tool.plumcraft] engine` in the nearest `pyproject.toml` (this one names `plumcraft_text:TextEngine`, with `demo = "../examples/data.json"`). It runs in process, as the editor's in-process mode does; `--attach URL` talks to one already serving HTTP, with `PLUMCRAFT_ENGINE_TOKEN` when set.
|
|
137
|
+
- **The workflow:** path inputs relative to the workflow's folder are made absolute, as `plumcraft run` does.
|
|
138
|
+
- **The exit code:** 0 when every node is `done` or `cached`, 1 when one isn't, 2 when the engine or workflow can't be had. A script can use `run` as a smoke test.
|
|
139
|
+
|
|
140
|
+
## A new engine
|
|
141
|
+
|
|
142
|
+
```sh
|
|
143
|
+
uv run --project ~/workspace/plumcraft/python plumcraft-engine new ~/workspace/weather-engine --name Weather --types text
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
This writes a standalone uv project that depends on this SDK, which `scripts/editor` opens in PlumCraft's editor, the editor starting the engine from its manifest: the engine with example nodes for each type, its tests (including a golden catalogue and conformance), a demo workflow, scripts for testing from the command line, PyCharm run configurations, a README for the developer, and the engine manifest. It refuses a directory with something in it and ids PlumCraft already uses, and a failure leaves nothing behind.
|
|
147
|
+
|
|
148
|
+
- **`--types`:** `text`, `table`, `array`, `svg`, `image` (adds pillow), `audio`, `json`, `list` (brings `text`), `any` (the building blocks), comma-separated. Scalars are always on. A conversion is generated when both its types are chosen, always with its inverse: `table`↔`text` (CSV), `table`↔`array`, `svg`↔`text`, `image`↔`array`, `audio`↔`array`, `json`↔`text`.
|
|
149
|
+
- **The other options:** `--id`, `--name`, `--package`, `--sdk pypi|path|git[@REV]`, `--python`, `--no-pycharm`, `--git`.
|
|
150
|
+
|
|
151
|
+
`uv run plumcraft-engine check` runs PlumCraft's conformance cases against an engine, in process and over HTTP (`--mode` for one): the session, core types declared exactly, every node on its defaults, the demo, cancel, answers off the run path, and hostile widget values. It needs only the catalogue, plus `[tool.plumcraft] demo` and `[tool.plumcraft.conformance] slow` when set; in a test, `plumcraft_engine.conformance.assert_conformant(MyEngine, demo=..., slow=...)` fails naming every failed case.
|
|
152
|
+
|
|
153
|
+
## Alternatives considered
|
|
154
|
+
|
|
155
|
+
1. **A parameters dataclass per node as the only form** (the research software's `parameters = AnnealParameters`). It reads well with ten settings and badly with one, and it splits a node's inputs between the signature (sockets) and the dataclass (widgets). It is supported as a parameter type for nodes with many settings.
|
|
156
|
+
2. **`Port(...)` as the default** (`find: str = Port("", label="Find")`, as typer and pydantic do). It hides the real default from type checkers and from readers. `Annotated` keeps the default a default.
|
|
157
|
+
3. **Signatures plus `Annotated`** (chosen): the method is an ordinary typed function a type checker understands, the port list is the parameter list, and metadata sits beside the type it qualifies.
|
|
158
|
+
|
|
159
|
+
## The low-level layer
|
|
160
|
+
|
|
161
|
+
The decorators compile to the layer underneath, which stays and is the escape hatch: a `Node` subclass with a `definition` dict (a NodeDef in protocol 2's JSON) and `run(inputs, cx) -> dict`, or `simple(definition, fn)`, added with `engine.with_node(...)` to a declared engine or to `Engine(info)`. Use it for what a signature can't say yet: variadic ports, `options`, `list` ports, `active_when`, `disabled_choices`, or ports whose shape depends on configuration.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# PlumCraft engines in Python
|
|
2
|
+
|
|
3
|
+
`plumcraft_engine` is PlumCraft's engine SDK in Python: protocol 2's executor, host, the mode 2 socket and mode 3 HTTP fronts, and blobs in commonkit. `plumcraft_text` is the text engine written with it, kept byte-identical on the wire to the Rust `plumcraft-text` by the conformance suite (`cargo test -p plumcraft-text`).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pip install plumcraft-engine
|
|
9
|
+
plumcraft-engine new my-engine --name Mine # a whole engine project, with tests and scripts
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Python 3.11 or later. Running an engine needs only this package. The editor is Rust: see [PlumCraft](https://github.com/seantrue/plumcraft) to build it.
|
|
13
|
+
|
|
14
|
+
## An engine in 20 lines
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
import sys
|
|
18
|
+
from typing import Annotated, Literal
|
|
19
|
+
|
|
20
|
+
from plumcraft_engine import ConfigError, Cx, Engine, Range, WireType, node
|
|
21
|
+
|
|
22
|
+
Text = Annotated[str, WireType("TEXT", media="text", color="#c9a227", thumb=True)]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class Shout(Engine):
|
|
26
|
+
id, name, version = "shout", "Shout", "0.1.0"
|
|
27
|
+
category = "Text"
|
|
28
|
+
|
|
29
|
+
@node("Loud")
|
|
30
|
+
def loud(self, text: Text, marks: Annotated[int, Range(0, 5)] = 1, case: Literal["upper", "title"] = "upper") -> Text:
|
|
31
|
+
"""Shout the text."""
|
|
32
|
+
if not text:
|
|
33
|
+
raise ConfigError("nothing to shout")
|
|
34
|
+
return (text.upper() if case == "upper" else text.title()) + "!" * marks
|
|
35
|
+
|
|
36
|
+
@node("Wait")
|
|
37
|
+
def wait(self, text: Text, seconds: float = 1.0, *, cx: Cx) -> Text:
|
|
38
|
+
cx.progress(0.5, "waiting")
|
|
39
|
+
return text
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
sys.exit(Shout.serve())
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
That is the whole engine. The class is compiled when it is defined: each `@node` method becomes a NodeDef (`shout.loud`: a `TEXT` socket, an `INT` widget with `min`/`max`, an `ENUM` widget with choices, a `TEXT` output), and each mistake raises `DeclarationError` at import, not mid-run. `Shout()` builds the engine; `Shout` itself is the factory `Host` and the bindings take.
|
|
47
|
+
|
|
48
|
+
## Ports from annotations
|
|
49
|
+
|
|
50
|
+
| Python | Port |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `str`, `int`, `float`, `bool` | `STRING`, `INT`, `FLOAT`, `BOOL`: a widget that can also be wired (no `socket` field, the proto's default) |
|
|
53
|
+
| `Literal["a", "b"]` | `ENUM` with `choices: ["a", "b"]` |
|
|
54
|
+
| `Annotated[T, WireType("ID", media=...)]` alias | a socket of type `ID` (`socket: "socket"`); declare the alias once, at module level |
|
|
55
|
+
| `String`, `Int`, `Float`, `Bool` (from the SDK) | the scalar types as explicit aliases, for `wires` and annotations |
|
|
56
|
+
| `Text`, `Table`, `Image`, `Audio`, `Array`, `Svg`, `Json` (from the SDK) | the core types, exactly as every engine declares them (`docs/interface.md`): a node takes and returns a `str`, a columnar table `dict`, an encoded-picture `Blob` (make one with `image(data)`), an `AudioValue(samples, sample_rate)`, an ndarray or `ArrayValue`, an SVG `Blob` (`svg(text)`), and any JSON value |
|
|
57
|
+
| `= default` | `default` (an `int` default on a `float` port becomes a float) |
|
|
58
|
+
| `X \| None = None` | `optional: true` |
|
|
59
|
+
| `Annotated[float, Range(0, 1, 0.1)]` | `min`, `max`, `step` |
|
|
60
|
+
| `Annotated[str, File("open", (("Text", ("txt",)),))]` | `path: {mode, filters}`; `open`, `save` or `dir` |
|
|
61
|
+
| `Annotated[T, Port(label=, tooltip=, advanced=, socket=, name=, decimals=)]` | those fields |
|
|
62
|
+
| a parameter annotated with a `@dataclass` | one port per field (with the field's annotation and default); the method receives the dataclass |
|
|
63
|
+
| a parameter named `cx` (or annotated `Cx`) | not a port: the node's `Cx`, for `cx.progress(f, stage)` and `cx.cancelled()` |
|
|
64
|
+
| `with_` | the port `with` (one trailing underscore is dropped, for keywords) |
|
|
65
|
+
|
|
66
|
+
Outputs come from the return annotation:
|
|
67
|
+
|
|
68
|
+
| Return | Outputs |
|
|
69
|
+
|---|---|
|
|
70
|
+
| `-> Text` (any port type) | one output, named after the wire type's id in lower case (`text`), or `@node(output="name")` |
|
|
71
|
+
| `-> Pair` (a `NamedTuple`) | one output per field, typed by the field; return the tuple. `output=("a", "b")` renames them |
|
|
72
|
+
| `-> None` | none (a sink) |
|
|
73
|
+
|
|
74
|
+
## `@node` options
|
|
75
|
+
|
|
76
|
+
`@node` alone, or `@node("Display name", ...)` with any of: `id` (default `<engine id>.<method>`), `category` (a string or a path; default the engine's `category`), `description` (default the docstring), `output`, `family` and `icon` (default the engine's), `version` (part of the memo key; bump it when results change), `memo` (a scope such as `"none"`, or a whole `memo` object), `flags`, `x` (passed through).
|
|
77
|
+
|
|
78
|
+
Engine class attributes: `id`, `name`, `version`, `salt` (default `py:<id>+<version>`), `dependencies` (the packages results depend on, such as `("opencv-python-headless",)`: their versions join the memo salt, so an upgrade never reuses an old result), `category`, `family`, `icon`, and `wires`: the wire types in catalogue order. Without `wires`, the catalogue lists the types in the order the nodes first use them; with it, a node using a type not listed is a `DeclarationError`. Subclasses inherit nodes and may override them.
|
|
79
|
+
|
|
80
|
+
## Values and errors
|
|
81
|
+
|
|
82
|
+
Before the method runs, every input is checked against its port:
|
|
83
|
+
|
|
84
|
+
- a `str` port (or a wire type over `str`) receives any value as text: strings as they are, other values as compact JSON;
|
|
85
|
+
- an `int`, `float`, `bool` or `Literal` port that gets the wrong type, or a number outside its `Range`, fails the node with a `config` error naming the port (`marks: 9 is outside 0..5`);
|
|
86
|
+
- `Range(..., invalid="clamp")` clamps instead, and replaces a wrong type with the default; `Range(..., invalid="pass")` makes the range a UI hint only and hands the value over as it is.
|
|
87
|
+
|
|
88
|
+
Raise `ConfigError("...")` for a setting the user can fix, `OpError("...")` for a failure on this input, or `NodeError.cancelled()` when `cx.cancelled()`. Any other exception fails the node as `op` with its type and message, and the engine carries on.
|
|
89
|
+
|
|
90
|
+
## Serving
|
|
91
|
+
|
|
92
|
+
`MyEngine.serve()` reads the command line: `--connect unix:<path>` (or `PLUMCRAFT_ENGINE_SOCKET` and `PLUMCRAFT_ENGINE_TOKEN`) serves mode 2, `--listen host:port [--port-file f] [--lifeline]` serves mode 3. In a test, `Host(MyEngine)` runs it in process.
|
|
93
|
+
|
|
94
|
+
**Pictures on nodes:** a picture file's value shows a thumbnail when it carries one. Make it with `image(data, pixels=array)`, or override `Engine.picture_thumb(blob)` to give Load Files' values one, returning (h, w, 4) uint8; the SDK itself decodes no pictures.
|
|
95
|
+
|
|
96
|
+
## From the command line
|
|
97
|
+
|
|
98
|
+
`plumcraft-engine` drives an engine with no Rust build:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
uv run plumcraft-engine nodes # the catalogue
|
|
102
|
+
uv run plumcraft-engine run # the [tool.plumcraft] demo, events as they come
|
|
103
|
+
uv run plumcraft-engine run my.json --watch shout.text # a workflow, with a value watched
|
|
104
|
+
uv run plumcraft-engine run my.json --cancel-after 0.5 --raw # cancel mid-run; every event as JSON
|
|
105
|
+
uv run plumcraft-engine run my.json --attach http://127.0.0.1:7311 # an engine serving --listen
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **The engine:** `--engine module:Class`, else `[tool.plumcraft] engine` in the nearest `pyproject.toml` (this one names `plumcraft_text:TextEngine`, with `demo = "../examples/data.json"`). It runs in process, as the editor's in-process mode does; `--attach URL` talks to one already serving HTTP, with `PLUMCRAFT_ENGINE_TOKEN` when set.
|
|
109
|
+
- **The workflow:** path inputs relative to the workflow's folder are made absolute, as `plumcraft run` does.
|
|
110
|
+
- **The exit code:** 0 when every node is `done` or `cached`, 1 when one isn't, 2 when the engine or workflow can't be had. A script can use `run` as a smoke test.
|
|
111
|
+
|
|
112
|
+
## A new engine
|
|
113
|
+
|
|
114
|
+
```sh
|
|
115
|
+
uv run --project ~/workspace/plumcraft/python plumcraft-engine new ~/workspace/weather-engine --name Weather --types text
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This writes a standalone uv project that depends on this SDK, which `scripts/editor` opens in PlumCraft's editor, the editor starting the engine from its manifest: the engine with example nodes for each type, its tests (including a golden catalogue and conformance), a demo workflow, scripts for testing from the command line, PyCharm run configurations, a README for the developer, and the engine manifest. It refuses a directory with something in it and ids PlumCraft already uses, and a failure leaves nothing behind.
|
|
119
|
+
|
|
120
|
+
- **`--types`:** `text`, `table`, `array`, `svg`, `image` (adds pillow), `audio`, `json`, `list` (brings `text`), `any` (the building blocks), comma-separated. Scalars are always on. A conversion is generated when both its types are chosen, always with its inverse: `table`↔`text` (CSV), `table`↔`array`, `svg`↔`text`, `image`↔`array`, `audio`↔`array`, `json`↔`text`.
|
|
121
|
+
- **The other options:** `--id`, `--name`, `--package`, `--sdk pypi|path|git[@REV]`, `--python`, `--no-pycharm`, `--git`.
|
|
122
|
+
|
|
123
|
+
`uv run plumcraft-engine check` runs PlumCraft's conformance cases against an engine, in process and over HTTP (`--mode` for one): the session, core types declared exactly, every node on its defaults, the demo, cancel, answers off the run path, and hostile widget values. It needs only the catalogue, plus `[tool.plumcraft] demo` and `[tool.plumcraft.conformance] slow` when set; in a test, `plumcraft_engine.conformance.assert_conformant(MyEngine, demo=..., slow=...)` fails naming every failed case.
|
|
124
|
+
|
|
125
|
+
## Alternatives considered
|
|
126
|
+
|
|
127
|
+
1. **A parameters dataclass per node as the only form** (the research software's `parameters = AnnealParameters`). It reads well with ten settings and badly with one, and it splits a node's inputs between the signature (sockets) and the dataclass (widgets). It is supported as a parameter type for nodes with many settings.
|
|
128
|
+
2. **`Port(...)` as the default** (`find: str = Port("", label="Find")`, as typer and pydantic do). It hides the real default from type checkers and from readers. `Annotated` keeps the default a default.
|
|
129
|
+
3. **Signatures plus `Annotated`** (chosen): the method is an ordinary typed function a type checker understands, the port list is the parameter list, and metadata sits beside the type it qualifies.
|
|
130
|
+
|
|
131
|
+
## The low-level layer
|
|
132
|
+
|
|
133
|
+
The decorators compile to the layer underneath, which stays and is the escape hatch: a `Node` subclass with a `definition` dict (a NodeDef in protocol 2's JSON) and `run(inputs, cx) -> dict`, or `simple(definition, fn)`, added with `engine.with_node(...)` to a declared engine or to `Engine(info)`. Use it for what a signature can't say yet: variadic ports, `options`, `list` ports, `active_when`, `disabled_choices`, or ports whose shape depends on configuration.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "plumcraft-engine"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "PlumCraft's Python engine SDK and the text engine in Python, speaking protocol 2 over the mode 2 socket binding, with blobs in commonkit"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT OR Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE-MIT", "LICENSE-APACHE"]
|
|
8
|
+
authors = [{ name = "Sean D. True" }, { name = "Swapwizard LLC" }]
|
|
9
|
+
keywords = ["node editor", "node graph", "workflow", "plumcraft"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Operating System :: MacOS",
|
|
14
|
+
"Operating System :: POSIX",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Software Development :: Libraries",
|
|
20
|
+
]
|
|
21
|
+
requires-python = ">=3.11"
|
|
22
|
+
dependencies = ["numpy>=1.26", "pillow>=10", "pyuncommonkit>=0.1"]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/seantrue/plumcraft"
|
|
26
|
+
Repository = "https://github.com/seantrue/plumcraft"
|
|
27
|
+
Issues = "https://github.com/seantrue/plumcraft/issues"
|
|
28
|
+
Changelog = "https://github.com/seantrue/plumcraft/blob/main/CHANGELOG.md"
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
plumcraft-text-engine-py = "plumcraft_text.__main__:main"
|
|
32
|
+
plumcraft-engine = "plumcraft_engine.cli:main"
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = ["pytest>=8", "ruff>=0.6"]
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["hatchling"]
|
|
39
|
+
build-backend = "hatchling.build"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/plumcraft_engine", "src/plumcraft_text"]
|
|
43
|
+
|
|
44
|
+
[tool.ruff]
|
|
45
|
+
line-length = 160
|
|
46
|
+
target-version = "py311"
|
|
47
|
+
# tests/golden holds generated projects, checked with their own settings (test_new_engine.py).
|
|
48
|
+
extend-exclude = ["tests/golden"]
|
|
49
|
+
|
|
50
|
+
[tool.ruff.lint]
|
|
51
|
+
select = ["E", "F", "W", "I", "B", "UP"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
norecursedirs = ["golden"]
|
|
56
|
+
|
|
57
|
+
# `plumcraft-engine run` and `nodes` here drive the Python text engine (plumcraft_engine.cli); a
|
|
58
|
+
# generated engine's project names its own.
|
|
59
|
+
[tool.plumcraft]
|
|
60
|
+
engine = "plumcraft_text:TextEngine"
|
|
61
|
+
demo = "../examples/data.json"
|
|
62
|
+
|
|
63
|
+
[tool.plumcraft.conformance]
|
|
64
|
+
slow = "text.slow"
|