by-framework 0.2.2.dev8__py3-none-any.whl → 0.2.2.dev9__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.
- by_framework/admin/cli.py +3 -2
- by_framework/common/config.py +10 -1
- by_framework/common/constants.py +13 -3
- by_framework/worker/app.py +29 -11
- {by_framework-0.2.2.dev8.dist-info → by_framework-0.2.2.dev9.dist-info}/METADATA +1 -1
- {by_framework-0.2.2.dev8.dist-info → by_framework-0.2.2.dev9.dist-info}/RECORD +9 -9
- {by_framework-0.2.2.dev8.dist-info → by_framework-0.2.2.dev9.dist-info}/WHEEL +0 -0
- {by_framework-0.2.2.dev8.dist-info → by_framework-0.2.2.dev9.dist-info}/entry_points.txt +0 -0
- {by_framework-0.2.2.dev8.dist-info → by_framework-0.2.2.dev9.dist-info}/licenses/LICENSE +0 -0
by_framework/admin/cli.py
CHANGED
|
@@ -31,8 +31,9 @@ app = typer.Typer(
|
|
|
31
31
|
help=(
|
|
32
32
|
"by-framework cluster admin CLI. For Redis Cluster, omit --redis-url "
|
|
33
33
|
"and set REDIS_CLUSTER_HOST (comma-separated host:port list; implies "
|
|
34
|
-
"cluster mode
|
|
35
|
-
"REDIS_CLUSTER_NODES
|
|
34
|
+
"both cluster mode and REDIS_KEY_SCHEMA_VERSION=v2 unless set "
|
|
35
|
+
"explicitly). REDIS_MODE=cluster + REDIS_CLUSTER_NODES + "
|
|
36
|
+
"REDIS_KEY_SCHEMA_VERSION=v2 also still works."
|
|
36
37
|
),
|
|
37
38
|
)
|
|
38
39
|
worker_app = typer.Typer(no_args_is_help=True)
|
by_framework/common/config.py
CHANGED
|
@@ -9,6 +9,7 @@ from dataclasses import dataclass, field
|
|
|
9
9
|
from typing import Literal, Optional
|
|
10
10
|
|
|
11
11
|
from by_framework.common.constants import RedisKeys
|
|
12
|
+
from by_framework.common.logger import logger
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
@dataclass(frozen=True)
|
|
@@ -36,6 +37,9 @@ class RedisConfig:
|
|
|
36
37
|
to switch to cluster mode, no separate REDIS_MODE=cluster needed.
|
|
37
38
|
An explicit REDIS_MODE still takes precedence when set, so existing
|
|
38
39
|
explicit REDIS_MODE=cluster + REDIS_CLUSTER_NODES setups keep working.
|
|
40
|
+
|
|
41
|
+
REDIS_DATABASE replaces REDIS_DB (which still works as a deprecated
|
|
42
|
+
fallback, logging a warning, during the transition period).
|
|
39
43
|
"""
|
|
40
44
|
password = os.environ.get("REDIS_PASSWORD", "")
|
|
41
45
|
username = os.environ.get("REDIS_USERNAME") or None
|
|
@@ -51,10 +55,15 @@ class RedisConfig:
|
|
|
51
55
|
for node in cluster_nodes_str.split(","):
|
|
52
56
|
node_host, node_port = node.rsplit(":", 1)
|
|
53
57
|
cluster_nodes.append((node_host, int(node_port)))
|
|
58
|
+
db_str = os.environ.get("REDIS_DATABASE")
|
|
59
|
+
if db_str is None:
|
|
60
|
+
db_str = os.environ.get("REDIS_DB")
|
|
61
|
+
if db_str is not None:
|
|
62
|
+
logger.warning("REDIS_DB is deprecated, use REDIS_DATABASE instead")
|
|
54
63
|
return cls(
|
|
55
64
|
host=os.environ.get("REDIS_HOST", "localhost"),
|
|
56
65
|
port=int(os.environ.get("REDIS_PORT", "6379")),
|
|
57
|
-
db=int(
|
|
66
|
+
db=int(db_str) if db_str is not None else 0,
|
|
58
67
|
password=password,
|
|
59
68
|
username=username,
|
|
60
69
|
max_connections=int(max_connections) if max_connections else None,
|
by_framework/common/constants.py
CHANGED
|
@@ -12,10 +12,20 @@ from typing import Optional
|
|
|
12
12
|
def get_key_schema_version() -> str:
|
|
13
13
|
"""Return the configured Redis key schema version ("v1" or "v2").
|
|
14
14
|
|
|
15
|
-
Controlled by REDIS_KEY_SCHEMA_VERSION,
|
|
16
|
-
|
|
15
|
+
Controlled by REDIS_KEY_SCHEMA_VERSION, which always wins when set
|
|
16
|
+
explicitly. When it isn't set, REDIS_CLUSTER_HOST being configured
|
|
17
|
+
implies "v2" (cluster mode requires v2 - v1 keys have no hash tags and
|
|
18
|
+
hit CROSSSLOT errors under Cluster; see redis_client.init_redis's
|
|
19
|
+
fail-fast check); otherwise it defaults to "v1" (the legacy unprefixed
|
|
20
|
+
key format). This mirrors RedisConfig.from_env()'s REDIS_MODE/
|
|
21
|
+
REDIS_CLUSTER_HOST precedence, but deliberately does NOT infer "v2"
|
|
22
|
+
from an explicit REDIS_MODE=cluster alone (without REDIS_CLUSTER_HOST)
|
|
23
|
+
- that legacy explicit-mode path still requires
|
|
24
|
+
REDIS_KEY_SCHEMA_VERSION=v2 to be set by hand.
|
|
17
25
|
"""
|
|
18
|
-
version = os.environ.get("REDIS_KEY_SCHEMA_VERSION"
|
|
26
|
+
version = os.environ.get("REDIS_KEY_SCHEMA_VERSION")
|
|
27
|
+
if version is None:
|
|
28
|
+
version = "v2" if os.environ.get("REDIS_CLUSTER_HOST") else "v1"
|
|
19
29
|
if version not in ("v1", "v2"):
|
|
20
30
|
raise ValueError(
|
|
21
31
|
f"Invalid REDIS_KEY_SCHEMA_VERSION: {version!r} (must be 'v1' or 'v2')"
|
by_framework/worker/app.py
CHANGED
|
@@ -131,6 +131,17 @@ async def _run_worker_async(
|
|
|
131
131
|
# parties can configure either mode purely programmatically or purely
|
|
132
132
|
# via env vars, without the two modes behaving inconsistently.
|
|
133
133
|
env_config = RedisConfig.from_env()
|
|
134
|
+
if redis_mode is not None:
|
|
135
|
+
effective_mode = redis_mode
|
|
136
|
+
elif redis_cluster_nodes:
|
|
137
|
+
# Mirrors REDIS_CLUSTER_HOST's env-var precedence: passing
|
|
138
|
+
# redis_cluster_nodes alone is enough to imply cluster mode, no
|
|
139
|
+
# separate redis_mode="cluster" required. Without this, passing
|
|
140
|
+
# redis_cluster_nodes alone would silently stay in standalone mode
|
|
141
|
+
# and the nodes list would be dropped on the floor.
|
|
142
|
+
effective_mode = "cluster"
|
|
143
|
+
else:
|
|
144
|
+
effective_mode = env_config.mode
|
|
134
145
|
effective_config = replace(
|
|
135
146
|
env_config,
|
|
136
147
|
host=redis_host if redis_host is not None else env_config.host,
|
|
@@ -142,7 +153,7 @@ async def _run_worker_async(
|
|
|
142
153
|
username=(
|
|
143
154
|
redis_username if redis_username is not None else env_config.username
|
|
144
155
|
),
|
|
145
|
-
mode=
|
|
156
|
+
mode=effective_mode,
|
|
146
157
|
cluster_nodes=(
|
|
147
158
|
redis_cluster_nodes
|
|
148
159
|
if redis_cluster_nodes is not None
|
|
@@ -276,16 +287,23 @@ def run_worker(
|
|
|
276
287
|
Redis configuration: every redis_* argument defaults to None, meaning
|
|
277
288
|
"not specified" - when not passed, the value is read from the
|
|
278
289
|
corresponding REDIS_* environment variable (REDIS_HOST, REDIS_PORT,
|
|
279
|
-
|
|
280
|
-
REDIS_CLUSTER_NODES), falling back to
|
|
281
|
-
none is set.
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
REDIS_DATABASE, REDIS_PASSWORD, REDIS_USERNAME, REDIS_MODE,
|
|
291
|
+
REDIS_CLUSTER_HOST, REDIS_CLUSTER_NODES), falling back to
|
|
292
|
+
"localhost"/6379/standalone if none is set. REDIS_DATABASE replaces
|
|
293
|
+
REDIS_DB (still works as a deprecated fallback, logging a warning).
|
|
294
|
+
Setting REDIS_CLUSTER_HOST (comma-separated "host:port" list) alone is
|
|
295
|
+
enough to switch to cluster mode - no separate REDIS_MODE=cluster
|
|
296
|
+
required, though an explicit REDIS_MODE still wins if set; it also
|
|
297
|
+
implies REDIS_KEY_SCHEMA_VERSION=v2 unless that's set explicitly. An
|
|
298
|
+
explicitly-passed argument always takes precedence over its env var,
|
|
299
|
+
for every field, in both standalone and cluster mode. The same
|
|
300
|
+
single-argument convenience carries over to the programmatic path:
|
|
301
|
+
passing just ``redis_cluster_nodes=[("h1", 6379)]`` (no ``redis_mode``)
|
|
302
|
+
is enough to switch to cluster mode, mirroring REDIS_CLUSTER_HOST -
|
|
303
|
+
``redis_mode`` only needs to be passed to explicitly force a mode
|
|
304
|
+
(e.g. pin a script to standalone regardless of REDIS_CLUSTER_HOST).
|
|
305
|
+
So either mode can be configured purely programmatically or purely via
|
|
306
|
+
env vars, without the two paths behaving inconsistently.
|
|
289
307
|
|
|
290
308
|
Plugin support:
|
|
291
309
|
- **Auto mode**: System automatically discovers and loads all subclasses
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
by_framework/__init__.py,sha256=5Ff4xfX-TNXcp4RMoBLQCWuehPMLpNRHwZrXofgFx5A,5300
|
|
2
2
|
by_framework/__main__.py,sha256=_vIEieJzSHfZnPp-zna_hbVtWQUgE0I3mrWD41WzXiA,2561
|
|
3
3
|
by_framework/admin/__init__.py,sha256=MKGQBtKk8YdnMrZ5gkzEemMl4iL8OfeFhEV6HdWR2XI,138
|
|
4
|
-
by_framework/admin/cli.py,sha256=
|
|
4
|
+
by_framework/admin/cli.py,sha256=KBmTHONKdb6BeskW6d3DL6GRnL91xen0PJ80JB0h0lc,11710
|
|
5
5
|
by_framework/admin/worker_manager.py,sha256=ihXRMlFJAR74T2JSh3xTNCDjzAElWd0-_yVDAZwSTJU,5924
|
|
6
6
|
by_framework/client/__init__.py,sha256=kGP7uoXIlTJuiJ2Cgl1Q5wqYjnMA4SZqoa7Q7BhQ5JQ,272
|
|
7
7
|
by_framework/client/byai_client.py,sha256=bB1NyKLvVW82bXefD_3zymqZ1vk2O925CIbxOho9Qww,2426
|
|
8
8
|
by_framework/client/client.py,sha256=T_5ahX9enmsaXm-xBGvwpMx-yALzO7wOTgY-qAVj0Q4,40342
|
|
9
9
|
by_framework/common/__init__.py,sha256=EkfIiVdmb8SCpi7OOUm6Hu84B7Wzekb-TG2hbvD_R1w,1685
|
|
10
|
-
by_framework/common/config.py,sha256=
|
|
11
|
-
by_framework/common/constants.py,sha256=
|
|
10
|
+
by_framework/common/config.py,sha256=RGe5Ce-uUgpZv1bgkdT4kCRcaIpaYhzskyvQy17Qn_o,5043
|
|
11
|
+
by_framework/common/constants.py,sha256=xUp6Nvx31EH7EzkxDNBzXD0GIE9FpPnPmuVbL-BAAoI,22089
|
|
12
12
|
by_framework/common/emitter.py,sha256=Mcp6vglFlS7_JVsLd_KVKvV49TKjoyoN4eCM_tm4I8s,11310
|
|
13
13
|
by_framework/common/exceptions.py,sha256=NKQC7ueLZ4-gVTRz3SFRZNoPHsayu6jxi3-YlW0n_jg,962
|
|
14
14
|
by_framework/common/logger.py,sha256=DX6S7U5CLcCQIUQ3IWqeeDnSC7QGuHKYaEhiKvKrBpk,5823
|
|
@@ -82,7 +82,7 @@ by_framework/worker/__init__.py,sha256=GBkUWYnHc2j3_Wx2AC2P49DzFl0CSrl0SKhdRP5CT
|
|
|
82
82
|
by_framework/worker/_control_handling.py,sha256=0bL1Alx8_qaeXQV32Xv4ARSd9q77ySh9LMd7KtZZXu8,8111
|
|
83
83
|
by_framework/worker/_execution_tracking.py,sha256=AWahfDKTXGrx_JWSCNisjGKkGAQruu9vSlXisof0BYQ,2493
|
|
84
84
|
by_framework/worker/_message_processing.py,sha256=rgKzJTgPVDFp_HUfMcqJBwNdTCEfspuRAo5IM9VKsxs,2622
|
|
85
|
-
by_framework/worker/app.py,sha256=
|
|
85
|
+
by_framework/worker/app.py,sha256=pf_q4F1ypf6u97HP4IpHVPVW5pssMg9_XXAwzv0wJfM,14387
|
|
86
86
|
by_framework/worker/byai_context.py,sha256=DvKw-X8ePZr5c5osdapvzTvH4G23u0J80U-fgMLtge4,2388
|
|
87
87
|
by_framework/worker/byai_worker.py,sha256=0NoRqzuTG_MPMxVbZ1ueeOrqI0H8-Adxh7dM3vckjJo,1757
|
|
88
88
|
by_framework/worker/context.py,sha256=XTNeTAhXvzS2OMDRCDKVD0s3uQscE1rFo9eImUw773w,44747
|
|
@@ -92,8 +92,8 @@ by_framework/worker/runner.py,sha256=ZuuhzdXB4oIjSaNyJCjOIYhzvw6L5N7X6kPzvrbWET8
|
|
|
92
92
|
by_framework/worker/worker.py,sha256=_RmNkvHEN5kDPlqbHtVQhkhgiKx37xjnCxNkf_tvASM,35441
|
|
93
93
|
by_framework/worker/sandbox/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
94
94
|
by_framework/worker/sandbox/hook_sandbox.py,sha256=XXSdH5YGX814LvV03vkq-zn5DVIBPYYt2NhRv1lT1Bk,2329
|
|
95
|
-
by_framework-0.2.2.
|
|
96
|
-
by_framework-0.2.2.
|
|
97
|
-
by_framework-0.2.2.
|
|
98
|
-
by_framework-0.2.2.
|
|
99
|
-
by_framework-0.2.2.
|
|
95
|
+
by_framework-0.2.2.dev9.dist-info/METADATA,sha256=qmdF2bXuu0_IfQI5_QazjrVOxd8EjIHiqnm0PiIVZVo,26533
|
|
96
|
+
by_framework-0.2.2.dev9.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
97
|
+
by_framework-0.2.2.dev9.dist-info/entry_points.txt,sha256=5t6kgMjkR0UgJTpOsbuQDo0fOf7zeXjQW9DhkxfAGFc,56
|
|
98
|
+
by_framework-0.2.2.dev9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
99
|
+
by_framework-0.2.2.dev9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|