weco 0.2.26__py3-none-any.whl → 0.2.27__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.
weco/api.py CHANGED
@@ -5,6 +5,7 @@ from rich.console import Console
5
5
 
6
6
  from weco import __pkg_version__, __base_url__
7
7
  from .constants import DEFAULT_API_TIMEOUT
8
+ from .utils import truncate_output
8
9
 
9
10
 
10
11
  def handle_api_error(e: requests.exceptions.HTTPError, console: Console) -> None:
@@ -35,7 +36,7 @@ def start_optimization_run(
35
36
  with console.status("[bold green]Starting Optimization..."):
36
37
  try:
37
38
  response = requests.post(
38
- f"{__base_url__}/runs",
39
+ f"{__base_url__}/runs/",
39
40
  json={
40
41
  "source_code": source_code,
41
42
  "additional_instructions": additional_instructions,
@@ -78,10 +79,13 @@ def evaluate_feedback_then_suggest_next_solution(
78
79
  ) -> Dict[str, Any]:
79
80
  """Evaluate the feedback and suggest the next solution."""
80
81
  try:
82
+ # Truncate the execution output before sending to backend
83
+ truncated_output = truncate_output(execution_output)
84
+
81
85
  response = requests.post(
82
86
  f"{__base_url__}/runs/{run_id}/suggest",
83
87
  json={
84
- "execution_output": execution_output,
88
+ "execution_output": truncated_output,
85
89
  "additional_instructions": additional_instructions,
86
90
  "metadata": {**api_keys},
87
91
  },
@@ -217,8 +221,8 @@ def get_optimization_suggestions_from_codebase(
217
221
  timeout: Union[int, Tuple[int, int]] = DEFAULT_API_TIMEOUT,
218
222
  ) -> Optional[List[Dict[str, Any]]]:
219
223
  """Analyze codebase and get optimization suggestions using the model-agnostic backend API."""
220
- model, api_key_dict = _determine_model_and_api_key()
221
224
  try:
225
+ model, api_key_dict = _determine_model_and_api_key()
222
226
  response = requests.post(
223
227
  f"{__base_url__}/onboard/analyze-codebase",
224
228
  json={
@@ -252,8 +256,8 @@ def generate_evaluation_script_and_metrics(
252
256
  timeout: Union[int, Tuple[int, int]] = DEFAULT_API_TIMEOUT,
253
257
  ) -> Tuple[Optional[str], Optional[str], Optional[str], Optional[str]]:
254
258
  """Generate evaluation script and determine metrics using the model-agnostic backend API."""
255
- model, api_key_dict = _determine_model_and_api_key()
256
259
  try:
260
+ model, api_key_dict = _determine_model_and_api_key()
257
261
  response = requests.post(
258
262
  f"{__base_url__}/onboard/generate-script",
259
263
  json={
@@ -288,8 +292,8 @@ def analyze_evaluation_environment(
288
292
  timeout: Union[int, Tuple[int, int]] = DEFAULT_API_TIMEOUT,
289
293
  ) -> Optional[Dict[str, Any]]:
290
294
  """Analyze existing evaluation scripts and environment using the model-agnostic backend API."""
291
- model, api_key_dict = _determine_model_and_api_key()
292
295
  try:
296
+ model, api_key_dict = _determine_model_and_api_key()
293
297
  response = requests.post(
294
298
  f"{__base_url__}/onboard/analyze-environment",
295
299
  json={
@@ -324,8 +328,8 @@ def analyze_script_execution_requirements(
324
328
  timeout: Union[int, Tuple[int, int]] = DEFAULT_API_TIMEOUT,
325
329
  ) -> Optional[str]:
326
330
  """Analyze script to determine proper execution command using the model-agnostic backend API."""
327
- model, api_key_dict = _determine_model_and_api_key()
328
331
  try:
332
+ model, api_key_dict = _determine_model_and_api_key()
329
333
  response = requests.post(
330
334
  f"{__base_url__}/onboard/analyze-script",
331
335
  json={
weco/cli.py CHANGED
@@ -67,6 +67,11 @@ def configure_run_parser(run_parser: argparse.ArgumentParser) -> None:
67
67
  default=None,
68
68
  help="Timeout in seconds for each evaluation. No timeout by default. Example: --eval-timeout 3600",
69
69
  )
70
+ run_parser.add_argument(
71
+ "--save-logs",
72
+ action="store_true",
73
+ help="Save execution output to .runs/<run-id>/outputs/step_<n>.out.txt with JSONL index",
74
+ )
70
75
 
71
76
 
72
77
  def execute_run_command(args: argparse.Namespace) -> None:
@@ -84,6 +89,7 @@ def execute_run_command(args: argparse.Namespace) -> None:
84
89
  additional_instructions=args.additional_instructions,
85
90
  console=console,
86
91
  eval_timeout=args.eval_timeout,
92
+ save_logs=args.save_logs,
87
93
  )
88
94
  exit_code = 0 if success else 1
89
95
  sys.exit(exit_code)
weco/constants.py CHANGED
@@ -5,3 +5,7 @@ Constants for the Weco CLI package.
5
5
 
6
6
  # API timeout configuration (connect_timeout, read_timeout) in seconds
7
7
  DEFAULT_API_TIMEOUT = (10, 800)
8
+
9
+ # Output truncation configuration
10
+ TRUNCATION_THRESHOLD = 51000 # Maximum length before truncation
11
+ TRUNCATION_KEEP_LENGTH = 25000 # Characters to keep from beginning and end
weco/optimizer.py CHANGED
@@ -5,6 +5,8 @@ import threading
5
5
  import signal
6
6
  import sys
7
7
  import traceback
8
+ import json
9
+ from datetime import datetime
8
10
  from typing import Optional
9
11
  from rich.console import Console
10
12
  from rich.live import Live
@@ -39,6 +41,36 @@ from .utils import (
39
41
  from .constants import DEFAULT_API_TIMEOUT
40
42
 
41
43
 
44
+ def save_execution_output(runs_dir: pathlib.Path, step: int, output: str) -> None:
45
+ """
46
+ Save execution output using hybrid approach:
47
+ 1. Per-step raw files under outputs/step_<n>.out.txt
48
+ 2. Centralized JSONL index in exec_output.jsonl
49
+
50
+ Args:
51
+ runs_dir: Path to the run directory (.runs/<run_id>)
52
+ step: Current step number
53
+ output: The execution output to save
54
+ """
55
+ timestamp = datetime.now().isoformat()
56
+
57
+ # Create outputs directory if it doesn't exist
58
+ outputs_dir = runs_dir / "outputs"
59
+ outputs_dir.mkdir(parents=True, exist_ok=True)
60
+
61
+ # Save per-step raw output file
62
+ step_file = outputs_dir / f"step_{step}.out.txt"
63
+ with open(step_file, "w", encoding="utf-8") as f:
64
+ f.write(output)
65
+
66
+ # Append to centralized JSONL index
67
+ jsonl_file = runs_dir / "exec_output.jsonl"
68
+ output_file_path = step_file.relative_to(runs_dir).as_posix()
69
+ entry = {"step": step, "timestamp": timestamp, "output_file": output_file_path, "output_length": len(output)}
70
+ with open(jsonl_file, "a", encoding="utf-8") as f:
71
+ f.write(json.dumps(entry) + "\n")
72
+
73
+
42
74
  # --- Heartbeat Sender Class ---
43
75
  class HeartbeatSender(threading.Thread):
44
76
  def __init__(self, run_id: str, auth_headers: dict, stop_event: threading.Event, interval: int = 30):
@@ -79,6 +111,7 @@ def execute_optimization(
79
111
  additional_instructions: Optional[str] = None,
80
112
  console: Optional[Console] = None,
81
113
  eval_timeout: Optional[int] = None,
114
+ save_logs: bool = False,
82
115
  ) -> bool:
83
116
  """
84
117
  Execute the core optimization logic.
@@ -202,6 +235,23 @@ def execute_optimization(
202
235
  # Define the runs directory (.runs/<run-id>) to store logs and results
203
236
  runs_dir = pathlib.Path(log_dir) / run_id
204
237
  runs_dir.mkdir(parents=True, exist_ok=True)
238
+
239
+ # Initialize logging structure if save_logs is enabled
240
+ if save_logs:
241
+ # Initialize JSONL index with metadata
242
+ jsonl_file = runs_dir / "exec_output.jsonl"
243
+ metadata = {
244
+ "type": "metadata",
245
+ "run_id": run_id,
246
+ "run_name": run_name,
247
+ "started": datetime.now().isoformat(),
248
+ "eval_command": eval_command,
249
+ "metric": metric,
250
+ "goal": "maximize" if maximize else "minimize",
251
+ "total_steps": steps,
252
+ }
253
+ with open(jsonl_file, "w", encoding="utf-8") as f:
254
+ f.write(json.dumps(metadata) + "\n")
205
255
  # Write the initial code string to the logs
206
256
  write_to_path(fp=runs_dir / f"step_0{source_fp.suffix}", content=run_response["code"])
207
257
  # Write the initial code string to the source file path
@@ -255,6 +305,9 @@ def execute_optimization(
255
305
 
256
306
  # Run evaluation on the initial solution
257
307
  term_out = run_evaluation(eval_command=eval_command, timeout=eval_timeout)
308
+ # Save logs if requested
309
+ if save_logs:
310
+ save_execution_output(runs_dir, step=0, output=term_out)
258
311
  # Update the evaluation output panel
259
312
  eval_output_panel.update(output=term_out)
260
313
  smooth_update(
@@ -356,6 +409,9 @@ def execute_optimization(
356
409
  transition_delay=0.08, # Slightly longer delay for more noticeable transitions
357
410
  )
358
411
  term_out = run_evaluation(eval_command=eval_command, timeout=eval_timeout)
412
+ # Save logs if requested
413
+ if save_logs:
414
+ save_execution_output(runs_dir, step=step, output=term_out)
359
415
  eval_output_panel.update(output=term_out)
360
416
  smooth_update(
361
417
  live=live,
weco/utils.py CHANGED
@@ -10,6 +10,8 @@ import pathlib
10
10
  import requests
11
11
  from packaging.version import parse as parse_version
12
12
 
13
+ from .constants import TRUNCATION_THRESHOLD, TRUNCATION_KEEP_LENGTH
14
+
13
15
 
14
16
  # Env/arg helper functions
15
17
  def read_api_keys_from_env() -> Dict[str, Any]:
@@ -124,37 +126,29 @@ def smooth_update(
124
126
 
125
127
 
126
128
  # Other helper functions
127
- DEFAULT_MAX_LINES = 50
128
- DEFAULT_MAX_CHARS = 5000
129
-
130
-
131
- def truncate_output(output: str, max_lines: int = DEFAULT_MAX_LINES, max_chars: int = DEFAULT_MAX_CHARS) -> str:
132
- """Truncate the output to a reasonable size."""
133
- lines = output.splitlines()
134
-
135
- # Determine what truncations are needed based on original output
136
- lines_truncated = len(lines) > max_lines
137
- chars_truncated = len(output) > max_chars
129
+ def truncate_output(output: str) -> str:
130
+ """Truncate long output to a manageable size.
138
131
 
139
- # Apply truncations to the original output
140
- if lines_truncated:
141
- output = "\n".join(lines[-max_lines:])
132
+ If output exceeds TRUNCATION_THRESHOLD characters, keeps the first
133
+ TRUNCATION_KEEP_LENGTH and last TRUNCATION_KEEP_LENGTH characters
134
+ with a truncation message.
142
135
 
143
- if chars_truncated:
144
- output = output[-max_chars:]
145
-
146
- # Add prefixes for truncations that were applied
147
- prefixes = []
148
- if lines_truncated:
149
- prefixes.append(f"truncated to last {max_lines} lines")
150
- if chars_truncated:
151
- prefixes.append(f"truncated to last {max_chars} characters")
136
+ Args:
137
+ output: The output string to truncate
138
+ """
139
+ # Check if the length of the string is longer than the threshold
140
+ if len(output) > TRUNCATION_THRESHOLD:
141
+ # Output the first TRUNCATION_KEEP_LENGTH and last TRUNCATION_KEEP_LENGTH characters
142
+ first_k_chars = output[:TRUNCATION_KEEP_LENGTH]
143
+ last_k_chars = output[-TRUNCATION_KEEP_LENGTH:]
152
144
 
153
- if prefixes:
154
- prefix_text = ", ".join(prefixes)
155
- output = f"... ({prefix_text})\n{output}"
145
+ truncated_len = len(output) - 2 * TRUNCATION_KEEP_LENGTH
156
146
 
157
- return output
147
+ if truncated_len <= 0:
148
+ return output
149
+ return f"{first_k_chars}\n ... [{truncated_len} characters truncated] ... \n{last_k_chars}"
150
+ else:
151
+ return output
158
152
 
159
153
 
160
154
  def run_evaluation(eval_command: str, timeout: int | None = None) -> str:
@@ -169,7 +163,7 @@ def run_evaluation(eval_command: str, timeout: int | None = None) -> str:
169
163
  if len(output) > 0:
170
164
  output += "\n"
171
165
  output += result.stdout
172
- return truncate_output(output)
166
+ return output # Return full output, no truncation
173
167
  except subprocess.TimeoutExpired:
174
168
  return f"Evaluation timed out after {'an unspecified duration' if timeout is None else f'{timeout} seconds'}."
175
169
 
@@ -1,14 +1,215 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weco
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: Documentation for `weco`, a CLI for using Weco AI's code optimizer.
5
5
  Author-email: Weco AI Team <contact@weco.ai>
6
- License: MIT
6
+ License:
7
+ Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+ APPENDIX: How to apply the Apache License to your work.
185
+
186
+ To apply the Apache License to your work, attach the following
187
+ boilerplate notice, with the fields enclosed by brackets "[]"
188
+ replaced with your own identifying information. (Don't include
189
+ the brackets!) The text should be enclosed in the appropriate
190
+ comment syntax for the file format. We also recommend that a
191
+ file or class name and description of purpose be included on the
192
+ same "printed page" as the copyright notice for easier
193
+ identification within third-party archives.
194
+
195
+ Copyright 2025 Weco AI
196
+
197
+ Licensed under the Apache License, Version 2.0 (the "License");
198
+ you may not use this file except in compliance with the License.
199
+ You may obtain a copy of the License at
200
+
201
+ http://www.apache.org/licenses/LICENSE-2.0
202
+
203
+ Unless required by applicable law or agreed to in writing, software
204
+ distributed under the License is distributed on an "AS IS" BASIS,
205
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
206
+ See the License for the specific language governing permissions and
207
+ limitations under the License.
7
208
  Project-URL: Homepage, https://github.com/WecoAI/weco-cli
8
209
  Keywords: AI,Code Optimization,Code Generation
9
210
  Classifier: Programming Language :: Python :: 3
10
211
  Classifier: Operating System :: OS Independent
11
- Classifier: License :: OSI Approved :: MIT License
212
+ Classifier: License :: OSI Approved :: Apache Software License
12
213
  Requires-Python: >=3.8
13
214
  Description-Content-Type: text/markdown
14
215
  License-File: LICENSE
@@ -69,7 +270,7 @@ The `weco` CLI leverages a tree search approach guided by LLMs to iteratively ex
69
270
  1. **Install the Package:**
70
271
 
71
272
  ```bash
72
- pip install weco
273
+ pip install weco>=0.2.18
73
274
  ```
74
275
 
75
276
  2. **Set Up LLM API Keys (Required):**
@@ -161,6 +362,7 @@ For more advanced examples, including [Triton](/examples/triton/README.md), [CUD
161
362
  | `-i, --additional-instructions`| Natural language description of specific instructions **or** path to a file containing detailed instructions to guide the LLM. | `None` | `-i instructions.md` or `-i "Optimize the model for faster inference"`|
162
363
  | `-l, --log-dir` | Path to the directory to log intermediate steps and final optimization result. | `.runs/` | `-l ./logs/` |
163
364
  | `--eval-timeout` | Timeout in seconds for each step in evaluation. | No timeout (unlimited) | `--eval-timeout 3600` |
365
+ | `--save-logs` | Save execution output from each optimization step to disk. Creates timestamped directories with raw output files and a JSONL index for tracking execution history. | `False` | `--save-logs` |
164
366
 
165
367
  ---
166
368
 
@@ -233,6 +435,42 @@ As shown, AIDE demonstrates strong performance gains over time, surpassing lower
233
435
 
234
436
  ---
235
437
 
438
+ ### Saving Execution Logs
439
+
440
+ When using the `--save-logs` flag, Weco saves the execution output from each optimization step to help with debugging and analysis. The logs are organized as follows:
441
+
442
+ ```
443
+ .runs/
444
+ └── <source-file-name>/
445
+ └── <run-uuid>/
446
+ ├── exec_output.jsonl # Index file with metadata for each step
447
+ ├── outputs/
448
+ │ ├── step_0.out.txt # Raw output from initial evaluation
449
+ │ ├── step_1.out.txt # Raw output from step 1
450
+ │ ├── step_2.out.txt # Raw output from step 2
451
+ │ └── ...
452
+ ├── step_0.py # Code snapshot from initial evaluation
453
+ ├── step_1.py # Code snapshot from step 1
454
+ ├── step_2.py # Code snapshot from step 2
455
+ └── ...
456
+ ```
457
+
458
+ Each run is organized under the source file name (e.g., `spaceship-titanic` for `spaceship-titanic.py`) and a unique UUID. The `outputs/` directory and `exec_output.jsonl` file are only created when the `--save-logs` flag is used.
459
+
460
+ The `exec_output.jsonl` file contains one JSON object per line with:
461
+ - `step`: The optimization step number
462
+ - `timestamp`: When the execution occurred
463
+ - `output_file`: Relative path to the full output file
464
+ - `output_length`: Total length of the output
465
+
466
+ This is particularly useful for:
467
+ - Debugging why certain optimizations fail
468
+ - Analyzing patterns in evaluation results
469
+ - Keeping records of long-running optimization sessions
470
+ - Troubleshooting evaluation script issues
471
+
472
+ ---
473
+
236
474
  ### Important Note on Evaluation
237
475
 
238
476
  The command specified by `--eval-command` is crucial. It's responsible for executing the potentially modified code from `--source` and assessing its performance. **This command MUST print the metric you specified with `--metric` along with its numerical value to the terminal (standard output or standard error).** Weco reads this output to understand how well each code version performs and guide the optimization process.
@@ -251,14 +489,20 @@ Final speedup value = 1.5
251
489
 
252
490
  Weco will parse this output to extract the numerical value (1.5 in this case) associated with the metric name ('speedup').
253
491
 
492
+ **Note on Output Truncation:** When evaluation output exceeds 51,000 characters, Weco truncates it to show the first 25,000 and last 25,000 characters. For best results, ensure your evaluation script prints the metric value near the end of its output.
493
+
254
494
  ## Supported Models
255
495
 
256
496
  Weco supports the following LLM models:
257
497
 
258
498
  ### OpenAI Models
259
- - `o3`
499
+ - `gpt-5` (recommended)
500
+ - `gpt-5-mini`
501
+ - `gpt-5-nano`
502
+ - `o3-pro` (recommended)
503
+ - `o3` (recommended)
504
+ - `o4-mini` (recommended)
260
505
  - `o3-mini`
261
- - `o4-mini`
262
506
  - `o1-pro`
263
507
  - `o1`
264
508
  - `gpt-4.1`
@@ -266,6 +510,7 @@ Weco supports the following LLM models:
266
510
  - `gpt-4.1-nano`
267
511
  - `gpt-4o`
268
512
  - `gpt-4o-mini`
513
+ - `codex-mini-latest`
269
514
 
270
515
  ### Anthropic Models
271
516
  - `claude-opus-4-1`
@@ -0,0 +1,15 @@
1
+ weco/__init__.py,sha256=ClO0uT6GKOA0iSptvP0xbtdycf0VpoPTq37jHtvlhtw,303
2
+ weco/api.py,sha256=cdZEf-Zt0CxMOj_gka6rGHEK1MVwPAjG1YH16jgDEsg,13177
3
+ weco/auth.py,sha256=KMSAsN1V5wx7KUsYL1cEOOiG29Pqf4Exb3EPW4mAWC0,10003
4
+ weco/chatbot.py,sha256=EkzKd5Q_IlcobBbY3gsbgN0jxbJMfP5eYtzxQaNQ3fg,37747
5
+ weco/cli.py,sha256=8hrlmHmaZiYQ7kotdpr4Ve-xAJZocDV6kcizPCmep0k,8380
6
+ weco/constants.py,sha256=hyBmHldKrfoYhdfkZ1OeHZ1gFmAqhD5j_XEnAx6gPG4,344
7
+ weco/optimizer.py,sha256=bXhNoa2qyC-CeqLHacy3xz2UKHuO_DVpC3z572NjFSU,26063
8
+ weco/panels.py,sha256=jwAV_uoa0ZI9vjyey-hSY3rx4pfNNkZvPzqt-iz-RXo,16808
9
+ weco/utils.py,sha256=P6efzBXg7m_Nnq6UUor9onCGxjE0CkTI2xYsymmCwZ4,7355
10
+ weco-0.2.27.dist-info/licenses/LICENSE,sha256=9LUfoGHjLPtak2zps2kL2tm65HAZIICx_FbLaRuS4KU,11337
11
+ weco-0.2.27.dist-info/METADATA,sha256=s3VcnhEWJjEp6sNQGTxFyxCR_xIGld4rBryAopnCNTM,31432
12
+ weco-0.2.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ weco-0.2.27.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
14
+ weco-0.2.27.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
15
+ weco-0.2.27.dist-info/RECORD,,
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025 Weco AI
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -1,15 +0,0 @@
1
- weco/__init__.py,sha256=ClO0uT6GKOA0iSptvP0xbtdycf0VpoPTq37jHtvlhtw,303
2
- weco/api.py,sha256=sz97FI0cMm4ku6bMnXsY9Jqgu-lUNELpF6L6vqIaSDE,12997
3
- weco/auth.py,sha256=KMSAsN1V5wx7KUsYL1cEOOiG29Pqf4Exb3EPW4mAWC0,10003
4
- weco/chatbot.py,sha256=EkzKd5Q_IlcobBbY3gsbgN0jxbJMfP5eYtzxQaNQ3fg,37747
5
- weco/cli.py,sha256=jasJpAwibp2rfZflE1LebyQz1dh55Y32G6qDINw4B_U,8161
6
- weco/constants.py,sha256=vfQGDf9_kzlN9BzEFvMsd0EeXOsRyzpvSWyxOJgRauE,168
7
- weco/optimizer.py,sha256=iFI1h2HlKFYMiIxVoTFS5aulUIuNjMbsOQw3MGfXIwI,23819
8
- weco/panels.py,sha256=jwAV_uoa0ZI9vjyey-hSY3rx4pfNNkZvPzqt-iz-RXo,16808
9
- weco/utils.py,sha256=HecbOqD5rBuVhUkLixVrTWBMJ-ZMAhK-889N-lCk3dQ,7335
10
- weco-0.2.26.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
11
- weco-0.2.26.dist-info/METADATA,sha256=liTaJZxAI_4Xe21aZ-1YKUzHEvtn1vzyu0liTayEb98,16089
12
- weco-0.2.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- weco-0.2.26.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
14
- weco-0.2.26.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
15
- weco-0.2.26.dist-info/RECORD,,
@@ -1,22 +0,0 @@
1
-
2
- MIT License
3
-
4
- Copyright (c) 2025 Weco AI
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
File without changes