meerschaum 3.0.0rc3__py3-none-any.whl → 3.0.0rc7__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.
- meerschaum/_internal/arguments/_parser.py +14 -2
- meerschaum/_internal/cli/__init__.py +6 -0
- meerschaum/_internal/cli/daemons.py +103 -0
- meerschaum/_internal/cli/entry.py +220 -0
- meerschaum/_internal/cli/workers.py +434 -0
- meerschaum/_internal/docs/index.py +1 -2
- meerschaum/_internal/entry.py +44 -8
- meerschaum/_internal/shell/Shell.py +113 -19
- meerschaum/_internal/shell/__init__.py +4 -1
- meerschaum/_internal/static.py +3 -1
- meerschaum/_internal/term/TermPageHandler.py +1 -2
- meerschaum/_internal/term/__init__.py +40 -6
- meerschaum/_internal/term/tools.py +33 -8
- meerschaum/actions/__init__.py +6 -4
- meerschaum/actions/api.py +39 -11
- meerschaum/actions/attach.py +1 -0
- meerschaum/actions/delete.py +4 -2
- meerschaum/actions/edit.py +27 -8
- meerschaum/actions/login.py +8 -8
- meerschaum/actions/register.py +13 -7
- meerschaum/actions/reload.py +22 -5
- meerschaum/actions/restart.py +14 -0
- meerschaum/actions/show.py +69 -4
- meerschaum/actions/start.py +135 -14
- meerschaum/actions/stop.py +36 -3
- meerschaum/actions/sync.py +6 -1
- meerschaum/api/__init__.py +35 -13
- meerschaum/api/_events.py +7 -2
- meerschaum/api/_oauth2.py +47 -4
- meerschaum/api/dash/callbacks/dashboard.py +103 -97
- meerschaum/api/dash/callbacks/jobs.py +3 -2
- meerschaum/api/dash/callbacks/login.py +10 -1
- meerschaum/api/dash/callbacks/pipes.py +136 -57
- meerschaum/api/dash/callbacks/register.py +9 -2
- meerschaum/api/dash/callbacks/tokens.py +2 -1
- meerschaum/api/dash/components.py +6 -7
- meerschaum/api/dash/keys.py +17 -1
- meerschaum/api/dash/pages/login.py +2 -2
- meerschaum/api/dash/pages/pipes.py +14 -4
- meerschaum/api/dash/pipes.py +186 -65
- meerschaum/api/dash/tokens.py +1 -1
- meerschaum/api/dash/webterm.py +14 -6
- meerschaum/api/models/_pipes.py +7 -1
- meerschaum/api/resources/static/js/terminado.js +3 -0
- meerschaum/api/resources/static/js/xterm-addon-unicode11.js +2 -0
- meerschaum/api/resources/templates/termpage.html +1 -0
- meerschaum/api/routes/_jobs.py +23 -11
- meerschaum/api/routes/_login.py +73 -5
- meerschaum/api/routes/_pipes.py +6 -4
- meerschaum/api/routes/_webterm.py +3 -3
- meerschaum/config/__init__.py +60 -13
- meerschaum/config/_default.py +89 -61
- meerschaum/config/_edit.py +10 -8
- meerschaum/config/_formatting.py +2 -0
- meerschaum/config/_patch.py +4 -2
- meerschaum/config/_paths.py +127 -12
- meerschaum/config/_read_config.py +20 -10
- meerschaum/config/_version.py +1 -1
- meerschaum/config/environment.py +262 -0
- meerschaum/config/stack/__init__.py +7 -5
- meerschaum/connectors/_Connector.py +1 -2
- meerschaum/connectors/__init__.py +37 -2
- meerschaum/connectors/api/_APIConnector.py +1 -1
- meerschaum/connectors/api/_jobs.py +11 -0
- meerschaum/connectors/api/_pipes.py +7 -1
- meerschaum/connectors/instance/_plugins.py +9 -1
- meerschaum/connectors/instance/_tokens.py +20 -3
- meerschaum/connectors/instance/_users.py +8 -1
- meerschaum/connectors/parse.py +1 -1
- meerschaum/connectors/sql/_create_engine.py +3 -0
- meerschaum/connectors/sql/_pipes.py +98 -79
- meerschaum/connectors/sql/_users.py +8 -1
- meerschaum/connectors/sql/tables/__init__.py +20 -3
- meerschaum/connectors/valkey/_ValkeyConnector.py +3 -3
- meerschaum/connectors/valkey/_pipes.py +7 -5
- meerschaum/core/Pipe/__init__.py +62 -72
- meerschaum/core/Pipe/_attributes.py +66 -90
- meerschaum/core/Pipe/_cache.py +555 -0
- meerschaum/core/Pipe/_clear.py +0 -11
- meerschaum/core/Pipe/_data.py +0 -50
- meerschaum/core/Pipe/_deduplicate.py +0 -13
- meerschaum/core/Pipe/_delete.py +12 -21
- meerschaum/core/Pipe/_drop.py +11 -23
- meerschaum/core/Pipe/_dtypes.py +1 -1
- meerschaum/core/Pipe/_index.py +8 -14
- meerschaum/core/Pipe/_sync.py +12 -18
- meerschaum/core/Plugin/_Plugin.py +7 -1
- meerschaum/core/Token/_Token.py +1 -1
- meerschaum/core/User/_User.py +1 -2
- meerschaum/jobs/_Executor.py +88 -4
- meerschaum/jobs/_Job.py +135 -35
- meerschaum/jobs/systemd.py +7 -2
- meerschaum/plugins/__init__.py +277 -81
- meerschaum/utils/_get_pipes.py +30 -4
- meerschaum/utils/daemon/Daemon.py +195 -41
- meerschaum/utils/daemon/FileDescriptorInterceptor.py +0 -1
- meerschaum/utils/daemon/RotatingFile.py +63 -36
- meerschaum/utils/daemon/StdinFile.py +53 -13
- meerschaum/utils/daemon/__init__.py +18 -5
- meerschaum/utils/daemon/_names.py +6 -3
- meerschaum/utils/debug.py +34 -4
- meerschaum/utils/dtypes/__init__.py +5 -1
- meerschaum/utils/formatting/__init__.py +4 -1
- meerschaum/utils/formatting/_jobs.py +1 -1
- meerschaum/utils/formatting/_pipes.py +47 -46
- meerschaum/utils/formatting/_pprint.py +1 -0
- meerschaum/utils/formatting/_shell.py +16 -6
- meerschaum/utils/misc.py +18 -38
- meerschaum/utils/packages/__init__.py +15 -13
- meerschaum/utils/packages/_packages.py +1 -0
- meerschaum/utils/pipes.py +39 -7
- meerschaum/utils/process.py +1 -1
- meerschaum/utils/prompt.py +171 -144
- meerschaum/utils/sql.py +12 -2
- meerschaum/utils/threading.py +42 -0
- meerschaum/utils/venv/__init__.py +2 -0
- meerschaum/utils/warnings.py +19 -13
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/METADATA +3 -1
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/RECORD +125 -119
- meerschaum/config/_environment.py +0 -145
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/WHEEL +0 -0
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/entry_points.txt +0 -0
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/licenses/LICENSE +0 -0
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/licenses/NOTICE +0 -0
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/top_level.txt +0 -0
- {meerschaum-3.0.0rc3.dist-info → meerschaum-3.0.0rc7.dist-info}/zip-safe +0 -0
@@ -1,145 +0,0 @@
|
|
1
|
-
#! /usr/bin/env python3
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
# vim:fenc=utf-8
|
4
|
-
|
5
|
-
"""
|
6
|
-
Patch the runtime configuration from environment variables.
|
7
|
-
"""
|
8
|
-
|
9
|
-
import os
|
10
|
-
import re
|
11
|
-
import json
|
12
|
-
from meerschaum.utils.typing import List, Union, Dict, Any
|
13
|
-
from meerschaum._internal.static import STATIC_CONFIG
|
14
|
-
|
15
|
-
def apply_environment_patches() -> None:
|
16
|
-
"""
|
17
|
-
Apply patches defined in `MRSM_CONFIG` and `MRSM_PATCH`.
|
18
|
-
"""
|
19
|
-
config_var = STATIC_CONFIG['environment']['config']
|
20
|
-
patch_var = STATIC_CONFIG['environment']['patch']
|
21
|
-
apply_environment_config(config_var)
|
22
|
-
apply_environment_config(patch_var)
|
23
|
-
|
24
|
-
|
25
|
-
def apply_environment_config(env_var: str) -> None:
|
26
|
-
"""
|
27
|
-
Parse a dictionary (simple or JSON) from an environment variable
|
28
|
-
and apply it to the current configuration.
|
29
|
-
"""
|
30
|
-
from meerschaum.config import get_config, set_config, _config
|
31
|
-
from meerschaum.config._patch import apply_patch_to_config
|
32
|
-
if env_var not in os.environ:
|
33
|
-
return
|
34
|
-
from meerschaum.utils.misc import string_to_dict
|
35
|
-
try:
|
36
|
-
_patch = string_to_dict(str(os.environ[env_var]).lstrip())
|
37
|
-
except Exception as e:
|
38
|
-
_patch = None
|
39
|
-
error_msg = (
|
40
|
-
f"Environment variable {env_var} is set but cannot be parsed.\n"
|
41
|
-
f"Unset {env_var} or change to JSON or simplified dictionary format " +
|
42
|
-
"(see --help, under params for formatting)\n" +
|
43
|
-
f"{env_var} is set to:\n{os.environ[env_var]}\n"
|
44
|
-
f"Skipping patching os environment into config..."
|
45
|
-
)
|
46
|
-
|
47
|
-
if not isinstance(_patch, dict):
|
48
|
-
print(error_msg)
|
49
|
-
return
|
50
|
-
|
51
|
-
valids = []
|
52
|
-
|
53
|
-
def load_key(key: str) -> Union[Dict[str, Any], None]:
|
54
|
-
try:
|
55
|
-
c = get_config(key, warn=False)
|
56
|
-
except Exception as e:
|
57
|
-
c = None
|
58
|
-
return c
|
59
|
-
|
60
|
-
### This was multi-threaded, but I ran into all sorts of locking issues.
|
61
|
-
keys = list(_patch.keys())
|
62
|
-
for key in keys:
|
63
|
-
_ = load_key(key)
|
64
|
-
|
65
|
-
### Load and patch config files.
|
66
|
-
set_config(
|
67
|
-
apply_patch_to_config(
|
68
|
-
_config(),
|
69
|
-
_patch,
|
70
|
-
)
|
71
|
-
)
|
72
|
-
|
73
|
-
|
74
|
-
def apply_environment_uris() -> None:
|
75
|
-
"""
|
76
|
-
Patch temporary connectors defined in environment variables which start with
|
77
|
-
`MRSM_SQL_` or `MRSM_API_`.
|
78
|
-
"""
|
79
|
-
for env_var in get_connector_env_vars():
|
80
|
-
apply_connector_uri(env_var)
|
81
|
-
|
82
|
-
|
83
|
-
def get_connector_env_regex() -> str:
|
84
|
-
"""
|
85
|
-
Return the regex pattern for valid environment variable names for instance connectors.
|
86
|
-
"""
|
87
|
-
return STATIC_CONFIG['environment']['uri_regex']
|
88
|
-
|
89
|
-
|
90
|
-
def get_connector_env_vars() -> List[str]:
|
91
|
-
"""
|
92
|
-
Get the names of the environment variables which match the Meerschaum connector regex.
|
93
|
-
|
94
|
-
Examples
|
95
|
-
--------
|
96
|
-
>>> get_connector_environment_vars()
|
97
|
-
['MRSM_SQL_FOO']
|
98
|
-
"""
|
99
|
-
uri_regex = get_connector_env_regex()
|
100
|
-
env_vars = []
|
101
|
-
for env_var in os.environ:
|
102
|
-
matched = re.match(uri_regex, env_var)
|
103
|
-
if matched is None:
|
104
|
-
continue
|
105
|
-
if env_var in STATIC_CONFIG['environment'].values():
|
106
|
-
continue
|
107
|
-
env_vars.append(env_var)
|
108
|
-
return env_vars
|
109
|
-
|
110
|
-
|
111
|
-
def apply_connector_uri(env_var: str) -> None:
|
112
|
-
"""
|
113
|
-
Parse and validate a URI obtained from an environment variable.
|
114
|
-
"""
|
115
|
-
from meerschaum.config import get_config, set_config, _config
|
116
|
-
from meerschaum.config._patch import apply_patch_to_config
|
117
|
-
from meerschaum.config._read_config import search_and_substitute_config
|
118
|
-
from meerschaum.utils.warnings import warn
|
119
|
-
uri_regex = get_connector_env_regex()
|
120
|
-
matched = re.match(uri_regex, env_var)
|
121
|
-
groups = matched.groups()
|
122
|
-
typ, label = groups[0].lower(), groups[1].lower()
|
123
|
-
uri = os.environ[env_var]
|
124
|
-
if uri.lstrip().startswith('{') and uri.rstrip().endswith('}'):
|
125
|
-
try:
|
126
|
-
conn_attrs = json.loads(uri)
|
127
|
-
except Exception as e:
|
128
|
-
warn(f"Unable to parse JSON for environment connector '{typ}:{label}'.")
|
129
|
-
conn_attrs = {'uri': uri}
|
130
|
-
else:
|
131
|
-
conn_attrs = {'uri': uri}
|
132
|
-
set_config(
|
133
|
-
apply_patch_to_config(
|
134
|
-
{'meerschaum': get_config('meerschaum')},
|
135
|
-
{'meerschaum': {'connectors': {typ: {label: conn_attrs}}}},
|
136
|
-
)
|
137
|
-
)
|
138
|
-
|
139
|
-
|
140
|
-
def get_env_vars() -> List[str]:
|
141
|
-
"""
|
142
|
-
Return all environment variables which begin with `'MRSM_'`.
|
143
|
-
"""
|
144
|
-
prefix = STATIC_CONFIG['environment']['prefix']
|
145
|
-
return sorted([env_var for env_var in os.environ if env_var.startswith(prefix)])
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|