hypershell 2.6.4__py3-none-any.whl

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.
hypershell/__init__.py ADDED
@@ -0,0 +1,115 @@
1
+ # SPDX-FileCopyrightText: 2025 Geoffrey Lentner
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """Initialization and entry-point for console application."""
5
+
6
+
7
+ # standard libs
8
+ import sys
9
+ from importlib.metadata import version as get_version
10
+ from platform import python_version
11
+
12
+ # external libs
13
+ from cmdkit.app import Application, ApplicationGroup
14
+ from cmdkit.cli import Interface
15
+
16
+ # internal libs
17
+ from hypershell.core.logging import Logger, initialize_logging
18
+ from hypershell.core.signal import register_handlers
19
+ from hypershell.submit import SubmitApp
20
+ from hypershell.server import ServerApp
21
+ from hypershell.client import ClientApp
22
+ from hypershell.cluster import ClusterApp
23
+ from hypershell.task import TaskGroupApp
24
+ from hypershell.config import ConfigApp
25
+ from hypershell.data import InitDBApp
26
+
27
+ # public interface
28
+ __all__ = ['HyperShellApp', 'main', '__version__']
29
+
30
+ # project metadata
31
+ __version__ = get_version('hypershell')
32
+ __website__ = 'https://github.com/glentner/hypershell'
33
+ __description__ = 'Process shell commands over a distributed, asynchronous queue.'
34
+ __citation__ = """\
35
+ @inproceedings{lentner_2022,
36
+ author = {Lentner, Geoffrey and Gorenstein, Lev},
37
+ title = {HyperShell v2: Distributed Task Execution for HPC},
38
+ year = {2022},
39
+ isbn = {9781450391610},
40
+ publisher = {Association for Computing Machinery},
41
+ url = {https://doi.org/10.1145/3491418.3535138},
42
+ doi = {10.1145/3491418.3535138},
43
+ booktitle = {Practice and Experience in Advanced Research Computing},
44
+ articleno = {80},
45
+ numpages = {3},
46
+ series = {PEARC '22}
47
+ }\
48
+ """
49
+
50
+ # initialize logger
51
+ log = Logger.with_name('hypershell')
52
+
53
+
54
+ # inject logger setup into command-line framework
55
+ Application.log_critical = log.critical
56
+ Application.log_exception = log.exception
57
+
58
+
59
+ APP_NAME = 'hs'
60
+ APP_USAGE = f"""\
61
+ Usage:
62
+ {APP_NAME} [-h] [-v] <command> [<args>...]
63
+ {__description__}\
64
+ """
65
+
66
+ APP_HELP = f"""\
67
+ {APP_USAGE}
68
+
69
+ Commands:
70
+ config {ConfigApp.__doc__}
71
+ submit {SubmitApp.__doc__}
72
+ server {ServerApp.__doc__}
73
+ client {ClientApp.__doc__}
74
+ cluster {ClusterApp.__doc__} (recommended)
75
+ task {TaskGroupApp.__doc__}
76
+ initdb {InitDBApp.__doc__}
77
+
78
+ Options:
79
+ -h, --help Show this message and exit.
80
+ -v, --version Show the version and exit.
81
+ --citation Show citation info and exit.
82
+
83
+ Issue tracking at:
84
+ {__website__}
85
+
86
+ If this software has helped in your research please consider
87
+ citing us (see --citation).\
88
+ """
89
+
90
+
91
+ class HyperShellApp(ApplicationGroup):
92
+ """Top-level application class for console application."""
93
+
94
+ interface = Interface(APP_NAME, APP_USAGE, APP_HELP)
95
+ interface.add_argument('-v', '--version', action='version',
96
+ version=f'HyperShell v{__version__} (Python {python_version()})')
97
+ interface.add_argument('--citation', action='version', version=__citation__)
98
+ interface.add_argument('command')
99
+
100
+ commands = {
101
+ 'submit': SubmitApp,
102
+ 'server': ServerApp,
103
+ 'client': ClientApp,
104
+ 'cluster': ClusterApp,
105
+ 'task': TaskGroupApp,
106
+ 'config': ConfigApp,
107
+ 'initdb': InitDBApp,
108
+ }
109
+
110
+
111
+ def main() -> int:
112
+ """Entry-point for console application."""
113
+ initialize_logging()
114
+ register_handlers()
115
+ return HyperShellApp.main(sys.argv[1:])