hypershell 2.6.4__tar.gz → 2.6.5__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.
Files changed (33) hide show
  1. {hypershell-2.6.4 → hypershell-2.6.5}/PKG-INFO +1 -1
  2. {hypershell-2.6.4 → hypershell-2.6.5}/pyproject.toml +1 -1
  3. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/__init__.py +9 -6
  4. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/client.py +6 -6
  5. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/cluster/__init__.py +6 -6
  6. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/cluster/local.py +5 -5
  7. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/cluster/remote.py +5 -5
  8. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/cluster/ssh.py +6 -6
  9. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/config.py +6 -6
  10. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/config.py +7 -12
  11. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/exceptions.py +4 -4
  12. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/fsm.py +4 -4
  13. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/heartbeat.py +4 -4
  14. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/logging.py +4 -4
  15. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/platform.py +3 -3
  16. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/queue.py +4 -4
  17. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/remote.py +6 -6
  18. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/signal.py +5 -5
  19. hypershell-2.6.5/src/hypershell/core/sys.py +69 -0
  20. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/tag.py +4 -4
  21. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/template.py +4 -4
  22. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/thread.py +3 -3
  23. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/types.py +2 -2
  24. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/data/__init__.py +6 -6
  25. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/data/core.py +5 -5
  26. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/data/model.py +6 -6
  27. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/server.py +6 -6
  28. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/submit.py +6 -6
  29. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/task.py +6 -6
  30. hypershell-2.6.4/src/hypershell/core/sys.py +0 -39
  31. {hypershell-2.6.4 → hypershell-2.6.5}/LICENSE +0 -0
  32. {hypershell-2.6.4 → hypershell-2.6.5}/README.rst +0 -0
  33. {hypershell-2.6.4 → hypershell-2.6.5}/src/hypershell/core/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: hypershell
3
- Version: 2.6.4
3
+ Version: 2.6.5
4
4
  Summary: A cross-platform, high-throughput computing utility for processing shell commands over a distributed, asynchronous queue.
5
5
  License: Apache-2.0
6
6
  Keywords: distributed-computing,command-line-tool,shell-scripting,high-performance-computing,high-throughput-computing
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "hypershell"
3
- version = "2.6.4"
3
+ version = "2.6.5"
4
4
  description = "A cross-platform, high-throughput computing utility for processing shell commands over a distributed, asynchronous queue."
5
5
  readme = "README.rst"
6
6
  license = "Apache-2.0"
@@ -4,16 +4,19 @@
4
4
  """Initialization and entry-point for console application."""
5
5
 
6
6
 
7
- # standard libs
7
+ # Path sanitizer must happen first
8
+ import hypershell.core.sys
9
+
10
+ # Standard libs
8
11
  import sys
9
12
  from importlib.metadata import version as get_version
10
13
  from platform import python_version
11
14
 
12
- # external libs
15
+ # External libs
13
16
  from cmdkit.app import Application, ApplicationGroup
14
17
  from cmdkit.cli import Interface
15
18
 
16
- # internal libs
19
+ # Internal libs
17
20
  from hypershell.core.logging import Logger, initialize_logging
18
21
  from hypershell.core.signal import register_handlers
19
22
  from hypershell.submit import SubmitApp
@@ -24,12 +27,12 @@ from hypershell.task import TaskGroupApp
24
27
  from hypershell.config import ConfigApp
25
28
  from hypershell.data import InitDBApp
26
29
 
27
- # public interface
30
+ # Public interface
28
31
  __all__ = ['HyperShellApp', 'main', '__version__']
29
32
 
30
33
  # project metadata
31
34
  __version__ = get_version('hypershell')
32
- __website__ = 'https://github.com/glentner/hypershell'
35
+ __website__ = 'https://github.com/hypershell/hypershell'
33
36
  __description__ = 'Process shell commands over a distributed, asynchronous queue.'
34
37
  __citation__ = """\
35
38
  @inproceedings{lentner_2022,
@@ -47,7 +50,7 @@ __citation__ = """\
47
50
  }\
48
51
  """
49
52
 
50
- # initialize logger
53
+ # Initialize logger
51
54
  log = Logger.with_name('hypershell')
52
55
 
53
56
 
@@ -28,12 +28,12 @@ Warning:
28
28
  """
29
29
 
30
30
 
31
- # type annotations
31
+ # Type annotations
32
32
  from __future__ import annotations
33
33
  from typing import List, Tuple, Optional, Callable, Dict, IO, Type, Final
34
34
  from types import TracebackType
35
35
 
36
- # standard libs
36
+ # Standard libs
37
37
  import os
38
38
  import sys
39
39
  import time
@@ -48,12 +48,12 @@ from socket import gaierror
48
48
  from dataclasses import dataclass
49
49
  from multiprocessing import AuthenticationError, cpu_count
50
50
 
51
- # external libs
51
+ # External libs
52
52
  from cmdkit.app import Application, exit_status
53
53
  from cmdkit.cli import Interface, ArgumentError
54
54
  from cmdkit.config import Namespace
55
55
 
56
- # internal libs
56
+ # Internal libs
57
57
  from hypershell.data.model import Task
58
58
  from hypershell.core.heartbeat import Heartbeat, ClientState
59
59
  from hypershell.core.platform import default_path
@@ -67,14 +67,14 @@ from hypershell.core.template import Template, DEFAULT_TEMPLATE
67
67
  from hypershell.core.exceptions import (handle_exception, handle_disconnect,
68
68
  handle_address_unknown, HostAddressInfo, get_shared_exception_mapping)
69
69
 
70
- # public interface
70
+ # Public interface
71
71
  __all__ = ['run_client', 'ClientThread', 'ClientApp', 'ClientInfo',
72
72
  'DEFAULT_BUNDLESIZE', 'DEFAULT_BUNDLEWAIT', 'DEFAULT_TEMPLATE',
73
73
  'DEFAULT_NUM_TASKS', 'DEFAULT_DELAY', 'DEFAULT_SIGNALWAIT',
74
74
  'DEFAULT_HEARTRATE', 'DEFAULT_HOST', 'DEFAULT_PORT', 'DEFAULT_AUTH',
75
75
  'set_client_standalone']
76
76
 
77
- # initialize logger
77
+ # Initialize logger
78
78
  log = Logger.with_name(__name__)
79
79
 
80
80
 
@@ -4,21 +4,21 @@
4
4
  """Run full cluster with server and managed clients."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import IO, Optional, Iterable, Dict, Callable, Type
10
10
  from types import TracebackType
11
11
 
12
- # standard libs
12
+ # Standard libs
13
13
  import sys
14
14
  import shlex
15
15
  from functools import cached_property
16
16
 
17
- # external libs
17
+ # External libs
18
18
  from cmdkit.app import Application
19
19
  from cmdkit.cli import Interface, ArgumentError
20
20
 
21
- # internal libs
21
+ # Internal libs
22
22
  from hypershell.core.config import config, blame
23
23
  from hypershell.core.queue import QueueConfig
24
24
  from hypershell.core.logging import Logger
@@ -35,14 +35,14 @@ from hypershell.cluster.remote import (run_cluster, RemoteCluster, AutoScalingCl
35
35
  DEFAULT_AUTOSCALE_MIN_SIZE, DEFAULT_AUTOSCALE_MAX_SIZE,
36
36
  DEFAULT_AUTOSCALE_INIT_SIZE)
37
37
 
38
- # public interface
38
+ # Public interface
39
39
  __all__ = ['run_local', 'run_cluster', 'run_ssh',
40
40
  'LocalCluster', 'RemoteCluster', 'AutoScalingCluster', 'SSHCluster',
41
41
  'DEFAULT_REMOTE_EXE', 'DEFAULT_AUTOSCALE_FACTOR', 'DEFAULT_AUTOSCALE_PERIOD',
42
42
  'DEFAULT_AUTOSCALE_MIN_SIZE', 'DEFAULT_AUTOSCALE_MAX_SIZE', 'DEFAULT_AUTOSCALE_INIT_SIZE',
43
43
  'ClusterApp', ]
44
44
 
45
- # initialize logger
45
+ # Initialize logger
46
46
  log = Logger.with_name(__name__)
47
47
 
48
48
 
@@ -4,15 +4,15 @@
4
4
  """Local cluster implementation."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Iterable, IO
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import time
13
13
  import secrets
14
14
 
15
- # internal libs
15
+ # Internal libs
16
16
  from hypershell.core.thread import Thread
17
17
  from hypershell.core.logging import Logger
18
18
  from hypershell.core.template import DEFAULT_TEMPLATE
@@ -20,10 +20,10 @@ from hypershell.submit import DEFAULT_BUNDLEWAIT
20
20
  from hypershell.server import ServerThread, DEFAULT_BUNDLESIZE, DEFAULT_ATTEMPTS
21
21
  from hypershell.client import ClientThread, DEFAULT_DELAY, DEFAULT_SIGNALWAIT, set_client_standalone
22
22
 
23
- # public interface
23
+ # Public interface
24
24
  __all__ = ['run_local', 'LocalCluster']
25
25
 
26
- # initialize logger
26
+ # Initialize logger
27
27
  log = Logger.with_name('hypershell.cluster')
28
28
 
29
29
 
@@ -4,11 +4,11 @@
4
4
  """Remote cluster implementation."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Tuple, List, Dict, IO, Iterable, Callable, Type, Final
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import os
13
13
  import sys
14
14
  import time
@@ -19,7 +19,7 @@ from datetime import datetime, timedelta
19
19
  from functools import cached_property
20
20
  from subprocess import Popen
21
21
 
22
- # internal libs
22
+ # Internal libs
23
23
  from hypershell.core.fsm import State, StateMachine
24
24
  from hypershell.core.config import default, load_task_env
25
25
  from hypershell.core.thread import Thread
@@ -30,14 +30,14 @@ from hypershell.client import DEFAULT_DELAY, DEFAULT_SIGNALWAIT
30
30
  from hypershell.submit import DEFAULT_BUNDLEWAIT
31
31
  from hypershell.server import ServerThread, DEFAULT_PORT, DEFAULT_BUNDLESIZE, DEFAULT_ATTEMPTS
32
32
 
33
- # public interface
33
+ # Public interface
34
34
  __all__ = ['run_cluster', 'RemoteCluster', 'AutoScalingCluster',
35
35
  'DEFAULT_REMOTE_EXE', 'DEFAULT_LAUNCHER',
36
36
  'DEFAULT_AUTOSCALE_POLICY', 'DEFAULT_AUTOSCALE_PERIOD', 'DEFAULT_AUTOSCALE_FACTOR',
37
37
  'DEFAULT_AUTOSCALE_INIT_SIZE', 'DEFAULT_AUTOSCALE_MIN_SIZE', 'DEFAULT_AUTOSCALE_MAX_SIZE',
38
38
  'DEFAULT_AUTOSCALE_LAUNCHER', ]
39
39
 
40
- # initialize logger
40
+ # Initialize logger
41
41
  log = Logger.with_name('hypershell.cluster')
42
42
 
43
43
 
@@ -4,11 +4,11 @@
4
4
  """SSH-based cluster implementation."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Type, List, Iterable, Tuple, IO, Final
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import re
13
13
  import sys
14
14
  import time
@@ -16,10 +16,10 @@ import shlex
16
16
  import secrets
17
17
  from subprocess import Popen
18
18
 
19
- # external libs
19
+ # External libs
20
20
  from cmdkit.config import ConfigurationError, Namespace
21
21
 
22
- # internal libs
22
+ # Internal libs
23
23
  from hypershell.core.config import config, blame
24
24
  from hypershell.core.thread import Thread
25
25
  from hypershell.core.logging import Logger, HOSTNAME
@@ -28,10 +28,10 @@ from hypershell.client import DEFAULT_DELAY, DEFAULT_SIGNALWAIT
28
28
  from hypershell.submit import DEFAULT_BUNDLEWAIT
29
29
  from hypershell.server import ServerThread, DEFAULT_PORT, DEFAULT_BUNDLESIZE, DEFAULT_ATTEMPTS
30
30
 
31
- # public interface
31
+ # Public interface
32
32
  __all__ = ['run_ssh', 'SSHCluster', 'NodeList', 'DEFAULT_REMOTE_EXE']
33
33
 
34
- # initialize logger
34
+ # Initialize logger
35
35
  log = Logger.with_name('hypershell.cluster')
36
36
 
37
37
 
@@ -4,11 +4,11 @@
4
4
  """Manage configuration."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Any
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import os
13
13
  import io
14
14
  import sys
@@ -16,7 +16,7 @@ import json
16
16
  import contextlib
17
17
  import subprocess
18
18
 
19
- # external libs
19
+ # External libs
20
20
  import tomlkit
21
21
  from pygments.styles import STYLE_MAP as CONSOLE_THEMES
22
22
  from cmdkit.app import Application, ApplicationGroup
@@ -25,7 +25,7 @@ from cmdkit.config import ConfigurationError
25
25
  from rich.console import Console
26
26
  from rich.syntax import Syntax
27
27
 
28
- # internal libs
28
+ # Internal libs
29
29
  from hypershell.core.platform import path
30
30
  from hypershell.core.types import smart_coerce
31
31
  from hypershell.core.logging import Logger
@@ -33,10 +33,10 @@ from hypershell.core.exceptions import get_shared_exception_mapping
33
33
  from hypershell.core.config import (load_file, update, ACTIVE_CONFIG_VARS,
34
34
  default as default_config, config as full_config)
35
35
 
36
- # public interface
36
+ # Public interface
37
37
  __all__ = ['ConfigApp', ]
38
38
 
39
- # initialize logger
39
+ # Initialize logger
40
40
  log = Logger.with_name(__name__)
41
41
 
42
42
 
@@ -4,11 +4,11 @@
4
4
  """Runtime configuration for HyperShell."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import TypeVar, Union, List, Optional, Protocol, Final, Iterator
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import os
13
13
  import re
14
14
  import sys
@@ -19,15 +19,16 @@ import socket
19
19
  import functools
20
20
  from datetime import datetime
21
21
 
22
- # external libs
22
+ # External libs
23
23
  from cmdkit.config import Namespace, Configuration, Environ, ConfigurationError
24
24
  from cmdkit.app import exit_status
25
25
 
26
- # internal libs
26
+ # Internal libs
27
27
  from hypershell.core.platform import path, home
28
28
  from hypershell.core.exceptions import write_traceback
29
+ from hypershell.core.sys import PATH_SEP
29
30
 
30
- # public interface
31
+ # Public interface
31
32
  __all__ = ['config', 'update', 'default', 'ConfigurationError', 'Namespace', 'blame',
32
33
  'load', 'reload', 'reload_local', 'load_file', 'reload_file', 'load_env', 'reload_env', 'load_task_env',
33
34
  'DEFAULT_LOGGING_STYLE', 'LOGGING_STYLES', 'ACTIVE_CONFIG_VARS', 'SSH_GROUPS',
@@ -328,18 +329,12 @@ def _inplace_update(original: dict, partial: dict) -> dict:
328
329
  return original
329
330
 
330
331
 
331
- if os.name == 'nt':
332
- PATH_DELIMITER = ';'
333
- else:
334
- PATH_DELIMITER = ':'
335
-
336
-
337
332
  T = TypeVar('T')
338
333
 
339
334
 
340
335
  def __collapse_if_list_impl(value: Union[T, List[str]]) -> Union[T, str]:
341
336
  """If `value` is a list, collapse it to a path-like list (with ':' or ';')."""
342
- return value if not isinstance(value, list) else PATH_DELIMITER.join([str(member) for member in value])
337
+ return value if not isinstance(value, list) else PATH_SEP.join([str(member) for member in value])
343
338
 
344
339
 
345
340
  def __collapse_lists(ns: Namespace) -> Namespace:
@@ -4,7 +4,7 @@
4
4
  """Core exception handling useful for import-time issues."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Dict, Union, Callable, Type
10
10
 
@@ -16,16 +16,16 @@ import functools
16
16
  import traceback
17
17
  from datetime import datetime
18
18
 
19
- # external libs
19
+ # External libs
20
20
  from cmdkit.app import exit_status
21
21
  from cmdkit.config import Namespace
22
22
  from cmdkit.config import ConfigurationError
23
23
  from cmdkit.ansi import faint, bold, magenta, yellow, red, COLOR_STDERR
24
24
 
25
- # internal libs
25
+ # Internal libs
26
26
  from hypershell.core.platform import default_path
27
27
 
28
- # public interface
28
+ # Public interface
29
29
  __all__ = ['display_warning', 'display_error', 'display_critical', 'traceback_filepath', 'write_traceback',
30
30
  'handle_exception', 'handle_exception_silently', 'handle_disconnect', 'handle_address_unknown',
31
31
  'HostAddressInfo', 'DatabaseUninitialized',
@@ -4,11 +4,11 @@
4
4
  """Instrumentation for building finite state machines."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Dict, Callable, Type
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  from enum import Enum
13
13
  from abc import ABC
14
14
  # FUZZ: import time
@@ -16,11 +16,11 @@ from abc import ABC
16
16
  # PERF: from collections import defaultdict
17
17
  # PERF: from time import perf_counter
18
18
 
19
- # internal libs
19
+ # Internal libs
20
20
  from hypershell.core.exceptions import write_traceback
21
21
  from hypershell.core.logging import Logger
22
22
 
23
- # public interface
23
+ # Public interface
24
24
  __all__ = ['State', 'StateMachine', ]
25
25
 
26
26
 
@@ -4,20 +4,20 @@
4
4
  """Heartbeat data passed between client and server."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Type
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import json
13
13
  from enum import Enum
14
14
  from datetime import datetime
15
15
  from dataclasses import dataclass
16
16
 
17
- # internal libs
17
+ # Internal libs
18
18
  from hypershell.core.logging import HOSTNAME, INSTANCE
19
19
 
20
- # public interface
20
+ # Public interface
21
21
  __all__ = ['ClientState', 'Heartbeat']
22
22
 
23
23
 
@@ -4,7 +4,7 @@
4
4
  """Logging configuration."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Tuple, Dict, Any, Type
10
10
 
@@ -16,16 +16,16 @@ import logging
16
16
  import functools
17
17
  import datetime
18
18
 
19
- # external libs
19
+ # External libs
20
20
  from cmdkit.app import exit_status
21
21
  from cmdkit.config import ConfigurationError
22
22
  from cmdkit.ansi import Ansi, COLOR_STDERR
23
23
 
24
- # internal libs
24
+ # Internal libs
25
25
  from hypershell.core.config import config, blame
26
26
  from hypershell.core.exceptions import write_traceback
27
27
 
28
- # public interface
28
+ # Public interface
29
29
  __all__ = ['Logger', 'HOSTNAME', 'INSTANCE', 'handler', 'initialize_logging', ]
30
30
 
31
31
 
@@ -10,18 +10,18 @@
10
10
  # to leave this module in place for the time being.
11
11
 
12
12
 
13
- # standard libs
13
+ # Standard libs
14
14
  import os
15
15
  import sys
16
16
  import ctypes
17
17
  import platform
18
18
 
19
- # external libs
19
+ # External libs
20
20
  from cmdkit.config import Namespace
21
21
  from cmdkit.app import exit_status
22
22
  from cmdkit.ansi import bold, magenta
23
23
 
24
- # public interface
24
+ # Public interface
25
25
  __all__ = ['cwd', 'home', 'site', 'path', 'default_path']
26
26
 
27
27
 
@@ -4,21 +4,21 @@
4
4
  """Queue server/client implementation."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Dict, List, Callable, Union, Optional, Any, Iterable, Type
10
10
  from types import TracebackType
11
11
 
12
- # standard libs
12
+ # Standard libs
13
13
  from multiprocessing.managers import BaseManager
14
14
  from multiprocessing import JoinableQueue
15
15
  from abc import ABC, abstractmethod
16
16
  from dataclasses import dataclass
17
17
 
18
- # internal libs
18
+ # Internal libs
19
19
  from hypershell.core.config import default, config as _config
20
20
 
21
- # public interface
21
+ # Public interface
22
22
  __all__ = ['QueueConfig', 'QueueInterface', 'QueueServer', 'QueueClient']
23
23
 
24
24
 
@@ -4,29 +4,29 @@
4
4
  """Manage remote connections and data."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Tuple, Optional, Type, Union, IO
10
10
  from types import TracebackType
11
11
 
12
- # standard libs
12
+ # Standard libs
13
13
  import os
14
14
  import sys
15
15
  from dataclasses import dataclass
16
16
 
17
- # external libs
17
+ # External libs
18
18
  from paramiko import SSHClient, SFTPClient, ProxyCommand, AutoAddPolicy, SSHConfig as SSHConfigParser
19
19
  from paramiko.channel import ChannelStdinFile, ChannelFile, ChannelStderrFile
20
20
 
21
- # internal libs
21
+ # Internal libs
22
22
  from hypershell.core.logging import Logger
23
23
  from hypershell.core.config import config
24
24
  from hypershell.core.thread import Thread
25
25
 
26
- # public interface
26
+ # Public interface
27
27
  __all__ = ['SSHConfig', 'SSHConnection', 'RemoteProcess', ]
28
28
 
29
- # initialize logger
29
+ # Initialize logger
30
30
  log = Logger.with_name(__name__)
31
31
 
32
32
 
@@ -4,20 +4,20 @@
4
4
  """Signal handling facility."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Optional, Final, Dict
10
10
  from types import FrameType
11
11
 
12
- # standard libs
12
+ # Standard libs
13
13
  import platform
14
14
  from signal import signal as register
15
15
 
16
16
 
17
- # internal libs
17
+ # Internal libs
18
18
  from hypershell.core.logging import Logger
19
19
 
20
- # public interface
20
+ # Public interface
21
21
  __all__ = ['check_signal', 'RECEIVED', 'SIGNAL_MAP',
22
22
  'handler', 'register_handlers', 'register',
23
23
  'SIGUSR1', 'SIGUSR2', 'SIGINT', 'SIGTERM', 'SIGKILL']
@@ -36,7 +36,7 @@ else:
36
36
  SIGKILL: Final[int] = 9
37
37
 
38
38
 
39
- # initialize logger
39
+ # Initialize logger
40
40
  log = Logger.with_name(__name__)
41
41
 
42
42
 
@@ -0,0 +1,69 @@
1
+ # SPDX-FileCopyrightText: 2025 Geoffrey Lentner
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """
5
+ Sanitize and supplement package environment.
6
+
7
+ For most installations this module does nothing and can be ignored.
8
+ For system-wide user-facing non-library installations we do not want user
9
+ programs (which may be Python-based with PYTHONPATH implications) to interfere
10
+ with this program.
11
+
12
+ The HYPERSHELL_PYTHONPATH environment variable takes the place of the normal
13
+ PYTHONPATH environment variable. However, if this variable exists and points to
14
+ a file, the contents of that file represents a frozen path list.
15
+ """
16
+
17
+
18
+ # Type annotations
19
+ from __future__ import annotations
20
+ from typing import List, Final
21
+
22
+ # Standard libs
23
+ import os
24
+ import sys
25
+ import platform
26
+
27
+ # Public interface
28
+ __all__ = ['HYPERSHELL_PYTHONPATH', 'PATH_SEP']
29
+
30
+
31
+ if platform.system() == 'Windows':
32
+ PATH_SEP: Final[str] = ';'
33
+ else:
34
+ PATH_SEP: Final[str] = ':'
35
+
36
+
37
+ HYPERSHELL_PYTHONPATH: Final[str | None] = os.getenv("HYPERSHELL_PYTHONPATH", None)
38
+
39
+
40
+ # If the HYPERSHELL_PYTHONPATH refers to a file path we interpret it to be a frozen list.
41
+ # E.g., (/etc/hypershell.pythonpath)
42
+ # /usr/local/lib
43
+ # /usr/local/lib/python3.12
44
+ # /usr/local/lib/python3.12/lib-dynload
45
+ # /usr/local/lib/python3.12/site-packages
46
+ # /usr/local/lib/hypershell/site-packages
47
+ if HYPERSHELL_PYTHONPATH and os.path.isfile(HYPERSHELL_PYTHONPATH):
48
+ sys.path.clear()
49
+ with open(HYPERSHELL_PYTHONPATH, mode='r') as stream:
50
+ lines = stream.read().strip().split('\n')
51
+ for path in lines:
52
+ if path and not path.startswith('#'):
53
+ if os.path.exists(path):
54
+ sys.path.append(path)
55
+ else:
56
+ print(f'Error: "{path}" not found (HYPERSHELL_PYTHONPATH={HYPERSHELL_PYTHONPATH})',
57
+ file=sys.stderr, flush=True)
58
+ sys.exit(3) # exit_status.bad_config
59
+
60
+ # Otherwise HYPERSHELL_PYTHONPATH is treated exactly like the normal PYTHONPATH variable.
61
+ elif HYPERSHELL_PYTHONPATH:
62
+ lines = HYPERSHELL_PYTHONPATH.strip().split(PATH_SEP)
63
+ for path in lines:
64
+ if os.path.exists(path):
65
+ sys.path.append(path)
66
+ else:
67
+ print(f'Error: "{path}" not found (HYPERSHELL_PYTHONPATH={HYPERSHELL_PYTHONPATH})',
68
+ file=sys.stderr, flush=True)
69
+ sys.exit(3) # exit_status.bad_config
@@ -4,17 +4,17 @@
4
4
  """Tag interface and parsing."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Dict, List, Optional, Type
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  from dataclasses import dataclass
13
13
 
14
- # internal libs
14
+ # Internal libs
15
15
  from hypershell.core.types import JSONValue, smart_coerce
16
16
 
17
- # public interface
17
+ # Public interface
18
18
  __all__ = ['Tag', ]
19
19
 
20
20
 
@@ -4,12 +4,12 @@
4
4
  """Template expansion facility for task execution."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Dict, Callable
10
10
  from types import ModuleType
11
11
 
12
- # standard libs
12
+ # Standard libs
13
13
  import os
14
14
  import re
15
15
  import math
@@ -17,10 +17,10 @@ import datetime
17
17
  import subprocess
18
18
  import functools
19
19
 
20
- # internal libs
20
+ # Internal libs
21
21
  from hypershell.core.types import smart_coerce
22
22
 
23
- # public interface
23
+ # Public interface
24
24
  __all__ = ['Template', 'DEFAULT_TEMPLATE', ]
25
25
 
26
26
 
@@ -4,15 +4,15 @@
4
4
  """Thread base class implementation."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Optional, Type
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import threading
13
13
  from abc import ABC, abstractmethod
14
14
 
15
- # public interface
15
+ # Public interface
16
16
  __all__ = ['Thread', ]
17
17
 
18
18
 
@@ -4,10 +4,10 @@
4
4
  """Automatic type coercion of input data."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from typing import TypeVar
9
9
 
10
- # public interface
10
+ # Public interface
11
11
  __all__ = ['smart_coerce', 'JSONValue']
12
12
 
13
13
 
@@ -4,15 +4,15 @@
4
4
  """Database interface, models, and methods."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Final
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import sys
13
13
  import functools
14
14
 
15
- # external libs
15
+ # External libs
16
16
  from cmdkit.app import Application, exit_status
17
17
  from cmdkit.cli import Interface
18
18
  from cmdkit.config import ConfigurationError
@@ -20,17 +20,17 @@ from sqlalchemy import inspect
20
20
  from sqlalchemy.orm import close_all_sessions
21
21
  from sqlalchemy.exc import OperationalError
22
22
 
23
- # internal libs
23
+ # Internal libs
24
24
  from hypershell.core.logging import Logger
25
25
  from hypershell.core.config import config
26
26
  from hypershell.core.exceptions import handle_exception, DatabaseUninitialized, get_shared_exception_mapping
27
27
  from hypershell.data.core import engine, in_memory, schema
28
28
  from hypershell.data.model import Entity, Task
29
29
 
30
- # public interface
30
+ # Public interface
31
31
  __all__ = ['InitDBApp', 'initdb', 'truncatedb', 'checkdb', 'ensuredb', 'DATABASE_ENABLED', ]
32
32
 
33
- # initialize logger
33
+ # Initialize logger
34
34
  log = Logger.with_name(__name__)
35
35
 
36
36
 
@@ -4,16 +4,16 @@
4
4
  """Core interface for database engine and session manager."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import Any, Type
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import sys
13
13
  import logging
14
14
  from urllib.parse import urlencode
15
15
 
16
- # external libs
16
+ # External libs
17
17
  from cmdkit.app import exit_status
18
18
  from cmdkit.config import Namespace, ConfigurationError
19
19
  from sqlalchemy.engine import create_engine, Engine
@@ -21,12 +21,12 @@ from sqlalchemy.pool import StaticPool
21
21
  from sqlalchemy.orm import sessionmaker, scoped_session
22
22
  from sqlalchemy.exc import ArgumentError
23
23
 
24
- # internal libs
24
+ # Internal libs
25
25
  from hypershell.core.config import config
26
26
  from hypershell.core.logging import handler
27
27
  from hypershell.core.exceptions import display_critical, write_traceback
28
28
 
29
- # public interface
29
+ # Public interface
30
30
  __all__ = ['DatabaseURL', 'engine', 'Session', 'config', 'in_memory', 'schema', ]
31
31
 
32
32
 
@@ -4,17 +4,17 @@
4
4
  """Database models."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import List, Dict, Tuple, Any, Type, TypeVar, Union, Optional
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import re
13
13
  import json
14
14
  from uuid import uuid4 as gen_uuid
15
15
  from datetime import datetime
16
16
 
17
- # external libs
17
+ # External libs
18
18
  from sqlalchemy import Column, Index, func
19
19
  from sqlalchemy.orm import Query, DeclarativeBase, Mapped, mapped_column
20
20
  from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
@@ -22,17 +22,17 @@ from sqlalchemy.ext.declarative import declared_attr
22
22
  from sqlalchemy.types import Integer, DateTime, Text, Boolean, JSON as _JSON
23
23
  from sqlalchemy.dialects.postgresql import SMALLINT, UUID as POSTGRES_UUID, JSONB as POSTGRES_JSON
24
24
 
25
- # internal libs
25
+ # Internal libs
26
26
  from hypershell.core.logging import Logger, HOSTNAME, INSTANCE
27
27
  from hypershell.core.heartbeat import Heartbeat
28
28
  from hypershell.core.types import JSONValue
29
29
  from hypershell.core.tag import Tag
30
30
  from hypershell.data.core import schema, Session
31
31
 
32
- # public interface
32
+ # Public interface
33
33
  __all__ = ['Task', 'Client', 'Entity', 'to_json_type', 'from_json_type', ]
34
34
 
35
- # initialize logger
35
+ # Initialize logger
36
36
  log = Logger.with_name(__name__)
37
37
 
38
38
 
@@ -40,12 +40,12 @@ Warning:
40
40
  """
41
41
 
42
42
 
43
- # type annotations
43
+ # Type annotations
44
44
  from __future__ import annotations
45
45
  from typing import List, Dict, Tuple, Iterable, IO, Optional, Callable, Type, Final
46
46
  from types import TracebackType
47
47
 
48
- # standard libs
48
+ # Standard libs
49
49
  import sys
50
50
  import time
51
51
  from enum import Enum
@@ -54,11 +54,11 @@ from functools import cached_property
54
54
  from itertools import islice
55
55
  from queue import Empty as QueueEmpty, Full as QueueFull
56
56
 
57
- # external libs
57
+ # External libs
58
58
  from cmdkit.app import Application
59
59
  from cmdkit.cli import Interface, ArgumentError
60
60
 
61
- # internal libs
61
+ # Internal libs
62
62
  from hypershell.core.exceptions import get_shared_exception_mapping
63
63
  from hypershell.core.config import config, default, find_available_ports
64
64
  from hypershell.core.logging import Logger
@@ -72,13 +72,13 @@ from hypershell.data import ensuredb, DATABASE_ENABLED
72
72
  from hypershell.submit import SubmitThread, LiveSubmitThread, DEFAULT_BUNDLEWAIT
73
73
  from hypershell.client import ClientInfo
74
74
 
75
- # public interface
75
+ # Public interface
76
76
  __all__ = ['serve_from', 'serve_file', 'serve_forever', 'ServerThread', 'ServerApp',
77
77
  'DEFAULT_BUNDLESIZE', 'DEFAULT_BUNDLEWAIT', 'DEFAULT_ATTEMPTS',
78
78
  'DEFAULT_EVICT', 'DEFAULT_EAGER_MODE', 'DEFAULT_QUERY_PAUSE',
79
79
  'DEFAULT_BIND', 'DEFAULT_PORT', 'DEFAULT_AUTH']
80
80
 
81
- # initialize logger
81
+ # Initialize logger
82
82
  log = Logger.with_name(__name__)
83
83
 
84
84
 
@@ -37,12 +37,12 @@ Warning:
37
37
  """
38
38
 
39
39
 
40
- # type annotations
40
+ # Type annotations
41
41
  from __future__ import annotations
42
42
  from typing import List, Iterable, Iterator, IO, Optional, Dict, Callable, Type, Final
43
43
  from types import TracebackType
44
44
 
45
- # standard libs
45
+ # Standard libs
46
46
  import io
47
47
  import sys
48
48
  import functools
@@ -50,12 +50,12 @@ from enum import Enum
50
50
  from datetime import datetime
51
51
  from queue import Queue, Empty as QueueEmpty, Full as QueueFull
52
52
 
53
- # external libs
53
+ # External libs
54
54
  from cmdkit.config import ConfigurationError
55
55
  from cmdkit.app import Application
56
56
  from cmdkit.cli import Interface, ArgumentError
57
57
 
58
- # internal libs
58
+ # Internal libs
59
59
  from hypershell.core.logging import Logger
60
60
  from hypershell.core.config import config, default
61
61
  from hypershell.core.fsm import State, StateMachine
@@ -68,11 +68,11 @@ from hypershell.data.model import Task
68
68
  from hypershell.data import initdb, checkdb
69
69
  from hypershell.task import Tag
70
70
 
71
- # public interface
71
+ # Public interface
72
72
  __all__ = ['submit_from', 'submit_file', 'SubmitThread', 'LiveSubmitThread',
73
73
  'SubmitApp', 'DEFAULT_BUNDLESIZE', 'DEFAULT_BUNDLEWAIT', 'DEFAULT_TEMPLATE']
74
74
 
75
- # initialize logger
75
+ # Initialize logger
76
76
  log = Logger.with_name(__name__)
77
77
 
78
78
 
@@ -4,11 +4,11 @@
4
4
  """Task based operations."""
5
5
 
6
6
 
7
- # type annotations
7
+ # Type annotations
8
8
  from __future__ import annotations
9
9
  from typing import List, Dict, Callable, IO, Tuple, Any, Optional, Type, Final
10
10
 
11
- # standard libs
11
+ # Standard libs
12
12
  import os
13
13
  import re
14
14
  import sys
@@ -21,7 +21,7 @@ from datetime import timedelta, datetime
21
21
  from dataclasses import dataclass
22
22
  from shutil import copyfileobj
23
23
 
24
- # external libs
24
+ # External libs
25
25
  import yaml
26
26
  from rich.console import Console
27
27
  from rich.syntax import Syntax
@@ -34,7 +34,7 @@ from sqlalchemy.orm import Query
34
34
  from sqlalchemy.orm.exc import StaleDataError
35
35
  from sqlalchemy.sql.elements import BinaryExpression
36
36
 
37
- # internal libs
37
+ # Internal libs
38
38
  from hypershell.core.platform import default_path
39
39
  from hypershell.core.config import config
40
40
  from hypershell.core.exceptions import handle_exception, handle_exception_silently, get_shared_exception_mapping
@@ -46,10 +46,10 @@ from hypershell.data.core import Session
46
46
  from hypershell.data.model import Task, to_json_type
47
47
  from hypershell.data import ensuredb
48
48
 
49
- # public interface
49
+ # Public interface
50
50
  __all__ = ['TaskGroupApp', ]
51
51
 
52
- # initialize logger
52
+ # Initialize logger
53
53
  log = Logger.with_name(__name__)
54
54
 
55
55
 
@@ -1,39 +0,0 @@
1
- # SPDX-FileCopyrightText: 2025 Geoffrey Lentner
2
- # SPDX-License-Identifier: Apache-2.0
3
-
4
- """
5
- Sanitize and supplement package environment.
6
-
7
- For most installations this module does nothing and can be ignored.
8
- For system installation as an application (non-library use) we do not want user
9
- programs (which may be Python-based with PYTHONPATH implications) to interfere
10
- with this program.
11
-
12
- If we are not installed in the user-site, we strip the user site-packages from
13
- `sys.path` as well as the current working directory. It should not matter what
14
- directory you run this program from.
15
-
16
- If `ctx.path.system.config`/hypershell.pth exists it will take this as truth
17
- """
18
-
19
- # Standard libs
20
- import sys
21
-
22
- if sys
23
-
24
- # NOTE:
25
- # This special module freezes the internal sys.path used by the application.
26
- # We do not want to do this for library use or under any normal circumstances.
27
- # When the program is installed system wide as a utility we need to ensure that
28
- # we are not being polluted by some other applications environment (e.g., PYTHONPATH).
29
- # This also allows us to suppliment with special locations of vendored dependencies.
30
- print('FIXING IMPORTS', flush=True)
31
- sys.path.clear()
32
- sys.path.extend([
33
- '/Library/Frameworks/Python.framework/Versions/3.12/lib/python312.zip',
34
- '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12',
35
- '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload',
36
- '/Users/geoffrey/Library/Caches/pypoetry/virtualenvs/hypershell-NY9Seigz-py3.12/lib/python3.12/site-packages',
37
- '/Users/geoffrey/Code/github.com/hypershell/hypershell/src'
38
- ])
39
- print('FIXING IMPORTS - DONE', flush=True)
File without changes
File without changes