Skip to content

Commit 1ccbc5d

Browse files
reckless: reduce uv verbosity and avoid flooding output
This was overloading the reckless-rpc plugin input when outputting json all in one shot. The verbosity was mostly dependency resolution which wasn't all that helpful so call uv pip install as normal. Changelog-None: bug introduced this release.
1 parent 54a8aca commit 1ccbc5d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tools/reckless

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ logging.basicConfig(
3232
LAST_FOUND = None
3333

3434

35+
def chunk_string(string: str, size: int):
36+
for i in range(0, len(string), size):
37+
yield string[i: i + size]
38+
39+
40+
def ratelimit_output(output: str):
41+
sys.stdout.reconfigure(encoding='utf-8')
42+
for i in chunk_string(output, 1024):
43+
sys.stdout.write(i)
44+
sys.stdout.flush()
45+
time.sleep(0.01)
46+
47+
3548
class Logger:
3649
"""Redirect logging output to a json object or stdout as appropriate."""
3750
def __init__(self, capture: bool = False):
@@ -89,7 +102,8 @@ class Logger:
89102
isinstance(log.json_output["result"][0], list):
90103
# unpack sources output
91104
log.json_output["result"] = log.json_output["result"][0]
92-
print(json.dumps(log.json_output, indent=3))
105+
output = json.dumps(log.json_output, indent=3) + '\n'
106+
ratelimit_output(output)
93107

94108

95109
log = Logger()
@@ -1027,7 +1041,7 @@ def install_python_uv_legacy(cloned_plugin: InstInfo):
10271041
(Path(cloned_plugin.source_loc) / 'requirements.txt').\
10281042
symlink_to(source / 'requirements.txt')
10291043

1030-
venv = run(['uv', '-v', 'venv'], cwd=str(cloned_plugin.source_loc),
1044+
venv = run(['uv', 'venv'], cwd=str(cloned_plugin.source_loc),
10311045
stdout=PIPE, stderr=PIPE, text=True, check=False)
10321046
if venv.returncode != 0:
10331047
for line in venv.stderr.splitlines():
@@ -1041,7 +1055,7 @@ def install_python_uv_legacy(cloned_plugin: InstInfo):
10411055
# Running this as a shell allows overriding any active virtual environment
10421056
# which would make uv skip installing packages already present in the
10431057
# current env.
1044-
call = ['. .venv/bin/activate; uv -v pip install -r requirements.txt']
1058+
call = ['. .venv/bin/activate; uv pip install -r requirements.txt']
10451059
uv = run(call, shell=True, cwd=str(cloned_plugin.source_loc),
10461060
stdout=PIPE, stderr=PIPE, text=True, check=False)
10471061
if uv.returncode != 0:

0 commit comments

Comments
 (0)