weco 0.2.8__py3-none-any.whl → 0.2.10__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/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # DO NOT EDIT
2
- __pkg_version__ = "0.2.8"
2
+ __pkg_version__ = "0.2.10"
3
3
  __api_version__ = "v1"
4
4
  __base_url__ = f"https://api.aide.weco.ai/{__api_version__}"
weco/cli.py CHANGED
@@ -57,6 +57,11 @@ def main() -> None:
57
57
  type=str,
58
58
  help="Description of additional instruction or path to a file containing additional instructions",
59
59
  )
60
+ parser.add_argument(
61
+ "--preserve-source",
62
+ action="store_true",
63
+ help="If set, do not overwrite the original source file; only save modified versions in the runs directory",
64
+ )
60
65
  args = parser.parse_args()
61
66
 
62
67
  try:
@@ -73,15 +78,16 @@ def main() -> None:
73
78
  "debug_prob": 0.5,
74
79
  "max_debug_depth": max(1, math.ceil(0.1 * steps)), # 10% of steps
75
80
  }
81
+ # Read API keys
82
+ api_keys = read_api_keys_from_env()
83
+ # API request timeout
84
+ timeout = 800
85
+
76
86
  # Read additional instructions
77
87
  additional_instructions = read_additional_instructions(additional_instructions=args.additional_instructions)
78
88
  # Read source code
79
89
  source_fp = pathlib.Path(args.source)
80
90
  source_code = read_from_path(fp=source_fp, is_json=False)
81
- # Read API keys
82
- api_keys = read_api_keys_from_env()
83
- # API request timeout
84
- timeout = 800
85
91
 
86
92
  # Initialize panels
87
93
  summary_panel = SummaryPanel(
@@ -119,12 +125,13 @@ def main() -> None:
119
125
  runs_dir.mkdir(parents=True, exist_ok=True)
120
126
 
121
127
  # Save the original code (.runs/<session-id>/original.<extension>)
122
- runs_copy_source_fp = runs_dir / f"original.{source_fp.suffix}"
128
+ runs_copy_source_fp = runs_dir / f"original{source_fp.suffix}"
123
129
  write_to_path(fp=runs_copy_source_fp, content=source_code)
124
130
 
125
131
  # Write the code string to the source file path
126
132
  # Do this after the original code is saved
127
- write_to_path(fp=source_fp, content=session_response["code"])
133
+ if not args.preserve_source:
134
+ write_to_path(fp=source_fp, content=session_response["code"])
128
135
 
129
136
  # Update the panels with the initial solution
130
137
  # Add session id now that we have it
@@ -191,20 +198,25 @@ def main() -> None:
191
198
  )
192
199
 
193
200
  for step in range(1, steps):
201
+ # Re-read instructions from the original source (file path or string) BEFORE each suggest call
202
+ current_additional_instructions = read_additional_instructions(
203
+ additional_instructions=args.additional_instructions
204
+ )
194
205
  # Evaluate the current output and get the next solution
195
206
  eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
196
207
  console=console,
197
208
  session_id=session_id,
198
209
  execution_output=term_out,
199
- additional_instructions=additional_instructions,
210
+ additional_instructions=current_additional_instructions,
200
211
  api_keys=api_keys,
201
212
  timeout=timeout,
202
213
  )
203
214
  # Save next solution (.runs/<session-id>/step_<step>.<extension>)
204
- write_to_path(fp=runs_dir / f"step_{step}.{source_fp.suffix}", content=eval_and_next_solution_response["code"])
215
+ write_to_path(fp=runs_dir / f"step_{step}{source_fp.suffix}", content=eval_and_next_solution_response["code"])
205
216
 
206
217
  # Write the next solution to the source file
207
- write_to_path(fp=source_fp, content=eval_and_next_solution_response["code"])
218
+ if not args.preserve_source:
219
+ write_to_path(fp=source_fp, content=eval_and_next_solution_response["code"])
208
220
 
209
221
  # Get the optimization session status for
210
222
  # the best solution, its score, and the history to plot the tree
@@ -283,12 +295,16 @@ def main() -> None:
283
295
  transition_delay=0.1, # Slightly longer delay for evaluation results
284
296
  )
285
297
 
298
+ # Re-read instructions before the final feedback step
299
+ current_additional_instructions = read_additional_instructions(
300
+ additional_instructions=args.additional_instructions
301
+ )
286
302
  # Ensure we pass evaluation results for the last step's generated solution
287
303
  eval_and_next_solution_response = evaluate_feedback_then_suggest_next_solution(
288
304
  console=console,
289
305
  session_id=session_id,
290
306
  execution_output=term_out,
291
- additional_instructions=additional_instructions,
307
+ additional_instructions=current_additional_instructions,
292
308
  api_keys=api_keys,
293
309
  timeout=timeout,
294
310
  )
@@ -352,10 +368,11 @@ def main() -> None:
352
368
  best_solution_content = f"# Best solution from Weco with a score of {best_score_str}\n\n{best_solution_code}"
353
369
 
354
370
  # Save best solution to .runs/<session-id>/best.<extension>
355
- write_to_path(fp=runs_dir / f"best.{source_fp.suffix}", content=best_solution_content)
371
+ write_to_path(fp=runs_dir / f"best{source_fp.suffix}", content=best_solution_content)
356
372
 
357
373
  # write the best solution to the source file
358
- write_to_path(fp=source_fp, content=best_solution_content)
374
+ if not args.preserve_source:
375
+ write_to_path(fp=source_fp, content=best_solution_content)
359
376
 
360
377
  console.print(end_optimization_layout)
361
378
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: weco
3
- Version: 0.2.8
3
+ Version: 0.2.10
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
6
  License: MIT
@@ -76,7 +76,7 @@ The `weco` CLI leverages a tree search approach guided by Large Language Models
76
76
 
77
77
  This basic example shows how to optimize a simple PyTorch function for speedup.
78
78
 
79
- For more advanced examples, including **[Metal/MLX](/examples/metal/README.md), [Triton](/examples/triton/README.md), [CUDA kernel optimization](/examples/cuda/README.md)**, and **[ML model optimization](/examples/spaceship-titanic/README.md)t**, please see the `README.md` files within the corresponding subdirectories under the [`examples/`](./examples/) folder.
79
+ For more advanced examples, including **[Metal/MLX](/examples/metal/README.md), [Triton](/examples/triton/README.md), [CUDA kernel optimization](/examples/cuda/README.md)**, and **[ML model optimization](/examples/spaceship-titanic/README.md)**, please see the `README.md` files within the corresponding subdirectories under the [`examples/`](./examples/) folder.
80
80
 
81
81
  ```bash
82
82
  # Navigate to the example directory
@@ -108,9 +108,10 @@ weco --source optimize.py \
108
108
  | `--metric` | The name of the metric you want to optimize (e.g., 'accuracy', 'speedup', 'loss'). This metric name should match what's printed by your `--eval-command`. | Yes |
109
109
  | `--maximize` | Whether to maximize (`true`) or minimize (`false`) the metric. | Yes |
110
110
  | `--steps` | Number of optimization steps (LLM iterations) to run. | Yes |
111
- | `--model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.5-sonnet`). Recommended models to try include `o3-mini`, `claude-3-haiku`, and `gemini-2.5-pro-exp-03-25`.| Yes |
111
+ | `--model` | Model identifier for the LLM to use (e.g., `gpt-4o`, `claude-3.7-sonnet`). Recommended models to try include `o4-mini`, and `gemini-2.5-pro-exp-03-25`.| Yes |
112
112
  | `--additional-instructions` | (Optional) Natural language description of specific instructions OR path to a file containing detailed instructions to guide the LLM. | No |
113
113
  | `--log-dir` | (Optional) Path to the directory to log intermediate steps and final optimization result. Defaults to `.runs/`. | No |
114
+ | `--preserve-source` | (Optional) If set, do not overwrite the original `--source` file. Modifications and the best solution will still be saved in the `--log-dir`. | No |
114
115
 
115
116
  ---
116
117
 
@@ -0,0 +1,11 @@
1
+ weco/__init__.py,sha256=4m6mYZh4BUqll1JfPLJW9FXVPLdCY5clDaJ8wYl15Ew,125
2
+ weco/api.py,sha256=89lB2572jApAxkA0DDppDnJKBwvZTa3kH9jFpC0LFDQ,3313
3
+ weco/cli.py,sha256=sOSyRQWVIWmpBPClsFcMaWNyEgtfFY4nyS6re0Ok6wM,18274
4
+ weco/panels.py,sha256=R_df-VAbWyLoqCA9A6UzbIGZ9sm2IgJO4idnyjmrHQk,12701
5
+ weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
6
+ weco-0.2.10.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
+ weco-0.2.10.dist-info/METADATA,sha256=7pUW5Z24Wg1_8A3P-ndHJ3SyXyUflUvYDtSVUBdUOrw,9379
8
+ weco-0.2.10.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
9
+ weco-0.2.10.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
+ weco-0.2.10.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
+ weco-0.2.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (79.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- weco/__init__.py,sha256=VUGnYC55MzHzmhg_IT0RRJ3QJDE3D2QFmvwGhhJ8hwA,124
2
- weco/api.py,sha256=89lB2572jApAxkA0DDppDnJKBwvZTa3kH9jFpC0LFDQ,3313
3
- weco/cli.py,sha256=8WotHdSRGP5GwLucEQltiMRH8zVrGB84n8o2mhUaCco,17408
4
- weco/panels.py,sha256=R_df-VAbWyLoqCA9A6UzbIGZ9sm2IgJO4idnyjmrHQk,12701
5
- weco/utils.py,sha256=hhIebUPnetFMfNSFfcsKVw1TSpeu_Zw3rBPPnxDie0U,3911
6
- weco-0.2.8.dist-info/licenses/LICENSE,sha256=p_GQqJBvuZgkLNboYKyH-5dhpTDlKs2wq2TVM55WrWE,1065
7
- weco-0.2.8.dist-info/METADATA,sha256=5KLO8utu8ItVkPmJ6uLy3NHCUpLsRit_OvyT70Sp7XI,9179
8
- weco-0.2.8.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
9
- weco-0.2.8.dist-info/entry_points.txt,sha256=ixJ2uClALbCpBvnIR6BXMNck8SHAab8eVkM9pIUowcs,39
10
- weco-0.2.8.dist-info/top_level.txt,sha256=F0N7v6e2zBSlsorFv-arAq2yDxQbzX3KVO8GxYhPUeE,5
11
- weco-0.2.8.dist-info/RECORD,,