A Library to add TaskGraph implementation of plans to Bluesky
Project description
A library extending the Bluesky RunEngine to allow TaskGraphs to be run: TaskGraphs are intended to encourage parallelism and composability compared to Bluesky native plans by breaking plans into conditional blocks, or tasks.
Work related to implementing a Task Graph runner (Decision Engine) in Bluesky, akin to the VMXi task graph runner in Jython.
The decision engine plan is passed to the RunEngine, optionally by a ControlObject which constructs multiple TaskGraphs according to either inbuilt logic or from a recipe involving an external source, and the RunEngine interrogates the plan as a Msg generator. A TaskGraph contains:
A dictionary of plan to a list of plans it is known to be dependent on or else unable to be run concurrently with
A dictionary of plan to list of strings, the names of the arguments it needs We force this to be defined for the task graph (rather than by each task) to prevent accessing prior args Multiple tasks may share an input argument name An input argument may be overwritten later by the output of a task, so a graph should be defined such that if args are going to be overwritten, the overwriting tasks should depend on any that require the previous value
A dictionary of plan to a list of strings, the names of the outputs it will provide We force this to be defined for the task graph (rather than by each task) to prevent overriding prior args The output strings should be at most the length of the outputs of the task, else will be truncated An output argument may overwrite a previous output or initial value, so care should be taken to either avoid this behaviour or have any overwriting tasks depend on any tasks requiring the previous value
The DecisionEnginePlan is additionally passed a dictionary of string to any necessary initial conditions or known values atits creation. e.g. - Beamline configurations, name etc. - Any devices that will be required for the graph
Decision engine plans, their decision engines, the task graphs they are initialised with, and the tasks are intended to be run once and then discarded.
Task graphs can be composed of smaller task graphs using the depends_on function, or by simple addition of plans. Graph A + Graph B places every entry from each dictionary in Graph B into Graph A’s, overwriting existing keys in A Graph A being dependent on Graph B is equivalent to every task within Graph A being dependent on every task in Graph B, then Graph A = Graph A + Graph B. After depends_on or graph addition, Graph B should be discarded to prevent accidental running of tasks again, Graph A now contains all the information Task graphs should not contain the same task as another graph other than these transient cases.
PyPI |
pip install python_bluesky_taskgraph |
Source code |
https://github.com/DiamondLightSource/python-bluesky-taskgraph |
Documentation |
https://DiamondLightSource.github.io/python_bluesky_taskgraph |
Releases |
https://github.com/DiamondLightSource/python-bluesky-taskgraph/releases |
# The TaskGraph plan can utilise the native Bluesky RunEngine: in Python 3.8 or
# above
RE = RunEngine({})
# An example ControlObject, which could monitors the state of the beamline 'baton' and returns control when
# required, or else restarts collection when the baton is free.
CO = UnattendedDataCollectionControlObject(RE)
CO.run_task_graphs()
# Or else, the RunEngine can run a decision_engine_plan, wrapping a TaskGraph
RE(decision_engine_plan(task_graph, variables or {}))
See https://DiamondLightSource.github.io/python_bluesky_taskgraph for more detailed documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python_bluesky_taskgraph-0.1.tar.gz
.
File metadata
- Download URL: python_bluesky_taskgraph-0.1.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d286f79a84a21f10c8689315b831b2328574e777f0e2adaafa62681b75c211d |
|
MD5 | 06a9dde5b738b0b98a4a239266ebee38 |
|
BLAKE2b-256 | f29979f1b87b0471ab04e312347d831345e9e4e4bf136f0822dbc2fa60cb24a5 |
File details
Details for the file python_bluesky_taskgraph-0.1-py3-none-any.whl
.
File metadata
- Download URL: python_bluesky_taskgraph-0.1-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d384167452d9ac7cf1e17c8e4136e48ae80b906bb2189a33582a0a1e0b667297 |
|
MD5 | 8169be17133756573ceb409f35fa9264 |
|
BLAKE2b-256 | ccab4415a886b44aea4eb5693e488136dc69491913ca126c26eac8f666bd6f89 |