AutoPumping 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.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: AutoPumping
3
+ Version: 0.1.0
4
+ Summary: A tool to automate pumping of vacuum systems
5
+ Author-email: Cameron Devine <cameron.devine@alleninstitute.org>
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Topic :: Scientific/Engineering :: Physics
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pydantic
15
+ Requires-Dist: pyyaml
16
+ Requires-Dist: networkx
17
+ Requires-Dist: nicegui
18
+ Requires-Dist: pyvis
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest; extra == "dev"
21
+ Requires-Dist: bump-my-version; extra == "dev"
22
+ Provides-Extra: docs
23
+ Requires-Dist: jsonschema2md; extra == "docs"
24
+ Dynamic: license-file
25
+
26
+ # Auto Pumping
27
+
28
+ This Python package is meant to provide a generic system for automating high-vacuum pumping systems.
29
+
30
+ ## Config
31
+
32
+ To support arbitrary pumping systems, a configuration file format was created where all valid valve, pump, and stage[^1] transition can be enumerated. Using this configuration file, the safety of any given valve transition can be evaluated, and the system automated. This configuration file format is documented [here](docs/config.md).
33
+
34
+ ## Solver
35
+
36
+ To support automated pumping of the vacuum system a solver was implemented using the information in the configuration file. This information is used to build a directed graph of all valid pumping system states where discretized pressure is included. After this directed graph is built, Dijkstra's algorithm is used for find the optimal method for pumping or venting the system, or reaching any other state. The built graph can be viewed by running: `python -m auto_pumping -c config/config.yaml network`.
37
+
38
+ ## UI
39
+
40
+ A NiceGUI based UI is also included. It is automatically built based on the configuration file. A dummy pumping system is available as an example and can be run with: `python -m auto_pumping -c config/config.yaml run`.
41
+
42
+ ## Getting Started
43
+
44
+ To implement automated pumping for your system subclass the `AutoPumping` class and define the following methods:
45
+
46
+ * `get_valve_state(valve)`
47
+ * `actuate_valve(valve, state)`
48
+ * `get_pump_state(pump)`
49
+ * `set_pump(pump, state)`
50
+ * `get_pump_current(pump)`
51
+ * `get_pump_voltage(pump)`
52
+ * `get_pump_flow(pump)`
53
+ * `get_pump_speed(pump)`
54
+ * `get_gauge_pressure(gauge)`
55
+ * `get_stage_position()`
56
+ * `move_stage(position)`
57
+
58
+ If you would like to add more fields to the configuration file for your specific hardware, subclass the `Config` class and set the `AutoPumping.CONFIG_CLASS` variable to your new config class.
59
+
60
+ To allow the system to be easily started, you can use the provided `main()` function. Simply run `main(<your_auto_pumping_subclass>)`, for example:
61
+
62
+ ```python
63
+ from auto_pumping.__main__ import main
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main(<your_auto_pumping_subclass>)
68
+ ```
69
+
70
+ Finally, a diagram can be added to the UI by setting the `AutoPumping.DIAGRAM_PATH` variable to the path to a diagram image of your system.
71
+
72
+ [^1]: this library was originally written for a custom microscope system.
@@ -0,0 +1,20 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ AutoPumping.egg-info/PKG-INFO
5
+ AutoPumping.egg-info/SOURCES.txt
6
+ AutoPumping.egg-info/dependency_links.txt
7
+ AutoPumping.egg-info/requires.txt
8
+ AutoPumping.egg-info/top_level.txt
9
+ auto_pumping/__init__.py
10
+ auto_pumping/__main__.py
11
+ auto_pumping/config.py
12
+ auto_pumping/dummy.py
13
+ auto_pumping/executor.py
14
+ auto_pumping/graph.py
15
+ auto_pumping/safety.py
16
+ auto_pumping/ui.py
17
+ test/test_config.py
18
+ test/test_executor.py
19
+ test/test_graph.py
20
+ test/test_ui.py
@@ -0,0 +1,12 @@
1
+ pydantic
2
+ pyyaml
3
+ networkx
4
+ nicegui
5
+ pyvis
6
+
7
+ [dev]
8
+ pytest
9
+ bump-my-version
10
+
11
+ [docs]
12
+ jsonschema2md
@@ -0,0 +1 @@
1
+ auto_pumping
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Allen Institute
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: AutoPumping
3
+ Version: 0.1.0
4
+ Summary: A tool to automate pumping of vacuum systems
5
+ Author-email: Cameron Devine <cameron.devine@alleninstitute.org>
6
+ License-Expression: BSD-3-Clause
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Topic :: Scientific/Engineering :: Physics
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pydantic
15
+ Requires-Dist: pyyaml
16
+ Requires-Dist: networkx
17
+ Requires-Dist: nicegui
18
+ Requires-Dist: pyvis
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest; extra == "dev"
21
+ Requires-Dist: bump-my-version; extra == "dev"
22
+ Provides-Extra: docs
23
+ Requires-Dist: jsonschema2md; extra == "docs"
24
+ Dynamic: license-file
25
+
26
+ # Auto Pumping
27
+
28
+ This Python package is meant to provide a generic system for automating high-vacuum pumping systems.
29
+
30
+ ## Config
31
+
32
+ To support arbitrary pumping systems, a configuration file format was created where all valid valve, pump, and stage[^1] transition can be enumerated. Using this configuration file, the safety of any given valve transition can be evaluated, and the system automated. This configuration file format is documented [here](docs/config.md).
33
+
34
+ ## Solver
35
+
36
+ To support automated pumping of the vacuum system a solver was implemented using the information in the configuration file. This information is used to build a directed graph of all valid pumping system states where discretized pressure is included. After this directed graph is built, Dijkstra's algorithm is used for find the optimal method for pumping or venting the system, or reaching any other state. The built graph can be viewed by running: `python -m auto_pumping -c config/config.yaml network`.
37
+
38
+ ## UI
39
+
40
+ A NiceGUI based UI is also included. It is automatically built based on the configuration file. A dummy pumping system is available as an example and can be run with: `python -m auto_pumping -c config/config.yaml run`.
41
+
42
+ ## Getting Started
43
+
44
+ To implement automated pumping for your system subclass the `AutoPumping` class and define the following methods:
45
+
46
+ * `get_valve_state(valve)`
47
+ * `actuate_valve(valve, state)`
48
+ * `get_pump_state(pump)`
49
+ * `set_pump(pump, state)`
50
+ * `get_pump_current(pump)`
51
+ * `get_pump_voltage(pump)`
52
+ * `get_pump_flow(pump)`
53
+ * `get_pump_speed(pump)`
54
+ * `get_gauge_pressure(gauge)`
55
+ * `get_stage_position()`
56
+ * `move_stage(position)`
57
+
58
+ If you would like to add more fields to the configuration file for your specific hardware, subclass the `Config` class and set the `AutoPumping.CONFIG_CLASS` variable to your new config class.
59
+
60
+ To allow the system to be easily started, you can use the provided `main()` function. Simply run `main(<your_auto_pumping_subclass>)`, for example:
61
+
62
+ ```python
63
+ from auto_pumping.__main__ import main
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main(<your_auto_pumping_subclass>)
68
+ ```
69
+
70
+ Finally, a diagram can be added to the UI by setting the `AutoPumping.DIAGRAM_PATH` variable to the path to a diagram image of your system.
71
+
72
+ [^1]: this library was originally written for a custom microscope system.
@@ -0,0 +1,47 @@
1
+ # Auto Pumping
2
+
3
+ This Python package is meant to provide a generic system for automating high-vacuum pumping systems.
4
+
5
+ ## Config
6
+
7
+ To support arbitrary pumping systems, a configuration file format was created where all valid valve, pump, and stage[^1] transition can be enumerated. Using this configuration file, the safety of any given valve transition can be evaluated, and the system automated. This configuration file format is documented [here](docs/config.md).
8
+
9
+ ## Solver
10
+
11
+ To support automated pumping of the vacuum system a solver was implemented using the information in the configuration file. This information is used to build a directed graph of all valid pumping system states where discretized pressure is included. After this directed graph is built, Dijkstra's algorithm is used for find the optimal method for pumping or venting the system, or reaching any other state. The built graph can be viewed by running: `python -m auto_pumping -c config/config.yaml network`.
12
+
13
+ ## UI
14
+
15
+ A NiceGUI based UI is also included. It is automatically built based on the configuration file. A dummy pumping system is available as an example and can be run with: `python -m auto_pumping -c config/config.yaml run`.
16
+
17
+ ## Getting Started
18
+
19
+ To implement automated pumping for your system subclass the `AutoPumping` class and define the following methods:
20
+
21
+ * `get_valve_state(valve)`
22
+ * `actuate_valve(valve, state)`
23
+ * `get_pump_state(pump)`
24
+ * `set_pump(pump, state)`
25
+ * `get_pump_current(pump)`
26
+ * `get_pump_voltage(pump)`
27
+ * `get_pump_flow(pump)`
28
+ * `get_pump_speed(pump)`
29
+ * `get_gauge_pressure(gauge)`
30
+ * `get_stage_position()`
31
+ * `move_stage(position)`
32
+
33
+ If you would like to add more fields to the configuration file for your specific hardware, subclass the `Config` class and set the `AutoPumping.CONFIG_CLASS` variable to your new config class.
34
+
35
+ To allow the system to be easily started, you can use the provided `main()` function. Simply run `main(<your_auto_pumping_subclass>)`, for example:
36
+
37
+ ```python
38
+ from auto_pumping.__main__ import main
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main(<your_auto_pumping_subclass>)
43
+ ```
44
+
45
+ Finally, a diagram can be added to the UI by setting the `AutoPumping.DIAGRAM_PATH` variable to the path to a diagram image of your system.
46
+
47
+ [^1]: this library was originally written for a custom microscope system.
@@ -0,0 +1,116 @@
1
+ from abc import ABC, abstractmethod
2
+ from .safety import SafetyMachine
3
+ from .graph import PumpingGraph
4
+ from .config import Config
5
+ from .executor import PlanExecutor
6
+ from .ui import UI
7
+
8
+
9
+ class AutoPumping(ABC):
10
+ CONFIG_CLASS = Config
11
+ DIAGRAM_PATH = None
12
+
13
+ def __init__(self, config, ui=True):
14
+ self._config = config
15
+ self._safety_machine = SafetyMachine(config, self)
16
+ self._pumping_graph = PumpingGraph(config)
17
+ self._plan_executor = PlanExecutor(self)
18
+ self._ui = None
19
+ if ui:
20
+ self._ui = UI(config, self, diagram=self.DIAGRAM_PATH)
21
+
22
+ def run(self):
23
+ if self._ui is None:
24
+ raise RuntimeError("UI is not enabled for this instance.")
25
+ self._ui.run()
26
+
27
+ def auto(self, **goal_state_data):
28
+ self._plan_executor.execute_plan(
29
+ list(self._pumping_graph.make_plan(self._get_state(), **goal_state_data))
30
+ )
31
+
32
+ def cancel(self):
33
+ self._plan_executor.cancel()
34
+
35
+ @property
36
+ def plan(self):
37
+ return self._plan_executor.plan
38
+
39
+ def _get_state(self):
40
+ return {
41
+ "valves": {
42
+ valve: self.get_valve_state(valve) for valve in self._config.valves
43
+ },
44
+ "pumps": {pump: self.get_pump_state(pump) for pump in self._config.pumps},
45
+ "stage": self.get_stage_position(),
46
+ "gauges": {gauge: self._pumping_graph._get_gauge_range(gauge, self.get_gauge_pressure(gauge)) for gauge in self._config.gauges},
47
+ }
48
+
49
+ @classmethod
50
+ def from_config_file(cls, config_file):
51
+ config = cls.CONFIG_CLASS.load_file(config_file)
52
+ return cls(config)
53
+
54
+ @abstractmethod
55
+ def get_valve_state(self, valve):
56
+ pass
57
+
58
+ def _actuate_valve(self, valve, state):
59
+ if self._safety_machine.can_actuate_valve(valve, state):
60
+ self.actuate_valve(valve, state)
61
+ self._safety_machine.record_valve_change(valve)
62
+ return True
63
+ return False
64
+
65
+ @abstractmethod
66
+ def actuate_valve(self, valve, state):
67
+ pass
68
+
69
+ @abstractmethod
70
+ def get_pump_state(self, pump):
71
+ pass
72
+
73
+ def _set_pump(self, pump, state):
74
+ if self._safety_machine.can_set_pump(pump, state):
75
+ self.set_pump(pump, state)
76
+ self._safety_machine.record_pump_change(pump)
77
+ return True
78
+ return False
79
+
80
+ @abstractmethod
81
+ def set_pump(self, pump, state):
82
+ pass
83
+
84
+ @abstractmethod
85
+ def get_pump_current(self, pump):
86
+ pass
87
+
88
+ @abstractmethod
89
+ def get_pump_voltage(self, pump):
90
+ pass
91
+
92
+ @abstractmethod
93
+ def get_pump_flow(self, pump):
94
+ pass
95
+
96
+ @abstractmethod
97
+ def get_pump_speed(self, pump):
98
+ pass
99
+
100
+ @abstractmethod
101
+ def get_gauge_pressure(self, gauge):
102
+ pass
103
+
104
+ @abstractmethod
105
+ def get_stage_position(self):
106
+ pass
107
+
108
+ def _move_stage(self, position):
109
+ if self._safety_machine.can_move_stage(position):
110
+ self.move_stage(position)
111
+ return True
112
+ return False
113
+
114
+ @abstractmethod
115
+ def move_stage(self, position):
116
+ pass
@@ -0,0 +1,35 @@
1
+ import argparse
2
+ from .dummy import DummyPumping
3
+
4
+
5
+ def build_parser(system_class):
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument(
8
+ "-c",
9
+ "--config",
10
+ type=str,
11
+ required=True,
12
+ help="Path to the configuration file.",
13
+ )
14
+ subparsers = parser.add_subparsers(dest="command", help="Sub-command help")
15
+ network_parser = subparsers.add_parser("network", help="Draw the network graph.")
16
+ network_parser.add_argument(
17
+ "--output", "-o", type=str, help="Output file for the network graph."
18
+ )
19
+ run_parser = subparsers.add_parser("run", help="Run the pumping system.")
20
+
21
+ return parser
22
+
23
+
24
+ def main(system_class):
25
+ parser = build_parser(system_class)
26
+ args = parser.parse_args()
27
+ system = system_class.from_config_file(args.config)
28
+ if args.command == "network":
29
+ system._pumping_graph.draw(args.output)
30
+ elif args.command == "run":
31
+ system.run()
32
+
33
+
34
+ if __name__ == "__main__":
35
+ main(DummyPumping)