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